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 --- Source/Core/VideoCommon/ShaderCache.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'Source/Core/VideoCommon/ShaderCache.cpp') diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 984793d9d8..38ac252832 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -1339,10 +1339,12 @@ const AbstractPipeline* ShaderCache::GetTextureReinterpretPipeline(TextureFormat return iiter.first->second.get(); } -const AbstractShader* ShaderCache::GetTextureDecodingShader(TextureFormat format, - TLUTFormat palette_format) +const AbstractShader* +ShaderCache::GetTextureDecodingShader(TextureFormat format, + std::optional palette_format) { - const auto key = std::make_pair(static_cast(format), static_cast(palette_format)); + const auto key = std::make_pair(static_cast(format), + static_cast(palette_format.value_or(TLUTFormat::IA8))); auto iter = m_texture_decoding_shaders.find(key); if (iter != m_texture_decoding_shaders.end()) return iter->second.get(); @@ -1355,9 +1357,13 @@ const AbstractShader* ShaderCache::GetTextureDecodingShader(TextureFormat format return nullptr; } - std::unique_ptr shader = g_renderer->CreateShaderFromSource( - ShaderStage::Compute, shader_source, - fmt::format("Texture decoding compute shader: {}, {}", format, palette_format)); + std::string name = + palette_format.has_value() ? + fmt::format("Texture decoding compute shader: {}", format) : + fmt::format("Texture decoding compute shader: {}, {}", format, *palette_format); + + std::unique_ptr shader = + g_renderer->CreateShaderFromSource(ShaderStage::Compute, shader_source, name); if (!shader) { m_texture_decoding_shaders.emplace(key, nullptr); -- cgit v1.2.3