mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-29 20:44:18 +01:00
fix: writing to depth from a fragment shader
This commit is contained in:
parent
1bcdade83e
commit
a50ce997df
@ -182,6 +182,8 @@ struct LatteDecompilerShader
|
||||
|
||||
// analyzer stage (pixel outputs)
|
||||
uint32 pixelColorOutputMask{ 0 }; // from LSB to MSB, 1 bit per written output. 1 if written (indices of color attachments)
|
||||
// analyzer stage (depth write)
|
||||
bool depthWritten{ false };
|
||||
// analyzer stage (geometry shader parameters/inputs)
|
||||
uint32 ringParameterCount{ 0 };
|
||||
uint32 ringParameterCountFromPrevStage{ 0 }; // used in geometry shader to hold VS ringParameterCount
|
||||
|
@ -393,7 +393,7 @@ void LatteDecompiler_analyzeExport(LatteDecompilerShaderContext* shaderContext,
|
||||
}
|
||||
else if( cfInstruction->exportType == 0 && cfInstruction->exportArrayBase == 61 )
|
||||
{
|
||||
// writes pixel depth
|
||||
shader->depthWritten = true;
|
||||
}
|
||||
else
|
||||
debugBreakpoint();
|
||||
|
@ -2441,11 +2441,12 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
|
||||
src->add(")");
|
||||
}
|
||||
}
|
||||
else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ )
|
||||
{
|
||||
// TODO: correct?
|
||||
src->add(", level(0.0)");
|
||||
}
|
||||
// TODO: uncomment?
|
||||
//else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ )
|
||||
//{
|
||||
// // TODO: correct?
|
||||
// src->add(", level(0.0)");
|
||||
//}
|
||||
}
|
||||
// gradient parameters
|
||||
if (texOpcode == GPU7_TEX_INST_SAMPLE_G)
|
||||
@ -3215,7 +3216,7 @@ static void _emitExportCode(LatteDecompilerShaderContext* shaderContext, LatteDe
|
||||
cemu_assert_unimplemented(); // ukn
|
||||
}
|
||||
|
||||
src->add("out.depth = ");
|
||||
src->add("out.passDepth = ");
|
||||
_emitExportGPRReadCode(shaderContext, cfInstruction, LATTE_DECOMPILER_DTYPE_FLOAT, 0);
|
||||
src->add(".x");
|
||||
src->add(";" _CRLF);
|
||||
|
@ -272,9 +272,9 @@ namespace LatteDecompiler
|
||||
}
|
||||
|
||||
// generate depth output for pixel shader
|
||||
if (decompilerContext->shader->pixelDepthOutputMask)
|
||||
if (decompilerContext->shader->depthWritten)
|
||||
{
|
||||
src->add("float passDepth [[depth(any)]];" _CRLF);
|
||||
src->add("float passDepth [[depth]];" _CRLF);
|
||||
}
|
||||
|
||||
src->add("};" _CRLF _CRLF);
|
||||
|
Loading…
Reference in New Issue
Block a user