fix: component indexing for framebuffer fetch

This commit is contained in:
Samuliak 2025-01-10 15:40:19 +01:00
parent 4479584eb6
commit ca3fe96104
No known key found for this signature in database

View file

@ -2261,24 +2261,14 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
}
// Do a framebuffer fetch if possible
// TODO: support comparison samplers
if (static_cast<MetalRenderer*>(g_renderer.get())->SupportsFramebufferFetch())
{
uint8 renderTargetIndex = shaderContext->shader->textureRenderTargetIndex[texInstruction->textureFetch.textureIndex];
if (renderTargetIndex != 255)
if (static_cast<MetalRenderer*>(g_renderer.get())->SupportsFramebufferFetch() && renderTargetIndex != 255)
{
src->addFmt("col{}.", renderTargetIndex);
// TODO: clean up
std::string components[] = {"x", "y", "z", "w"};
for (sint32 i = 0; i < numWrittenElements; i++)
// TODO: support comparison samplers
src->addFmt("col{}", renderTargetIndex);
}
else
{
src->addFmt("{}", components[i]);
}
src->add(");" _CRLF);
return;
}
}
if (emulateCompare)
{
cemu_assert_debug(!isGather);
@ -2537,6 +2527,8 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
// lod bias (TODO: wht?)
src->add(")");
}
// sample_compare doesn't return a float
if (!isCompare)
{