check if verticesPerInstance uniform is used

This commit is contained in:
Samuliak 2024-11-11 17:21:16 +01:00
parent 326d3442cd
commit 4b58ac1a1e
No known key found for this signature in database
2 changed files with 13 additions and 3 deletions

View File

@ -547,6 +547,12 @@ namespace LatteDecompiler
{ {
decompilerContext->hasUniformVarBlock = true; // uf_verticesPerInstance and uf_streamoutBufferBase* decompilerContext->hasUniformVarBlock = true; // uf_verticesPerInstance and uf_streamoutBufferBase*
} }
if (g_renderer->GetType() == RendererAPI::Metal)
{
// TODO: also check for rect primitive
if (decompilerContext->shaderType == LatteConst::ShaderType::Vertex && decompilerContext->options->usesGeometryShader)
decompilerContext->hasUniformVarBlock = true; // uf_verticesPerInstance
}
} }
void _initUniformBindingPoints(LatteDecompilerShaderContext* decompilerContext) void _initUniformBindingPoints(LatteDecompilerShaderContext* decompilerContext)

View File

@ -5,7 +5,7 @@
namespace LatteDecompiler namespace LatteDecompiler
{ {
static void _emitUniformVariables(LatteDecompilerShaderContext* decompilerContext) static void _emitUniformVariables(LatteDecompilerShaderContext* decompilerContext, bool isRectVertexShader)
{ {
auto src = decompilerContext->shaderSource; auto src = decompilerContext->shaderSource;
@ -85,7 +85,11 @@ namespace LatteDecompiler
uniformCurrentOffset += 8; uniformCurrentOffset += 8;
} }
// define verticesPerInstance + streamoutBufferBaseX // define verticesPerInstance + streamoutBufferBaseX
if (shader->shaderType == LatteConst::ShaderType::Vertex || shader->shaderType == LatteConst::ShaderType::Geometry) if ((shader->shaderType == LatteConst::ShaderType::Vertex &&
(decompilerContext->options->usesGeometryShader || isRectVertexShader)) ||
(decompilerContext->analyzer.useSSBOForStreamout &&
(shader->shaderType == LatteConst::ShaderType::Vertex && !decompilerContext->options->usesGeometryShader) ||
(shader->shaderType == LatteConst::ShaderType::Geometry)))
{ {
src->add("int verticesPerInstance;" _CRLF); src->add("int verticesPerInstance;" _CRLF);
uniformOffsets.offset_verticesPerInstance = uniformCurrentOffset; uniformOffsets.offset_verticesPerInstance = uniformCurrentOffset;
@ -392,7 +396,7 @@ namespace LatteDecompiler
if(dump_shaders_enabled) if(dump_shaders_enabled)
decompilerContext->shaderSource->add("// start of shader inputs/outputs, predetermined by Cemu. Do not touch" _CRLF); decompilerContext->shaderSource->add("// start of shader inputs/outputs, predetermined by Cemu. Do not touch" _CRLF);
// uniform variables // uniform variables
_emitUniformVariables(decompilerContext); _emitUniformVariables(decompilerContext, isRectVertexShader);
// uniform buffers // uniform buffers
_emitUniformBuffers(decompilerContext); _emitUniformBuffers(decompilerContext);
// inputs and outputs // inputs and outputs