diff options
| author | Stenzek <stenzek@gmail.com> | 2019-07-14 15:24:12 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2019-07-14 19:16:27 +1000 |
| commit | 946571b7595b6b24e02cf8622f2bd5935b5aa360 (patch) | |
| tree | eef0c948d64df352f6b37e0625e4dbd917d8f7e4 /Source/Core/VideoCommon/ShaderCache.cpp | |
| parent | 77f406c8a8dc638bd6404dd71b7537eed9498b69 (diff) | |
TextureCache: Support reinterpreting formats for VRAM textures
Diffstat (limited to 'Source/Core/VideoCommon/ShaderCache.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/ShaderCache.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 1f578f6bd8..3d4f286b68 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -1255,6 +1255,44 @@ const AbstractPipeline* ShaderCache::GetPaletteConversionPipeline(TLUTFormat for return m_palette_conversion_pipelines[static_cast<size_t>(format)].get(); } +const AbstractPipeline* ShaderCache::GetTextureReinterpretPipeline(TextureFormat from_format, + TextureFormat to_format) +{ + const auto key = std::make_pair(from_format, to_format); + auto iter = m_texture_reinterpret_pipelines.find(key); + if (iter != m_texture_reinterpret_pipelines.end()) + return iter->second.get(); + + std::string shader_source = + FramebufferShaderGen::GenerateTextureReinterpretShader(from_format, to_format); + if (shader_source.empty()) + { + m_texture_reinterpret_pipelines.emplace(key, nullptr); + return nullptr; + } + + std::unique_ptr<AbstractShader> shader = + g_renderer->CreateShaderFromSource(ShaderStage::Pixel, shader_source); + if (!shader) + { + m_texture_reinterpret_pipelines.emplace(key, nullptr); + return nullptr; + } + + AbstractPipelineConfig config; + config.vertex_format = nullptr; + config.vertex_shader = m_screen_quad_vertex_shader.get(); + config.geometry_shader = nullptr; + config.pixel_shader = shader.get(); + config.rasterization_state = RenderState::GetNoCullRasterizationState(PrimitiveType::Triangles); + config.depth_state = RenderState::GetNoDepthTestingDepthState(); + config.blending_state = RenderState::GetNoBlendingBlendState(); + config.framebuffer_state = RenderState::GetRGBA8FramebufferState(); + config.usage = AbstractPipelineUsage::Utility; + auto iiter = m_texture_reinterpret_pipelines.emplace(key, g_renderer->CreatePipeline(config)); + return iiter.first->second.get(); +} + const AbstractShader* ShaderCache::GetTextureDecodingShader(TextureFormat format, TLUTFormat palette_format) { @@ -1282,5 +1320,4 @@ const AbstractShader* ShaderCache::GetTextureDecodingShader(TextureFormat format auto iiter = m_texture_decoding_shaders.emplace(key, std::move(shader)); return iiter.first->second.get(); } - } // namespace VideoCommon |
