aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-07-19 02:30:21 -0300
committerGitHub <noreply@github.com>2018-07-19 02:30:21 -0300
commit60f2198a1e8e61fe1cfb8da30a6afcd86a672a85 (patch)
treebe608a9f483e751d6d4bf4d9037048c94d495b0d /Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs
parent8b685b12f0b7a901139999dff17b24b049b9084b (diff)
Support deswizzle of sparse tiled textures and some frame buffer fixes (#275)
* Attempt to support deswizzle of sparse tiled textures * Use correct frame buffer and viewport sizes, started to clean up the copy engine * Correct texture width alignment * Use Scale/Translate registers to calculate viewport rect * Allow texture copy between frame buffers
Diffstat (limited to 'Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs')
-rw-r--r--Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs26
1 files changed, 19 insertions, 7 deletions
diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs
index 5c474ab0..dce25a5e 100644
--- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs
+++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs
@@ -132,10 +132,22 @@ namespace Ryujinx.HLE.Gpu.Engines
int Width = ReadRegister(NvGpuEngine3dReg.FrameBufferNWidth + FbIndex * 0x10);
int Height = ReadRegister(NvGpuEngine3dReg.FrameBufferNHeight + FbIndex * 0x10);
- //Note: Using the Width/Height results seems to give incorrect results.
- //Maybe the size of all frame buffers is hardcoded to screen size? This seems unlikely.
- Gpu.Renderer.FrameBuffer.Create(Key, 1280, 720);
+ float TX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateX + FbIndex * 4);
+ float TY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNTranslateY + FbIndex * 4);
+
+ float SX = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleX + FbIndex * 4);
+ float SY = ReadRegisterFloat(NvGpuEngine3dReg.ViewportNScaleY + FbIndex * 4);
+
+ int VpX = (int)MathF.Max(0, TX - MathF.Abs(SX));
+ int VpY = (int)MathF.Max(0, TY - MathF.Abs(SY));
+
+ int VpW = (int)(TX + MathF.Abs(SX)) - VpX;
+ int VpH = (int)(TY + MathF.Abs(SY)) - VpY;
+
+ Gpu.Renderer.FrameBuffer.Create(Key, Width, Height);
Gpu.Renderer.FrameBuffer.Bind(Key);
+
+ Gpu.Renderer.FrameBuffer.SetViewport(VpX, VpY, VpW, VpH);
}
private long[] UploadShaders(NvGpuVmm Vmm)
@@ -195,8 +207,8 @@ namespace Ryujinx.HLE.Gpu.Engines
Gpu.Renderer.Shader.Bind(Key);
}
- float SignX = GetFlipSign(NvGpuEngine3dReg.ViewportScaleX);
- float SignY = GetFlipSign(NvGpuEngine3dReg.ViewportScaleY);
+ float SignX = GetFlipSign(NvGpuEngine3dReg.ViewportNScaleX);
+ float SignY = GetFlipSign(NvGpuEngine3dReg.ViewportNScaleY);
Gpu.Renderer.Shader.SetFlip(SignX, SignY);
@@ -220,8 +232,8 @@ namespace Ryujinx.HLE.Gpu.Engines
private void SetFrontFace()
{
- float SignX = GetFlipSign(NvGpuEngine3dReg.ViewportScaleX);
- float SignY = GetFlipSign(NvGpuEngine3dReg.ViewportScaleY);
+ float SignX = GetFlipSign(NvGpuEngine3dReg.ViewportNScaleX);
+ float SignY = GetFlipSign(NvGpuEngine3dReg.ViewportNScaleY);
GalFrontFace FrontFace = (GalFrontFace)ReadRegister(NvGpuEngine3dReg.FrontFace);