set stencil reference value

This commit is contained in:
Samuliak 2024-07-08 15:01:52 +02:00
parent 1a3e8357fa
commit db08f73530
2 changed files with 6 additions and 2 deletions

View file

@ -37,7 +37,6 @@ public:
MTL::StencilDescriptor* stencilDesc = nullptr;
if (stencilEnable) {
const u8 stencilFunc = Helpers::getBits<4, 3>(hash.stencilConfig);
const s8 reference = s8(Helpers::getBits<16, 8>(hash.stencilConfig)); // Signed reference value
const u8 stencilRefMask = Helpers::getBits<24, 8>(hash.stencilConfig);
const u32 stencilBufferMask = hash.depthStencilWrite ? Helpers::getBits<8, 8>(hash.stencilConfig) : 0;
@ -53,7 +52,6 @@ public:
stencilDesc->setStencilCompareFunction(toMTLCompareFunc(stencilFunc));
stencilDesc->setReadMask(stencilRefMask);
stencilDesc->setWriteMask(stencilBufferMask);
// TODO: Set reference value
desc->setFrontFaceStencil(stencilDesc);
desc->setBackFaceStencil(stencilDesc);

View file

@ -574,6 +574,12 @@ void RendererMTL::drawVertices(PICA::PrimType primType, std::span<const PICA::Ve
renderCommandEncoder->setBlendColor(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
}
// Stencil reference
if (stencilEnable) {
const s8 reference = s8(Helpers::getBits<16, 8>(depthStencilHash.stencilConfig)); // Signed reference value
renderCommandEncoder->setStencilReferenceValue(reference);
}
// Bind resources
setupTextureEnvState(renderCommandEncoder);
bindTexturesToSlots(renderCommandEncoder);