mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-24 13:44:16 +00:00
Add depth range support on the GPU (#472)
* Add depth range support on the GPU * Address PR feedback
This commit is contained in:
parent
e674b37710
commit
044b84b078
4 changed files with 35 additions and 20 deletions
|
@ -43,6 +43,8 @@
|
||||||
public bool DepthTestEnabled;
|
public bool DepthTestEnabled;
|
||||||
public bool DepthWriteEnabled;
|
public bool DepthWriteEnabled;
|
||||||
public GalComparisonOp DepthFunc;
|
public GalComparisonOp DepthFunc;
|
||||||
|
public float DepthRangeNear;
|
||||||
|
public float DepthRangeFar;
|
||||||
|
|
||||||
public bool StencilTestEnabled;
|
public bool StencilTestEnabled;
|
||||||
public bool StencilTwoSideEnabled;
|
public bool StencilTwoSideEnabled;
|
||||||
|
|
|
@ -95,44 +95,46 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
FrontFace = GalFrontFace.CCW,
|
FrontFace = GalFrontFace.CCW,
|
||||||
|
|
||||||
CullFaceEnabled = false,
|
CullFaceEnabled = false,
|
||||||
CullFace = GalCullFace.Back,
|
CullFace = GalCullFace.Back,
|
||||||
|
|
||||||
DepthTestEnabled = false,
|
DepthTestEnabled = false,
|
||||||
DepthWriteEnabled = true,
|
DepthWriteEnabled = true,
|
||||||
DepthFunc = GalComparisonOp.Less,
|
DepthFunc = GalComparisonOp.Less,
|
||||||
|
DepthRangeNear = 0,
|
||||||
|
DepthRangeFar = 1,
|
||||||
|
|
||||||
StencilTestEnabled = false,
|
StencilTestEnabled = false,
|
||||||
|
|
||||||
StencilBackFuncFunc = GalComparisonOp.Always,
|
StencilBackFuncFunc = GalComparisonOp.Always,
|
||||||
StencilBackFuncRef = 0,
|
StencilBackFuncRef = 0,
|
||||||
StencilBackFuncMask = UInt32.MaxValue,
|
StencilBackFuncMask = UInt32.MaxValue,
|
||||||
StencilBackOpFail = GalStencilOp.Keep,
|
StencilBackOpFail = GalStencilOp.Keep,
|
||||||
StencilBackOpZFail = GalStencilOp.Keep,
|
StencilBackOpZFail = GalStencilOp.Keep,
|
||||||
StencilBackOpZPass = GalStencilOp.Keep,
|
StencilBackOpZPass = GalStencilOp.Keep,
|
||||||
StencilBackMask = UInt32.MaxValue,
|
StencilBackMask = UInt32.MaxValue,
|
||||||
|
|
||||||
StencilFrontFuncFunc = GalComparisonOp.Always,
|
StencilFrontFuncFunc = GalComparisonOp.Always,
|
||||||
StencilFrontFuncRef = 0,
|
StencilFrontFuncRef = 0,
|
||||||
StencilFrontFuncMask = UInt32.MaxValue,
|
StencilFrontFuncMask = UInt32.MaxValue,
|
||||||
StencilFrontOpFail = GalStencilOp.Keep,
|
StencilFrontOpFail = GalStencilOp.Keep,
|
||||||
StencilFrontOpZFail = GalStencilOp.Keep,
|
StencilFrontOpZFail = GalStencilOp.Keep,
|
||||||
StencilFrontOpZPass = GalStencilOp.Keep,
|
StencilFrontOpZPass = GalStencilOp.Keep,
|
||||||
StencilFrontMask = UInt32.MaxValue,
|
StencilFrontMask = UInt32.MaxValue,
|
||||||
|
|
||||||
BlendEnabled = false,
|
BlendEnabled = false,
|
||||||
BlendSeparateAlpha = false,
|
BlendSeparateAlpha = false,
|
||||||
|
|
||||||
BlendEquationRgb = 0,
|
BlendEquationRgb = 0,
|
||||||
BlendFuncSrcRgb = GalBlendFactor.One,
|
BlendFuncSrcRgb = GalBlendFactor.One,
|
||||||
BlendFuncDstRgb = GalBlendFactor.Zero,
|
BlendFuncDstRgb = GalBlendFactor.Zero,
|
||||||
BlendEquationAlpha = 0,
|
BlendEquationAlpha = 0,
|
||||||
BlendFuncSrcAlpha = GalBlendFactor.One,
|
BlendFuncSrcAlpha = GalBlendFactor.One,
|
||||||
BlendFuncDstAlpha = GalBlendFactor.Zero,
|
BlendFuncDstAlpha = GalBlendFactor.Zero,
|
||||||
|
|
||||||
ColorMask = ColorMaskRgba.Default,
|
ColorMask = ColorMaskRgba.Default,
|
||||||
|
|
||||||
PrimitiveRestartEnabled = false,
|
PrimitiveRestartEnabled = false,
|
||||||
PrimitiveRestartIndex = 0
|
PrimitiveRestartIndex = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++)
|
for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++)
|
||||||
|
@ -195,6 +197,12 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (New.DepthRangeNear != Old.DepthRangeNear ||
|
||||||
|
New.DepthRangeFar != Old.DepthRangeFar)
|
||||||
|
{
|
||||||
|
GL.DepthRange(New.DepthRangeNear, New.DepthRangeFar);
|
||||||
|
}
|
||||||
|
|
||||||
if (New.StencilTestEnabled != Old.StencilTestEnabled)
|
if (New.StencilTestEnabled != Old.StencilTestEnabled)
|
||||||
{
|
{
|
||||||
Enable(EnableCap.StencilTest, New.StencilTestEnabled);
|
Enable(EnableCap.StencilTest, New.StencilTestEnabled);
|
||||||
|
|
|
@ -371,6 +371,9 @@ namespace Ryujinx.Graphics
|
||||||
{
|
{
|
||||||
State.DepthFunc = (GalComparisonOp)ReadRegister(NvGpuEngine3dReg.DepthTestFunction);
|
State.DepthFunc = (GalComparisonOp)ReadRegister(NvGpuEngine3dReg.DepthTestFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
State.DepthRangeNear = ReadRegisterFloat(NvGpuEngine3dReg.DepthRangeNNear);
|
||||||
|
State.DepthRangeFar = ReadRegisterFloat(NvGpuEngine3dReg.DepthRangeNFar);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetStencil(GalPipelineState State)
|
private void SetStencil(GalPipelineState State)
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace Ryujinx.Graphics
|
||||||
ViewportNTranslateZ = 0x285,
|
ViewportNTranslateZ = 0x285,
|
||||||
ViewportNHoriz = 0x300,
|
ViewportNHoriz = 0x300,
|
||||||
ViewportNVert = 0x301,
|
ViewportNVert = 0x301,
|
||||||
|
DepthRangeNNear = 0x302,
|
||||||
|
DepthRangeNFar = 0x303,
|
||||||
VertexArrayFirst = 0x35d,
|
VertexArrayFirst = 0x35d,
|
||||||
VertexArrayCount = 0x35e,
|
VertexArrayCount = 0x35e,
|
||||||
ClearNColor = 0x360,
|
ClearNColor = 0x360,
|
||||||
|
|
Loading…
Reference in a new issue