mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-01 13:34:18 +01:00
implement ABGR4 texture decoders
This commit is contained in:
parent
ed5f72a1ca
commit
f9e71e9eb2
@ -632,6 +632,47 @@ 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:
|
||||
@ -723,6 +764,49 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class TextureDecoder_R4G4B4A4_UNORM_To_ABGR4 : public TextureDecoder, public SingletonClass<TextureDecoder_R4G4B4A4_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>
|
||||
{
|
||||
@ -2121,4 +2205,4 @@ public:
|
||||
*(outputPixel + 2) = 0;
|
||||
*(outputPixel + 3) = 255;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -108,7 +108,7 @@ void CheckForPixelFormatSupport(const MetalPixelFormatSupport& support)
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R16_G16_FLOAT].textureDecoder = TextureDecoder_R16_G16_FLOAT::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R8_G8_UNORM].textureDecoder = TextureDecoder_R8_G8::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R8_G8_SNORM].textureDecoder = TextureDecoder_R8_G8::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_UNORM].textureDecoder = TextureDecoder_R4_G4_UNORM_To_RGBA4::getInstance(); // TODO: to ABGR4
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_UNORM].textureDecoder = TextureDecoder_R4_G4_UNORM_To_ABGR4::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R32_FLOAT].textureDecoder = TextureDecoder_R32_FLOAT::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R32_UINT].textureDecoder = TextureDecoder_R32_UINT::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R16_FLOAT].textureDecoder = TextureDecoder_R16_FLOAT::getInstance();
|
||||
@ -122,7 +122,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::getInstance(); // TODO: ABGR4
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R4_G4_B4_A4_UNORM].textureDecoder = TextureDecoder_R4G4B4A4_UNORM_To_ABGR4::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();
|
||||
@ -136,12 +136,12 @@ void CheckForPixelFormatSupport(const MetalPixelFormatSupport& support)
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::BC4_SNORM].textureDecoder = TextureDecoder_BC4::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::BC5_UNORM].textureDecoder = TextureDecoder_BC5::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::BC5_SNORM].textureDecoder = TextureDecoder_BC5::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R24_X8_UNORM].textureDecoder = TextureDecoder_R24_X8::getInstance(); // TODO: correct?
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::X24_G8_UINT].textureDecoder = TextureDecoder_X24_G8_UINT::getInstance(); // todo: correct?
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::R24_X8_UNORM].textureDecoder = TextureDecoder_R24_X8::getInstance();
|
||||
MTL_COLOR_FORMAT_TABLE[Latte::E_GX2SURFFMT::X24_G8_UINT].textureDecoder = TextureDecoder_X24_G8_UINT::getInstance();
|
||||
|
||||
// Depth
|
||||
MTL_DEPTH_FORMAT_TABLE[Latte::E_GX2SURFFMT::D24_S8_UNORM].textureDecoder = TextureDecoder_D24_S8::getInstance();
|
||||
MTL_DEPTH_FORMAT_TABLE[Latte::E_GX2SURFFMT::D24_S8_FLOAT].textureDecoder = TextureDecoder_NullData64::getInstance();
|
||||
MTL_DEPTH_FORMAT_TABLE[Latte::E_GX2SURFFMT::D24_S8_FLOAT].textureDecoder = TextureDecoder_NullData64::getInstance(); // TODO: why?
|
||||
MTL_DEPTH_FORMAT_TABLE[Latte::E_GX2SURFFMT::D32_FLOAT].textureDecoder = TextureDecoder_R32_FLOAT::getInstance();
|
||||
MTL_DEPTH_FORMAT_TABLE[Latte::E_GX2SURFFMT::D16_UNORM].textureDecoder = TextureDecoder_R16_UNORM::getInstance();
|
||||
MTL_DEPTH_FORMAT_TABLE[Latte::E_GX2SURFFMT::D32_S8_FLOAT].textureDecoder = TextureDecoder_D32_S8_UINT_X24::getInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user