mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-05 22:41:18 +12:00
use depth mask when writing to depth
This commit is contained in:
parent
21e7466670
commit
2a218d418f
5 changed files with 17 additions and 8 deletions
|
@ -678,6 +678,13 @@ uint64 LatteSHRC_CalcPSAuxHash(LatteDecompilerShader* pixelShader, uint32* conte
|
||||||
auxHash = std::rotl<uint64>(auxHash, 7);
|
auxHash = std::rotl<uint64>(auxHash, 7);
|
||||||
auxHash += (uint64)dataType;
|
auxHash += (uint64)dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasDepthBuffer = LatteMRT::GetActiveDepthBufferMask(LatteGPUState.contextNew);
|
||||||
|
if (hasDepthBuffer)
|
||||||
|
{
|
||||||
|
auxHash = std::rotl<uint64>(auxHash, 5);
|
||||||
|
auxHash += 13u;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -187,8 +187,8 @@ struct LatteDecompilerShader
|
||||||
|
|
||||||
// analyzer stage (pixel outputs)
|
// analyzer stage (pixel outputs)
|
||||||
uint32 pixelColorOutputMask{ 0 }; // from LSB to MSB, 1 bit per written output. 1 if written (indices of color attachments)
|
uint32 pixelColorOutputMask{ 0 }; // from LSB to MSB, 1 bit per written output. 1 if written (indices of color attachments)
|
||||||
// analyzer stage (depth write)
|
// analyzer stage (depth output)
|
||||||
bool depthWritten{ false };
|
bool depthMask{ false };
|
||||||
// analyzer stage (geometry shader parameters/inputs)
|
// analyzer stage (geometry shader parameters/inputs)
|
||||||
uint32 ringParameterCount{ 0 };
|
uint32 ringParameterCount{ 0 };
|
||||||
uint32 ringParameterCountFromPrevStage{ 0 }; // used in geometry shader to hold VS ringParameterCount
|
uint32 ringParameterCountFromPrevStage{ 0 }; // used in geometry shader to hold VS ringParameterCount
|
||||||
|
|
|
@ -387,7 +387,7 @@ void LatteDecompiler_analyzeExport(LatteDecompilerShaderContext* shaderContext,
|
||||||
LatteDecompilerShader* shader = shaderContext->shader;
|
LatteDecompilerShader* shader = shaderContext->shader;
|
||||||
if( shader->shaderType == LatteConst::ShaderType::Pixel )
|
if( shader->shaderType == LatteConst::ShaderType::Pixel )
|
||||||
{
|
{
|
||||||
if( cfInstruction->exportType == 0 && cfInstruction->exportArrayBase < 8 )
|
if (cfInstruction->exportType == 0 && cfInstruction->exportArrayBase < 8)
|
||||||
{
|
{
|
||||||
// remember color outputs that are written
|
// remember color outputs that are written
|
||||||
for(uint32 i=0; i<(cfInstruction->exportBurstCount+1); i++)
|
for(uint32 i=0; i<(cfInstruction->exportBurstCount+1); i++)
|
||||||
|
@ -396,9 +396,10 @@ void LatteDecompiler_analyzeExport(LatteDecompilerShaderContext* shaderContext,
|
||||||
shader->pixelColorOutputMask |= (1<<colorOutputIndex);
|
shader->pixelColorOutputMask |= (1<<colorOutputIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( cfInstruction->exportType == 0 && cfInstruction->exportArrayBase == 61 )
|
else if (cfInstruction->exportType == 0 && cfInstruction->exportArrayBase == 61)
|
||||||
{
|
{
|
||||||
shader->depthWritten = true;
|
if (LatteMRT::GetActiveDepthBufferMask(*shaderContext->contextRegistersNew))
|
||||||
|
shader->depthMask = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
debugBreakpoint();
|
debugBreakpoint();
|
||||||
|
|
|
@ -3316,6 +3316,9 @@ static void _emitExportCode(LatteDecompilerShaderContext* shaderContext, LatteDe
|
||||||
cemu_assert_unimplemented(); // ukn
|
cemu_assert_unimplemented(); // ukn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!shaderContext->shader->depthMask)
|
||||||
|
return;
|
||||||
|
|
||||||
src->add("out.passDepth = ");
|
src->add("out.passDepth = ");
|
||||||
_emitExportGPRReadCode(shaderContext, cfInstruction, LATTE_DECOMPILER_DTYPE_FLOAT, 0);
|
_emitExportGPRReadCode(shaderContext, cfInstruction, LATTE_DECOMPILER_DTYPE_FLOAT, 0);
|
||||||
src->add(".x");
|
src->add(".x");
|
||||||
|
|
|
@ -298,10 +298,8 @@ namespace LatteDecompiler
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate depth output for pixel shader
|
// generate depth output for pixel shader
|
||||||
if (decompilerContext->shader->depthWritten)
|
if (decompilerContext->shader->depthMask)
|
||||||
{
|
|
||||||
src->add("float passDepth [[depth(any)]];" _CRLF);
|
src->add("float passDepth [[depth(any)]];" _CRLF);
|
||||||
}
|
|
||||||
|
|
||||||
src->add("};" _CRLF _CRLF);
|
src->add("};" _CRLF _CRLF);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue