properly implement ABGR4 decoder

This commit is contained in:
Samuliak 2024-10-01 19:37:11 +02:00
parent 2fb4d83a5f
commit 6ba6157bae
2 changed files with 2 additions and 43 deletions

View File

@ -594,7 +594,7 @@ public:
}
};
class TextureDecoder_R4_G4_UNORM_To_RGBA4_vk : public TextureDecoder, public SingletonClass<TextureDecoder_R4_G4_UNORM_To_RGBA4_vk>
class TextureDecoder_R4_G4_UNORM_To_ABGR4 : public TextureDecoder, public SingletonClass<TextureDecoder_R4_G4_UNORM_To_ABGR4>
{
public:
sint32 getBytesPerTexel(LatteTextureLoaderCtx* textureLoader) override
@ -632,47 +632,6 @@ public:
}
};
class TextureDecoder_R4_G4_UNORM_To_ABGR4 : public TextureDecoder, public SingletonClass<TextureDecoder_R4_G4_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 v = (*(uint8*)(blockData + 0));
uint8 c0 = (v & 0xF);
uint8 c1 = (v >> 4) & 0xF;
v = (c0 << 4) | c1;
*(uint8*)(outputData + pixelOffset + 0) = v;
*(uint8*)(outputData + pixelOffset + 1) = 0;
}
}
}
void decodePixelToRGBA(uint8* blockData, uint8* outputPixel, uint8 blockOffsetX, uint8 blockOffsetY) override
{
uint8 v0 = *(blockData + 0);
uint8 c0 = (v0 & 0xF);
uint8 c1 = (v0 >> 4) & 0xF;
c0 = (c0 << 4) | c0;
c1 = (c1 << 4) | c1;
*(outputPixel + 0) = c0;
*(outputPixel + 1) = c1;
*(outputPixel + 2) = 0;
*(outputPixel + 3) = 255;
}
};
class TextureDecoder_R4G4_UNORM_To_RGBA8 : public TextureDecoder, public SingletonClass<TextureDecoder_R4G4_UNORM_To_RGBA8>
{
public:

View File

@ -2283,7 +2283,7 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
}
else {
formatInfoOut->vkImageFormat = VK_FORMAT_R4G4B4A4_UNORM_PACK16;
formatInfoOut->decoder = TextureDecoder_R4_G4_UNORM_To_RGBA4_vk::getInstance();
formatInfoOut->decoder = TextureDecoder_R4_G4_UNORM_To_ABGR4::getInstance();
}
}
else