mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-29 12:34:17 +01:00
use RG8Unorm format if ABGR4Unorm is not available
This commit is contained in:
parent
810168be48
commit
8c30bc805c
@ -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>
|
class TextureDecoder_R4_G4_B4_A4_UNORM : public TextureDecoder, public SingletonClass<TextureDecoder_R4_G4_B4_A4_UNORM>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -152,10 +152,9 @@ void CheckForPixelFormatSupport(const MetalPixelFormatSupport& support)
|
|||||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::A1_B5_G5_R5_UNORM].textureDecoder = TextureDecoder_A1_B5_G5_R5_UNORM_vulkan_To_RGBA8::getInstance();
|
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::A1_B5_G5_R5_UNORM].textureDecoder = TextureDecoder_A1_B5_G5_R5_UNORM_vulkan_To_RGBA8::getInstance();
|
||||||
|
|
||||||
// ABGR4Unorm
|
// ABGR4Unorm
|
||||||
// TODO: use RG8Unorm
|
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_UNORM].pixelFormat = MTL::PixelFormatRG8Unorm;
|
||||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_UNORM].pixelFormat = MTL::PixelFormatRGBA8Unorm;
|
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_UNORM].bytesPerBlock = 2;
|
||||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_UNORM].bytesPerBlock = 4;
|
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_UNORM].textureDecoder = TextureDecoder_R4G4_UNORM_To_RG8::getInstance();
|
||||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_UNORM].textureDecoder = TextureDecoder_R4G4_UNORM_To_RGBA8::getInstance();
|
|
||||||
|
|
||||||
// ABGR4Unorm
|
// ABGR4Unorm
|
||||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_B4_A4_UNORM].pixelFormat = MTL::PixelFormatRGBA8Unorm;
|
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_B4_A4_UNORM].pixelFormat = MTL::PixelFormatRGBA8Unorm;
|
||||||
|
Loading…
Reference in New Issue
Block a user