0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-23 09:15:46 +00:00

Implement GPU primitive restart (#221)

This commit is contained in:
ReinUsesLisp 2018-07-08 13:14:35 -03:00 committed by gdkchan
parent dc04b5465f
commit 6479c3e484
4 changed files with 47 additions and 0 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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);

View file

@ -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,