Skip to content

Commit 0c05c3e

Browse files
committed
Fix bc5 decoding
1 parent a08958f commit 0c05c3e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Cafe/HW/Latte/Core/LatteTextureLoader.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ void decodeBC3Block_UNORM(uint8* inputData, float* imageRGBA);
4646
void decodeBC4Block_UNORM(uint8* blockStorage, float* rOutput);
4747
void decodeBC5Block_UNORM(uint8* blockStorage, float* rgOutput);
4848
void decodeBC5Block_SNORM(uint8* blockStorage, float* rgOutput);
49+
using decodingFn = void (uint8 *, float *);
4950

5051
inline void BC1_GetPixel(uint8* inputData, sint32 x, sint32 y, uint8 rgba[4])
5152
{
@@ -2171,8 +2172,8 @@ class TextureDecoder_BC4 : public TextureDecoder, public SingletonClass<TextureD
21712172
*(outputPixel + 3) = 255;
21722173
}
21732174
};
2174-
2175-
class TextureDecoder_BC5_To_R8G8 : public TextureDecoder, public SingletonClass<TextureDecoder_BC5_To_R8G8>
2175+
template<decodingFn fn>
2176+
class TextureDecoder_BC5_To_R8G8 : public TextureDecoder, public SingletonClass<TextureDecoder_BC5_To_R8G8<fn>>
21762177
{
21772178
public:
21782179

@@ -2192,7 +2193,7 @@ class TextureDecoder_BC5_To_R8G8 : public TextureDecoder, public SingletonClass<
21922193
sint32 blockSizeY = (std::min)(4, textureLoader->height - y);
21932194
// decode 4x4 pixels at once
21942195
float rgBlock[4 * 4 * 2];
2195-
decodeBC5Block_UNORM(blockData, rgBlock);
2196+
fn(blockData, rgBlock);
21962197

21972198
for (sint32 py = 0; py < blockSizeY; py++)
21982199
{

src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,7 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
25792579
else
25802580
{
25812581
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8_UNORM;
2582-
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8::getInstance();
2582+
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8<decodeBC5Block_UNORM>::getInstance();
25832583
}
25842584
break;
25852585
case Latte::E_GX2SURFFMT::BC5_SNORM:
@@ -2591,7 +2591,7 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
25912591
else
25922592
{
25932593
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8_SNORM;
2594-
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8::getInstance();
2594+
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8<decodeBC5Block_SNORM>::getInstance();
25952595
}
25962596
break;
25972597
case Latte::E_GX2SURFFMT::R24_X8_UNORM:

0 commit comments

Comments
 (0)