1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-10-01 12:30:00 +02:00

Fix depth clamp enable bit, unit scale for polygon offset. (#1178)

Verified with deko3d and opengl driver code.
This commit is contained in:
riperiperi 2020-04-30 02:47:24 +01:00 committed by GitHub
parent ec620e2de0
commit c2ac45adc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 11 deletions

View file

@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.GAL
void SetBlendState(int index, BlendDescriptor blend); void SetBlendState(int index, BlendDescriptor blend);
void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp); void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
void SetDepthClamp(bool clampNear, bool clampFar); void SetDepthClamp(bool clamp);
void SetDepthMode(DepthMode mode); void SetDepthMode(DepthMode mode);
void SetDepthTest(DepthTestDescriptor depthTest); void SetDepthTest(DepthTestDescriptor depthTest);

View file

@ -394,8 +394,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
private void UpdateDepthClampState(GpuState state) private void UpdateDepthClampState(GpuState state)
{ {
ViewVolumeClipControl clip = state.Get<ViewVolumeClipControl>(MethodOffset.ViewVolumeClipControl); ViewVolumeClipControl clip = state.Get<ViewVolumeClipControl>(MethodOffset.ViewVolumeClipControl);
_context.Renderer.Pipeline.SetDepthClamp((clip & ViewVolumeClipControl.DepthClampNear) != 0, _context.Renderer.Pipeline.SetDepthClamp((clip & ViewVolumeClipControl.DepthClampDisabled) == 0);
(clip & ViewVolumeClipControl.DepthClampFar) != 0);
} }
/// <summary> /// <summary>

View file

@ -6,7 +6,6 @@ namespace Ryujinx.Graphics.Gpu.State
enum ViewVolumeClipControl enum ViewVolumeClipControl
{ {
ForceDepthRangeZeroToOne = 1 << 0, ForceDepthRangeZeroToOne = 1 << 0,
DepthClampNear = 1 << 3, DepthClampDisabled = 1 << 11,
DepthClampFar = 1 << 4,
} }
} }

View file

@ -549,17 +549,13 @@ namespace Ryujinx.Graphics.OpenGL
return; return;
} }
GL.PolygonOffset(factor, units); GL.PolygonOffset(factor, units / 2f);
// TODO: Enable when GL_EXT_polygon_offset_clamp is supported. // TODO: Enable when GL_EXT_polygon_offset_clamp is supported.
// GL.PolygonOffsetClamp(factor, units, clamp); // GL.PolygonOffsetClamp(factor, units, clamp);
} }
public void SetDepthClamp(bool clampNear, bool clampFar) public void SetDepthClamp(bool clamp)
{ {
// TODO: Use GL_AMD_depth_clamp_separate or similar if available?
// Currently enables clamping if either is set.
bool clamp = clampNear || clampFar;
if (!clamp) if (!clamp)
{ {
GL.Disable(EnableCap.DepthClamp); GL.Disable(EnableCap.DepthClamp);