Skip to content

Commit

Permalink
Fix bc5 decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
SSimco committed Sep 26, 2024
1 parent a08958f commit 0c05c3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Cafe/HW/Latte/Core/LatteTextureLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void decodeBC3Block_UNORM(uint8* inputData, float* imageRGBA);
void decodeBC4Block_UNORM(uint8* blockStorage, float* rOutput);
void decodeBC5Block_UNORM(uint8* blockStorage, float* rgOutput);
void decodeBC5Block_SNORM(uint8* blockStorage, float* rgOutput);
using decodingFn = void (uint8 *, float *);

inline void BC1_GetPixel(uint8* inputData, sint32 x, sint32 y, uint8 rgba[4])
{
Expand Down Expand Up @@ -2171,8 +2172,8 @@ class TextureDecoder_BC4 : public TextureDecoder, public SingletonClass<TextureD
*(outputPixel + 3) = 255;
}
};

class TextureDecoder_BC5_To_R8G8 : public TextureDecoder, public SingletonClass<TextureDecoder_BC5_To_R8G8>
template<decodingFn fn>
class TextureDecoder_BC5_To_R8G8 : public TextureDecoder, public SingletonClass<TextureDecoder_BC5_To_R8G8<fn>>
{
public:

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

for (sint32 py = 0; py < blockSizeY; py++)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2579,7 +2579,7 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
else
{
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8_UNORM;
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8::getInstance();
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8<decodeBC5Block_UNORM>::getInstance();
}
break;
case Latte::E_GX2SURFFMT::BC5_SNORM:
Expand All @@ -2591,7 +2591,7 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
else
{
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8_SNORM;
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8::getInstance();
formatInfoOut->decoder = TextureDecoder_BC5_To_R8G8<decodeBC5Block_SNORM>::getInstance();
}
break;
case Latte::E_GX2SURFFMT::R24_X8_UNORM:
Expand Down

0 comments on commit 0c05c3e

Please sign in to comment.