Skip to content

Commit

Permalink
filter framebuffer fetch more
Browse files Browse the repository at this point in the history
  • Loading branch information
SamoZ256 committed Jan 20, 2025
1 parent 29a4835 commit 7ad4d48
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD
sint32 index;
MPTR physAddr;
Latte::E_GX2SURFFMT format;
Latte::E_HWTILEMODE tileMode;
} colorBuffers[LATTE_NUM_COLOR_TARGET]{};

uint8 colorBufferMask = LatteMRT::GetActiveColorBufferMask(shader, *shaderContext->contextRegistersNew);
Expand All @@ -882,12 +883,10 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD

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(i, *shaderContext->contextRegistersNew);

colorBuffer = {i, colorBufferPhysMem, colorBufferFormat};
colorBuffer = {i, colorBufferPhysMem, colorBufferFormat, colorBufferTileMode};
colorBufferCount++;
}

Expand All @@ -902,8 +901,6 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD
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];
Expand All @@ -927,8 +924,7 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD
{
const auto& colorBuffer = colorBuffers[j];

// TODO: check if mip matches as well?
if (physAddr == colorBuffer.physAddr && format == colorBuffer.format)
if (physAddr == colorBuffer.physAddr && format == colorBuffer.format && tileMode == colorBuffer.tileMode)
{
shader->textureRenderTargetIndex[textureIndex] = colorBuffer.index;
break;
Expand Down

0 comments on commit 7ad4d48

Please sign in to comment.