mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-11 09:18:30 +12:00
use RG8Unorm format if ABGR4Unorm is not available
This commit is contained in:
parent
810168be48
commit
8c30bc805c
2 changed files with 48 additions and 4 deletions
|
@ -720,6 +720,51 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class TextureDecoder_R4G4_UNORM_To_RG8 : public TextureDecoder, public SingletonClass<TextureDecoder_R4G4_UNORM_To_RGBA8>
|
||||
{
|
||||
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 red4 = (v0 >> 4) & 0xF;
|
||||
uint8 green4 = (v0 & 0xF);
|
||||
|
||||
red4 = (red4 << 4) | red4;
|
||||
green4 = (green4 << 4) | green4;
|
||||
|
||||
*(uint8*)(outputData + pixelOffset + 0) = red4;
|
||||
*(uint8*)(outputData + pixelOffset + 1) = green4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void decodePixelToRGBA(uint8* blockData, uint8* outputPixel, uint8 blockOffsetX, uint8 blockOffsetY) override
|
||||
{
|
||||
uint8 v0 = *(blockData + 0);
|
||||
uint8 red4 = (v0 >> 4) & 0xF;
|
||||
uint8 green4 = (v0 & 0xF);
|
||||
red4 = (red4 << 4) | red4;
|
||||
green4 = (green4 << 4) | green4;
|
||||
*(outputPixel + 0) = red4;
|
||||
*(outputPixel + 1) = green4;
|
||||
*(outputPixel + 2) = 0;
|
||||
*(outputPixel + 3) = 255;
|
||||
}
|
||||
};
|
||||
|
||||
class TextureDecoder_R4_G4_B4_A4_UNORM : public TextureDecoder, public SingletonClass<TextureDecoder_R4_G4_B4_A4_UNORM>
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue