diff options
| author | TellowKrinkle <tellowkrinkle@gmail.com> | 2022-06-11 02:51:24 -0500 |
|---|---|---|
| committer | TellowKrinkle <tellowkrinkle@gmail.com> | 2022-06-16 02:08:45 -0500 |
| commit | 23c1721fbd317a31046affcf362848bc191f4711 (patch) | |
| tree | 7e6f2698a7d0b4fab2793d0ba3b7c55a399d0433 /Source/Core/VideoCommon/ShaderCache.cpp | |
| parent | 70bf89fa59e3bd48633677374ca26124d36ff7e5 (diff) | |
VideoCommon: Reduce duplicates of non-palette-requiring texture decode shaders
Diffstat (limited to 'Source/Core/VideoCommon/ShaderCache.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/ShaderCache.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
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<TLUTFormat> palette_format) { - const auto key = std::make_pair(static_cast<u32>(format), static_cast<u32>(palette_format)); + const auto key = std::make_pair(static_cast<u32>(format), + static_cast<u32>(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<AbstractShader> 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<AbstractShader> shader = + g_renderer->CreateShaderFromSource(ShaderStage::Compute, shader_source, name); if (!shader) { m_texture_decoding_shaders.emplace(key, nullptr); |
