mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-05 06:21:19 +12:00
fix: depth stencil state issues
This commit is contained in:
parent
d64e0c9b6f
commit
c6e8b5c933
3 changed files with 20 additions and 29 deletions
|
@ -450,14 +450,6 @@ bool LatteMRT::UpdateCurrentFBO()
|
||||||
uint8 colorBufferMask = GetActiveColorBufferMask(pixelShader, LatteGPUState.contextNew);
|
uint8 colorBufferMask = GetActiveColorBufferMask(pixelShader, LatteGPUState.contextNew);
|
||||||
bool depthBufferMask = GetActiveDepthBufferMask(LatteGPUState.contextNew);
|
bool depthBufferMask = GetActiveDepthBufferMask(LatteGPUState.contextNew);
|
||||||
|
|
||||||
// if depth test is not used then detach the depth buffer
|
|
||||||
bool depthEnable = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_Z_ENABLE();
|
|
||||||
bool stencilTestEnable = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_ENABLE();
|
|
||||||
bool backStencilEnable = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_BACK_STENCIL_ENABLE();
|
|
||||||
|
|
||||||
if (!depthEnable && !stencilTestEnable && !backStencilEnable)
|
|
||||||
depthBufferMask = false;
|
|
||||||
|
|
||||||
bool hasResizedTexture = false; // set to true if any of the color buffers or the depth buffer reference a resized texture (via graphic pack texture rules)
|
bool hasResizedTexture = false; // set to true if any of the color buffers or the depth buffer reference a resized texture (via graphic pack texture rules)
|
||||||
sLatteRenderTargetState.renderTargetIsResized = false;
|
sLatteRenderTargetState.renderTargetIsResized = false;
|
||||||
// real size
|
// real size
|
||||||
|
|
|
@ -3121,7 +3121,7 @@ static void _emitExportCode(LatteDecompilerShaderContext* shaderContext, LatteDe
|
||||||
src->add("float4 finalPos = ");
|
src->add("float4 finalPos = ");
|
||||||
_emitExportGPRReadCode(shaderContext, cfInstruction, LATTE_DECOMPILER_DTYPE_FLOAT, 0);
|
_emitExportGPRReadCode(shaderContext, cfInstruction, LATTE_DECOMPILER_DTYPE_FLOAT, 0);
|
||||||
src->add(";" _CRLF);
|
src->add(";" _CRLF);
|
||||||
src->add("finalPos.xy = finalPos.xy * supportBuffer.windowSpaceToClipSpaceTransform - float2(1.0,1.0);");
|
src->add("finalPos.xy = finalPos.xy * supportBuffer.windowSpaceToClipSpaceTransform - float2(1.0,1.0);" _CRLF);
|
||||||
src->add("SET_POSITION(finalPos);");
|
src->add("SET_POSITION(finalPos);");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -21,37 +21,36 @@ MTL::DepthStencilState* MetalDepthStencilCache::GetDepthStencilState(const Latte
|
||||||
return depthStencilState;
|
return depthStencilState;
|
||||||
|
|
||||||
// Depth stencil state
|
// Depth stencil state
|
||||||
bool depthEnable = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_Z_ENABLE();
|
bool depthEnable = lcr.DB_DEPTH_CONTROL.get_Z_ENABLE();
|
||||||
auto depthFunc = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_Z_FUNC();
|
auto depthFunc = lcr.DB_DEPTH_CONTROL.get_Z_FUNC();
|
||||||
bool depthWriteEnable = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_Z_WRITE_ENABLE();
|
bool depthWriteEnable = lcr.DB_DEPTH_CONTROL.get_Z_WRITE_ENABLE();
|
||||||
|
|
||||||
MTL::DepthStencilDescriptor* desc = MTL::DepthStencilDescriptor::alloc()->init();
|
MTL::DepthStencilDescriptor* desc = MTL::DepthStencilDescriptor::alloc()->init();
|
||||||
desc->setDepthWriteEnabled(depthWriteEnable);
|
|
||||||
|
|
||||||
if (depthEnable)
|
if (depthEnable)
|
||||||
{
|
{
|
||||||
|
desc->setDepthWriteEnabled(depthWriteEnable);
|
||||||
desc->setDepthCompareFunction(GetMtlCompareFunc(depthFunc));
|
desc->setDepthCompareFunction(GetMtlCompareFunc(depthFunc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stencil state
|
// Stencil state
|
||||||
bool stencilEnable = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_ENABLE();
|
bool stencilEnable = lcr.DB_DEPTH_CONTROL.get_STENCIL_ENABLE();
|
||||||
if (stencilEnable)
|
if (stencilEnable)
|
||||||
{
|
{
|
||||||
// get stencil control parameters
|
// get stencil control parameters
|
||||||
bool backStencilEnable = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_BACK_STENCIL_ENABLE();
|
bool backStencilEnable = lcr.DB_DEPTH_CONTROL.get_BACK_STENCIL_ENABLE();
|
||||||
auto frontStencilFunc = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_FUNC_F();
|
auto frontStencilFunc = lcr.DB_DEPTH_CONTROL.get_STENCIL_FUNC_F();
|
||||||
auto frontStencilZPass = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_ZPASS_F();
|
auto frontStencilZPass = lcr.DB_DEPTH_CONTROL.get_STENCIL_ZPASS_F();
|
||||||
auto frontStencilZFail = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_ZFAIL_F();
|
auto frontStencilZFail = lcr.DB_DEPTH_CONTROL.get_STENCIL_ZFAIL_F();
|
||||||
auto frontStencilFail = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_FAIL_F();
|
auto frontStencilFail = lcr.DB_DEPTH_CONTROL.get_STENCIL_FAIL_F();
|
||||||
auto backStencilFunc = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_FUNC_B();
|
auto backStencilFunc = lcr.DB_DEPTH_CONTROL.get_STENCIL_FUNC_B();
|
||||||
auto backStencilZPass = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_ZPASS_B();
|
auto backStencilZPass = lcr.DB_DEPTH_CONTROL.get_STENCIL_ZPASS_B();
|
||||||
auto backStencilZFail = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_ZFAIL_B();
|
auto backStencilZFail = lcr.DB_DEPTH_CONTROL.get_STENCIL_ZFAIL_B();
|
||||||
auto backStencilFail = LatteGPUState.contextNew.DB_DEPTH_CONTROL.get_STENCIL_FAIL_B();
|
auto backStencilFail = lcr.DB_DEPTH_CONTROL.get_STENCIL_FAIL_B();
|
||||||
// get stencil control parameters
|
// get stencil control parameters
|
||||||
uint32 stencilCompareMaskFront = LatteGPUState.contextNew.DB_STENCILREFMASK.get_STENCILMASK_F();
|
uint32 stencilCompareMaskFront = lcr.DB_STENCILREFMASK.get_STENCILMASK_F();
|
||||||
uint32 stencilWriteMaskFront = LatteGPUState.contextNew.DB_STENCILREFMASK.get_STENCILWRITEMASK_F();
|
uint32 stencilWriteMaskFront = lcr.DB_STENCILREFMASK.get_STENCILWRITEMASK_F();
|
||||||
uint32 stencilCompareMaskBack = LatteGPUState.contextNew.DB_STENCILREFMASK_BF.get_STENCILMASK_B();
|
uint32 stencilCompareMaskBack = lcr.DB_STENCILREFMASK_BF.get_STENCILMASK_B();
|
||||||
uint32 stencilWriteMaskBack = LatteGPUState.contextNew.DB_STENCILREFMASK_BF.get_STENCILWRITEMASK_B();
|
uint32 stencilWriteMaskBack = lcr.DB_STENCILREFMASK_BF.get_STENCILWRITEMASK_B();
|
||||||
|
|
||||||
MTL::StencilDescriptor* frontStencil = MTL::StencilDescriptor::alloc()->init();
|
MTL::StencilDescriptor* frontStencil = MTL::StencilDescriptor::alloc()->init();
|
||||||
frontStencil->setReadMask(stencilCompareMaskFront);
|
frontStencil->setReadMask(stencilCompareMaskFront);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue