mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-28 03:23:05 +00:00
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 MTLCompareFunction DepthCompareFunction = MTLCompareFunction.Always;
|
||||||
public bool DepthWriteEnabled = false;
|
public bool DepthWriteEnabled = false;
|
||||||
|
|
||||||
|
public float DepthBias;
|
||||||
|
public float SlopeScale;
|
||||||
|
public float Clamp;
|
||||||
|
|
||||||
public MTLStencilDescriptor BackFaceStencil = new();
|
public MTLStencilDescriptor BackFaceStencil = new();
|
||||||
public MTLStencilDescriptor FrontFaceStencil = new();
|
public MTLStencilDescriptor FrontFaceStencil = new();
|
||||||
public int BackRefValue = 0;
|
public int BackRefValue = 0;
|
||||||
|
|
|
@ -79,6 +79,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
// Set all the inline state, since it might have changed
|
// Set all the inline state, since it might have changed
|
||||||
var renderCommandEncoder = _pipeline.GetOrCreateRenderEncoder();
|
var renderCommandEncoder = _pipeline.GetOrCreateRenderEncoder();
|
||||||
SetDepthClamp(renderCommandEncoder);
|
SetDepthClamp(renderCommandEncoder);
|
||||||
|
SetDepthBias(renderCommandEncoder);
|
||||||
SetScissors(renderCommandEncoder);
|
SetScissors(renderCommandEncoder);
|
||||||
SetViewports(renderCommandEncoder);
|
SetViewports(renderCommandEncoder);
|
||||||
SetVertexBuffers(renderCommandEncoder, _currentState.VertexBuffers);
|
SetVertexBuffers(renderCommandEncoder, _currentState.VertexBuffers);
|
||||||
|
@ -165,6 +166,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
// Rebind all the state
|
// Rebind all the state
|
||||||
SetDepthClamp(renderCommandEncoder);
|
SetDepthClamp(renderCommandEncoder);
|
||||||
|
SetDepthBias(renderCommandEncoder);
|
||||||
SetCullMode(renderCommandEncoder);
|
SetCullMode(renderCommandEncoder);
|
||||||
SetFrontFace(renderCommandEncoder);
|
SetFrontFace(renderCommandEncoder);
|
||||||
SetStencilRefValue(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
|
// Inlineable
|
||||||
public void UpdateScissors(ReadOnlySpan<Rectangle<int>> regions)
|
public void UpdateScissors(ReadOnlySpan<Rectangle<int>> regions)
|
||||||
{
|
{
|
||||||
|
@ -839,6 +856,11 @@ namespace Ryujinx.Graphics.Metal
|
||||||
renderCommandEncoder.SetDepthClipMode(_currentState.DepthClipMode);
|
renderCommandEncoder.SetDepthClipMode(_currentState.DepthClipMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly void SetDepthBias(MTLRenderCommandEncoder renderCommandEncoder)
|
||||||
|
{
|
||||||
|
renderCommandEncoder.SetDepthBias(_currentState.DepthBias, _currentState.SlopeScale, _currentState.Clamp);
|
||||||
|
}
|
||||||
|
|
||||||
private unsafe void SetScissors(MTLRenderCommandEncoder renderCommandEncoder)
|
private unsafe void SetScissors(MTLRenderCommandEncoder renderCommandEncoder)
|
||||||
{
|
{
|
||||||
if (_currentState.Scissors.Length > 0)
|
if (_currentState.Scissors.Length > 0)
|
||||||
|
|
|
@ -388,7 +388,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
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)
|
public void SetDepthClamp(bool clamp)
|
||||||
|
|
Loading…
Reference in a new issue