mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-25 09:36:12 +00:00
Stencil Ref Value
This commit is contained in:
parent
0a6f11d247
commit
43460186a8
2 changed files with 24 additions and 0 deletions
|
@ -53,6 +53,8 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public MTLStencilDescriptor BackFaceStencil = new();
|
public MTLStencilDescriptor BackFaceStencil = new();
|
||||||
public MTLStencilDescriptor FrontFaceStencil = new();
|
public MTLStencilDescriptor FrontFaceStencil = new();
|
||||||
|
public int BackRefValue = 0;
|
||||||
|
public int FrontRefValue = 0;
|
||||||
public bool StencilTestEnabled = false;
|
public bool StencilTestEnabled = false;
|
||||||
|
|
||||||
public PrimitiveTopology Topology = PrimitiveTopology.Triangles;
|
public PrimitiveTopology Topology = PrimitiveTopology.Triangles;
|
||||||
|
|
|
@ -81,6 +81,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
SetBuffers(renderCommandEncoder, _currentState.StorageBuffers, true);
|
SetBuffers(renderCommandEncoder, _currentState.StorageBuffers, true);
|
||||||
SetCullMode(renderCommandEncoder);
|
SetCullMode(renderCommandEncoder);
|
||||||
SetFrontFace(renderCommandEncoder);
|
SetFrontFace(renderCommandEncoder);
|
||||||
|
SetStencilRefValue(renderCommandEncoder);
|
||||||
|
|
||||||
// Mark the other state as dirty
|
// Mark the other state as dirty
|
||||||
_currentState.Dirty.MarkAll();
|
_currentState.Dirty.MarkAll();
|
||||||
|
@ -161,6 +162,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
SetDepthClamp(renderCommandEncoder);
|
SetDepthClamp(renderCommandEncoder);
|
||||||
SetCullMode(renderCommandEncoder);
|
SetCullMode(renderCommandEncoder);
|
||||||
SetFrontFace(renderCommandEncoder);
|
SetFrontFace(renderCommandEncoder);
|
||||||
|
SetStencilRefValue(renderCommandEncoder);
|
||||||
SetViewports(renderCommandEncoder);
|
SetViewports(renderCommandEncoder);
|
||||||
SetScissors(renderCommandEncoder);
|
SetScissors(renderCommandEncoder);
|
||||||
SetVertexBuffers(renderCommandEncoder, _currentState.VertexBuffers);
|
SetVertexBuffers(renderCommandEncoder, _currentState.VertexBuffers);
|
||||||
|
@ -433,6 +435,8 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
_currentState.DepthStencilState = _depthStencilCache.GetOrCreate(descriptor);
|
_currentState.DepthStencilState = _depthStencilCache.GetOrCreate(descriptor);
|
||||||
|
|
||||||
|
UpdateStencilRefValue(stencilTest.FrontFuncRef, stencilTest.BackFuncRef);
|
||||||
|
|
||||||
// Mark dirty
|
// Mark dirty
|
||||||
_currentState.Dirty.DepthStencil = true;
|
_currentState.Dirty.DepthStencil = true;
|
||||||
|
|
||||||
|
@ -635,6 +639,19 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateStencilRefValue(int frontRef, int backRef)
|
||||||
|
{
|
||||||
|
_currentState.FrontRefValue = frontRef;
|
||||||
|
_currentState.BackRefValue = backRef;
|
||||||
|
|
||||||
|
// Inline update
|
||||||
|
if (_pipeline.CurrentEncoderType == EncoderType.Render && _pipeline.CurrentEncoder != null)
|
||||||
|
{
|
||||||
|
var renderCommandEncoder = new MTLRenderCommandEncoder(_pipeline.CurrentEncoder.Value);
|
||||||
|
SetStencilRefValue(renderCommandEncoder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Inlineable
|
// Inlineable
|
||||||
public readonly void UpdateTextureAndSampler(ShaderStage stage, ulong binding, MTLTexture texture, MTLSamplerState sampler)
|
public readonly void UpdateTextureAndSampler(ShaderStage stage, ulong binding, MTLTexture texture, MTLSamplerState sampler)
|
||||||
{
|
{
|
||||||
|
@ -786,6 +803,11 @@ namespace Ryujinx.Graphics.Metal
|
||||||
renderCommandEncoder.SetFrontFacingWinding(_currentState.Winding);
|
renderCommandEncoder.SetFrontFacingWinding(_currentState.Winding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly void SetStencilRefValue(MTLRenderCommandEncoder renderCommandEncoder)
|
||||||
|
{
|
||||||
|
renderCommandEncoder.SetStencilReferenceValues((uint)_currentState.FrontRefValue, (uint)_currentState.BackRefValue);
|
||||||
|
}
|
||||||
|
|
||||||
private static void SetTextureAndSampler(MTLRenderCommandEncoder renderCommandEncoder, ShaderStage stage, MTLTexture[] textures, MTLSamplerState[] samplers)
|
private static void SetTextureAndSampler(MTLRenderCommandEncoder renderCommandEncoder, ShaderStage stage, MTLTexture[] textures, MTLSamplerState[] samplers)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < textures.Length; i++)
|
for (int i = 0; i < textures.Length; i++)
|
||||||
|
|
Loading…
Reference in a new issue