disable depth write if active FBO doesn't have a depth attachment

This commit is contained in:
Samuliak 2024-08-30 16:53:00 +02:00
parent cda4799b54
commit a9a4d7b4f8
2 changed files with 6 additions and 6 deletions

View File

@ -251,11 +251,11 @@ void SetFragmentState(T* desc, CachedFBOMtl* lastUsedFBO, CachedFBOMtl* activeFB
if (lastUsedFBO->depthBuffer.texture) if (lastUsedFBO->depthBuffer.texture)
{ {
auto texture = static_cast<LatteTextureViewMtl*>(lastUsedFBO->depthBuffer.texture); auto texture = static_cast<LatteTextureViewMtl*>(lastUsedFBO->depthBuffer.texture);
desc->setDepthAttachmentPixelFormat(texture->GetRGBAView()->pixelFormat()); desc->setDepthAttachmentPixelFormat(texture->GetRGBAView()->pixelFormat());
if (lastUsedFBO->depthBuffer.hasStencil) if (lastUsedFBO->depthBuffer.hasStencil)
{ {
desc->setStencilAttachmentPixelFormat(texture->GetRGBAView()->pixelFormat()); desc->setStencilAttachmentPixelFormat(texture->GetRGBAView()->pixelFormat());
} }
} }
} }

View File

@ -950,7 +950,7 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32
// Disable depth write when there is no depth attachment // Disable depth write when there is no depth attachment
auto& depthControl = LatteGPUState.contextNew.DB_DEPTH_CONTROL; auto& depthControl = LatteGPUState.contextNew.DB_DEPTH_CONTROL;
bool depthWriteEnable = depthControl.get_Z_WRITE_ENABLE(); bool depthWriteEnable = depthControl.get_Z_WRITE_ENABLE();
if (!m_state.m_lastUsedFBO->depthBuffer.texture) if (!m_state.m_activeFBO->depthBuffer.texture)
depthControl.set_Z_WRITE_ENABLE(false); depthControl.set_Z_WRITE_ENABLE(false);
MTL::DepthStencilState* depthStencilState = m_depthStencilCache->GetDepthStencilState(LatteGPUState.contextNew); MTL::DepthStencilState* depthStencilState = m_depthStencilCache->GetDepthStencilState(LatteGPUState.contextNew);