set stencil reference value

This commit is contained in:
Samuliak 2024-08-08 11:58:18 +02:00
parent a50ce997df
commit e0791c3bf4
3 changed files with 35 additions and 23 deletions

View file

@ -603,6 +603,19 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32
MTL::DepthStencilState* depthStencilState = m_depthStencilCache->GetDepthStencilState(LatteGPUState.contextNew);
renderCommandEncoder->setDepthStencilState(depthStencilState);
// Stencil reference
bool stencilEnable = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_ENABLE();
if (stencilEnable)
{
bool backStencilEnable = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_BACK_STENCIL_ENABLE();
uint32 stencilRefFront = LatteGPUState.contextNew.DB_STENCILREFMASK.get_STENCILREF_F();
uint32 stencilRefBack = LatteGPUState.contextNew.DB_STENCILREFMASK_BF.get_STENCILREF_B();
if (backStencilEnable)
renderCommandEncoder->setStencilReferenceValues(stencilRefFront, stencilRefBack);
else
renderCommandEncoder->setStencilReferenceValue(stencilRefFront);
}
// Primitive type
const LattePrimitiveMode primitiveMode = static_cast<LattePrimitiveMode>(LatteGPUState.contextRegister[mmVGT_PRIMITIVE_TYPE]);
auto mtlPrimitiveType = GetMtlPrimitiveType(primitiveMode);