From 9e944510933a2b9068e5db9fad9be3b7fe365d69 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Sun, 19 Jan 2025 10:15:20 +0100 Subject: [PATCH] check for texture and color tile mode --- .../LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp index cbb2b3ff..37e228d5 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp @@ -870,6 +870,10 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD if (physAddr == MPTR_NULL) continue; // invalid data + auto tileMode = texRegister.word0.get_TILE_MODE(); + if (Latte::TM_IsMacroTiled(tileMode)) + physAddr &= 0x700; + // Check for dimension auto dim = shader->textureUnitDim[textureIndex]; // TODO: 2D arrays could technically be supported as well @@ -896,7 +900,13 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD uint32* colorBufferRegBase = shaderContext->contextRegisters + (mmCB_COLOR0_BASE + j); uint32 regColorBufferBase = colorBufferRegBase[mmCB_COLOR0_BASE - mmCB_COLOR0_BASE] & 0xFFFFFF00; // the low 8 bits are ignored? How to Survive seems to rely on this + uint32 regColorInfo = colorBufferRegBase[mmCB_COLOR0_INFO - mmCB_COLOR0_BASE]; + MPTR colorBufferPhysMem = regColorBufferBase; + Latte::E_HWTILEMODE colorBufferTileMode = (Latte::E_HWTILEMODE)((regColorInfo >> 8) & 0xF); + if (Latte::TM_IsMacroTiled(colorBufferTileMode)) + colorBufferPhysMem &= ~0x700; + Latte::E_GX2SURFFMT colorBufferFormat = LatteMRT::GetColorBufferFormat(j, *shaderContext->contextRegistersNew); // TODO: check if mip matches as well?