Depth Bias
This commit is contained in:
parent
e97c9bc959
commit
9a6759d1e5
3 changed files with 27 additions and 1 deletions
|
@ -51,6 +51,10 @@ namespace Ryujinx.Graphics.Metal
|
|||
public MTLCompareFunction DepthCompareFunction = MTLCompareFunction.Always;
|
||||
public bool DepthWriteEnabled = false;
|
||||
|
||||
public float DepthBias;
|
||||
public float SlopeScale;
|
||||
public float Clamp;
|
||||
|
||||
public MTLStencilDescriptor BackFaceStencil = new();
|
||||
public MTLStencilDescriptor FrontFaceStencil = new();
|
||||
public int BackRefValue = 0;
|
||||
|
|
|
@ -79,6 +79,7 @@ namespace Ryujinx.Graphics.Metal
|
|||
// Set all the inline state, since it might have changed
|
||||
var renderCommandEncoder = _pipeline.GetOrCreateRenderEncoder();
|
||||
SetDepthClamp(renderCommandEncoder);
|
||||
SetDepthBias(renderCommandEncoder);
|
||||
SetScissors(renderCommandEncoder);
|
||||
SetViewports(renderCommandEncoder);
|
||||
SetVertexBuffers(renderCommandEncoder, _currentState.VertexBuffers);
|
||||
|
@ -165,6 +166,7 @@ namespace Ryujinx.Graphics.Metal
|
|||
|
||||
// Rebind all the state
|
||||
SetDepthClamp(renderCommandEncoder);
|
||||
SetDepthBias(renderCommandEncoder);
|
||||
SetCullMode(renderCommandEncoder);
|
||||
SetFrontFace(renderCommandEncoder);
|
||||
SetStencilRefValue(renderCommandEncoder);
|
||||
|
@ -561,6 +563,21 @@ namespace Ryujinx.Graphics.Metal
|
|||
}
|
||||
}
|
||||
|
||||
// Inlineable
|
||||
public void UpdateDepthBias(float depthBias, float slopeScale, float clamp)
|
||||
{
|
||||
_currentState.DepthBias = depthBias;
|
||||
_currentState.SlopeScale = slopeScale;
|
||||
_currentState.Clamp = clamp;
|
||||
|
||||
// Inline update
|
||||
if (_pipeline.CurrentEncoderType == EncoderType.Render && _pipeline.CurrentEncoder != null)
|
||||
{
|
||||
var renderCommandEncoder = new MTLRenderCommandEncoder(_pipeline.CurrentEncoder.Value);
|
||||
SetDepthBias(renderCommandEncoder);
|
||||
}
|
||||
}
|
||||
|
||||
// Inlineable
|
||||
public void UpdateScissors(ReadOnlySpan<Rectangle<int>> regions)
|
||||
{
|
||||
|
@ -839,6 +856,11 @@ namespace Ryujinx.Graphics.Metal
|
|||
renderCommandEncoder.SetDepthClipMode(_currentState.DepthClipMode);
|
||||
}
|
||||
|
||||
private readonly void SetDepthBias(MTLRenderCommandEncoder renderCommandEncoder)
|
||||
{
|
||||
renderCommandEncoder.SetDepthBias(_currentState.DepthBias, _currentState.SlopeScale, _currentState.Clamp);
|
||||
}
|
||||
|
||||
private unsafe void SetScissors(MTLRenderCommandEncoder renderCommandEncoder)
|
||||
{
|
||||
if (_currentState.Scissors.Length > 0)
|
||||
|
|
|
@ -388,7 +388,7 @@ namespace Ryujinx.Graphics.Metal
|
|||
|
||||
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||
_encoderStateManager.UpdateDepthBias(units, factor, clamp);
|
||||
}
|
||||
|
||||
public void SetDepthClamp(bool clamp)
|
||||
|
|
Loading…
Reference in a new issue