diff --git a/Ryujinx.Graphics/Gal/IGalRasterizer.cs b/Ryujinx.Graphics/Gal/IGalRasterizer.cs index 586eae6b..2598efb6 100644 --- a/Ryujinx.Graphics/Gal/IGalRasterizer.cs +++ b/Ryujinx.Graphics/Gal/IGalRasterizer.cs @@ -36,6 +36,12 @@ namespace Ryujinx.Graphics.Gal void SetClearStencil(int Stencil); + void EnablePrimitiveRestart(); + + void DisablePrimitiveRestart(); + + void SetPrimitiveRestartIndex(uint Index); + void CreateVbo(long Key, byte[] Buffer); void CreateIbo(long Key, byte[] Buffer); diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs index b9885711..a4ec7f87 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs @@ -184,6 +184,21 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.ClearStencil(Stencil); } + public void EnablePrimitiveRestart() + { + GL.Enable(EnableCap.PrimitiveRestart); + } + + public void DisablePrimitiveRestart() + { + GL.Disable(EnableCap.PrimitiveRestart); + } + + public void SetPrimitiveRestartIndex(uint Index) + { + GL.PrimitiveRestartIndex(Index); + } + public void CreateVbo(long Key, byte[] Buffer) { int Handle = GL.GenBuffer(); diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs index d46f5089..10c99494 100644 --- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs @@ -85,6 +85,7 @@ namespace Ryujinx.HLE.Gpu.Engines SetDepth(); SetStencil(); SetAlphaBlending(); + SetPrimitiveRestart(); UploadTextures(Vmm, Keys); UploadUniforms(Vmm); @@ -389,6 +390,29 @@ namespace Ryujinx.HLE.Gpu.Engines } } + private void SetPrimitiveRestart() + { + bool Enable = (ReadRegister(NvGpuEngine3dReg.PrimRestartEnable) & 1) != 0; + + if (Enable) + { + Gpu.Renderer.Rasterizer.EnablePrimitiveRestart(); + } + else + { + Gpu.Renderer.Rasterizer.DisablePrimitiveRestart(); + } + + if (!Enable) + { + return; + } + + uint Index = (uint)ReadRegister(NvGpuEngine3dReg.PrimRestartIndex); + + Gpu.Renderer.Rasterizer.SetPrimitiveRestartIndex(Index); + } + private void UploadTextures(NvGpuVmm Vmm, long[] Keys) { long BaseShPosition = MakeInt64From2xInt32(NvGpuEngine3dReg.ShaderAddress); diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3dReg.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3dReg.cs index 9eb2966d..3de2885e 100644 --- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3dReg.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3dReg.cs @@ -50,6 +50,8 @@ namespace Ryujinx.HLE.Gpu.Engines StencilBackFuncFunc = 0x569, ShaderAddress = 0x582, VertexBeginGl = 0x586, + PrimRestartEnable = 0x591, + PrimRestartIndex = 0x592, IndexArrayAddress = 0x5f2, IndexArrayEndAddr = 0x5f4, IndexArrayFormat = 0x5f6,