fix incorrect ABGR4 texture decoder

This commit is contained in:
Samuliak 2025-01-20 13:47:59 +01:00
parent 709f24bf41
commit 29a4835278
No known key found for this signature in database
2 changed files with 1 additions and 45 deletions

View file

@ -768,50 +768,6 @@ public:
}
};
class TextureDecoder_R4_G4_B4_A4_UNORM_To_ABGR4 : public TextureDecoder, public SingletonClass<TextureDecoder_R4_G4_B4_A4_UNORM_To_ABGR4>
{
public:
sint32 getBytesPerTexel(LatteTextureLoaderCtx* textureLoader) override
{
return 2;
}
void decode(LatteTextureLoaderCtx* textureLoader, uint8* outputData) override
{
for (sint32 y = 0; y < textureLoader->height; y += textureLoader->stepY)
{
sint32 yc = y;
for (sint32 x = 0; x < textureLoader->width; x += textureLoader->stepX)
{
uint8* blockData = LatteTextureLoader_GetInput(textureLoader, x, y);
sint32 pixelOffset = (x + yc * textureLoader->width) * 2;
uint8 v0 = (*(uint8*)(blockData + 0));
uint8 v1 = (*(uint8*)(blockData + 1));
*(uint8*)(outputData + pixelOffset + 0) = v0; // todo: Verify
*(uint8*)(outputData + pixelOffset + 1) = v1; // todo: Verify
}
}
}
void decodePixelToRGBA(uint8* blockData, uint8* outputPixel, uint8 blockOffsetX, uint8 blockOffsetY) override
{
uint8 v0 = *(blockData + 0);
uint8 v1 = *(blockData + 1);
uint8 c0 = (v0 & 0xF);
uint8 c1 = (v0 >> 4) & 0xF;
uint8 c2 = (v1 & 0xF);
uint8 c3 = (v1 >> 4) & 0xF;
c0 = (c0 << 4) | c0;
c1 = (c1 << 4) | c1;
c2 = (c2 << 4) | c2;
c3 = (c3 << 4) | c3;
*(outputPixel + 0) = c0;
*(outputPixel + 1) = c1;
*(outputPixel + 2) = c2;
*(outputPixel + 3) = c3;
}
};
class TextureDecoder_R4G4B4A4_UNORM_To_RGBA8 : public TextureDecoder, public SingletonClass<TextureDecoder_R4G4B4A4_UNORM_To_RGBA8>
{
public:

View file

@ -121,7 +121,7 @@ void CheckForPixelFormatSupport(const MetalPixelFormatSupport& support)
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R5_G5_B5_A1_UNORM].textureDecoder = TextureDecoder_R5_G5_B5_A1_UNORM_swappedRB::getInstance();
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::A1_B5_G5_R5_UNORM].textureDecoder = TextureDecoder_A1_B5_G5_R5_UNORM::getInstance();
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R11_G11_B10_FLOAT].textureDecoder = TextureDecoder_R11_G11_B10_FLOAT::getInstance();
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_B4_A4_UNORM].textureDecoder = TextureDecoder_R4_G4_B4_A4_UNORM_To_ABGR4::getInstance();
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_B4_A4_UNORM].textureDecoder = TextureDecoder_R4_G4_B4_A4_UNORM::getInstance();
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R10_G10_B10_A2_UNORM].textureDecoder = TextureDecoder_R10_G10_B10_A2_UNORM::getInstance();
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R10_G10_B10_A2_SNORM].textureDecoder = TextureDecoder_R10_G10_B10_A2_SNORM_To_RGBA16::getInstance();
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R10_G10_B10_A2_SRGB].textureDecoder = TextureDecoder_R10_G10_B10_A2_UNORM::getInstance();