From 23c1721fbd317a31046affcf362848bc191f4711 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Sat, 11 Jun 2022 02:51:24 -0500 Subject: VideoCommon: Reduce duplicates of non-palette-requiring texture decode shaders --- .../Core/VideoCommon/TextureConversionShader.cpp | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'Source/Core/VideoCommon/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index 1b9183846f..19f2a384f0 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -950,6 +950,7 @@ uint GetTiledTexelOffset(uint2 block_size, uint2 coords) return buffer_pos; } +#if defined(HAS_PALETTE) uint4 GetPaletteColor(uint index) { // Fetch and swap BE to LE. @@ -994,6 +995,7 @@ float4 GetPaletteColorNormalized(uint index) uint4 color = GetPaletteColor(index); return float4(color) / 255.0; } +#endif // defined(HAS_PALETTE) )"; @@ -1385,7 +1387,7 @@ std::pair GetDispatchCount(const DecodingShaderInfo* info, u32 width, (height + (info->group_size_y - 1)) / info->group_size_y}; } -std::string GenerateDecodingShader(TextureFormat format, TLUTFormat palette_format, +std::string GenerateDecodingShader(TextureFormat format, std::optional palette_format, APIType api_type) { const DecodingShaderInfo* info = GetDecodingShaderInfo(format); @@ -1393,17 +1395,20 @@ std::string GenerateDecodingShader(TextureFormat format, TLUTFormat palette_form return ""; std::ostringstream ss; - switch (palette_format) + if (palette_format.has_value()) { - case TLUTFormat::IA8: - ss << "#define PALETTE_FORMAT_IA8 1\n"; - break; - case TLUTFormat::RGB565: - ss << "#define PALETTE_FORMAT_RGB565 1\n"; - break; - case TLUTFormat::RGB5A3: - ss << "#define PALETTE_FORMAT_RGB5A3 1\n"; - break; + switch (*palette_format) + { + case TLUTFormat::IA8: + ss << "#define PALETTE_FORMAT_IA8 1\n"; + break; + case TLUTFormat::RGB565: + ss << "#define PALETTE_FORMAT_RGB565 1\n"; + break; + case TLUTFormat::RGB5A3: + ss << "#define PALETTE_FORMAT_RGB5A3 1\n"; + break; + } } ss << decoding_shader_header; -- cgit v1.2.3