From 0c05c3e87f4c0f22bcbf6fd0cedf0e776e63ef72 Mon Sep 17 00:00:00 2001 From: SSimco <37044560+SSimco@users.noreply.github.com> Date: Fri, 27 Sep 2024 01:41:35 +0300 Subject: [PATCH] Fix bc5 decoding --- src/Cafe/HW/Latte/Core/LatteTextureLoader.h | 7 ++++--- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteTextureLoader.h b/src/Cafe/HW/Latte/Core/LatteTextureLoader.h index 31b049044..8e3ad0985 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureLoader.h +++ b/src/Cafe/HW/Latte/Core/LatteTextureLoader.h @@ -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]) { @@ -2171,8 +2172,8 @@ class TextureDecoder_BC4 : public TextureDecoder, public SingletonClass +template +class TextureDecoder_BC5_To_R8G8 : public TextureDecoder, public SingletonClass> { public: @@ -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++) { diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index c61c1d04b..521d583c1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -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::getInstance(); } break; case Latte::E_GX2SURFFMT::BC5_SNORM: @@ -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::getInstance(); } break; case Latte::E_GX2SURFFMT::R24_X8_UNORM: