From e7f8f0ee4cff283a2e4ee5308d29fee6c73023f0 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Wed, 11 Sep 2024 12:28:35 +0200 Subject: [PATCH] simplify uniform names --- .../LatteDecompilerEmitMSL.cpp | 18 ++---------------- .../LatteDecompilerEmitMSLHeader.hpp | 16 ++-------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSL.cpp index 3f022c61..58b2615b 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSL.cpp @@ -631,14 +631,7 @@ static void _emitUniformAccessCode(LatteDecompilerShaderContext* shaderContext, } cemu_assert_debug(remappedUniformEntry); _emitTypeConversionPrefixMSL(shaderContext, LATTE_DECOMPILER_DTYPE_SIGNED_INT, requiredType); - if(shaderContext->shader->shaderType == LatteConst::ShaderType::Vertex ) - src->addFmt("supportBuffer.remappedVS[{}]", remappedUniformEntry->mappedIndex); - else if(shaderContext->shader->shaderType == LatteConst::ShaderType::Pixel ) - src->addFmt("supportBuffer.remappedPS[{}]", remappedUniformEntry->mappedIndex); - else if(shaderContext->shader->shaderType == LatteConst::ShaderType::Geometry ) - src->addFmt("supportBuffer.remappedGS[{}]", remappedUniformEntry->mappedIndex); - else - debugBreakpoint(); + src->addFmt("supportBuffer.remapped[{}]", remappedUniformEntry->mappedIndex); _appendChannelAccess(src, aluInstruction->sourceOperand[operandIndex].chan); _emitTypeConversionSuffixMSL(shaderContext, LATTE_DECOMPILER_DTYPE_SIGNED_INT, requiredType); } @@ -646,14 +639,7 @@ static void _emitUniformAccessCode(LatteDecompilerShaderContext* shaderContext, { // uniform registers are accessed with unpredictable (dynamic) offset _emitTypeConversionPrefixMSL(shaderContext, LATTE_DECOMPILER_DTYPE_SIGNED_INT, requiredType); - if(shaderContext->shader->shaderType == LatteConst::ShaderType::Vertex ) - src->add("supportBuffer.uniformRegisterVS["); - else if (shaderContext->shader->shaderType == LatteConst::ShaderType::Pixel) - src->add("supportBuffer.uniformRegisterPS["); - else if(shaderContext->shader->shaderType == LatteConst::ShaderType::Geometry ) - src->add("supportBuffer.uniformRegisterGS["); - else - debugBreakpoint(); + src->add("supportBuffer.uniformRegister["); _emitUniformAccessIndexCode(shaderContext, aluInstruction, operandIndex); src->add("]"); diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLHeader.hpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLHeader.hpp index a7121f52..37a509c1 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLHeader.hpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSLHeader.hpp @@ -20,14 +20,7 @@ namespace LatteDecompiler { // uniform registers or buffers are accessed statically with predictable offsets // this allows us to remap the used entries into a more compact array - if (shaderType == LatteConst::ShaderType::Vertex) - src->addFmt("int4 remappedVS[{}];" _CRLF, (sint32)shader->list_remappedUniformEntries.size()); - else if (shaderType == LatteConst::ShaderType::Pixel) - src->addFmt("int4 remappedPS[{}];" _CRLF, (sint32)shader->list_remappedUniformEntries.size()); - else if (shaderType == LatteConst::ShaderType::Geometry) - src->addFmt("int4 remappedGS[{}];" _CRLF, (sint32)shader->list_remappedUniformEntries.size()); - else - debugBreakpoint(); + src->addFmt("int4 remapped[{}];" _CRLF, (sint32)shader->list_remappedUniformEntries.size()); uniformOffsets.offset_remapped = uniformCurrentOffset; uniformCurrentOffset += 16 * shader->list_remappedUniformEntries.size(); } @@ -35,12 +28,7 @@ namespace LatteDecompiler { uint32 cfileSize = decompilerContext->analyzer.uniformRegisterAccessTracker.DetermineSize(decompilerContext->shaderBaseHash, 256); // full or partial uniform register file has to be present - if (shaderType == LatteConst::ShaderType::Vertex) - src->addFmt("int4 uniformRegisterVS[{}];" _CRLF, cfileSize); - else if (shaderType == LatteConst::ShaderType::Pixel) - src->addFmt("int4 uniformRegisterPS[{}];" _CRLF, cfileSize); - else if (shaderType == LatteConst::ShaderType::Geometry) - src->addFmt("int4 uniformRegisterGS[{}];" _CRLF, cfileSize); + src->addFmt("int4 uniformRegister[{}];" _CRLF, cfileSize); uniformOffsets.offset_uniformRegister = uniformCurrentOffset; uniformOffsets.count_uniformRegister = cfileSize; uniformCurrentOffset += 16 * cfileSize;