diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index f370da7142..cf36f0663d 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -510,7 +510,8 @@ void TextureCache::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, glViewport(0, 0, destination_texture->GetConfig().width, destination_texture->GetConfig().height); - auto uid = GetTextureConverterShaderUid(dst_format, is_depth_copy, is_intensity, scale_by_half); + auto uid = TextureConversionShaderGen::GetShaderUid(dst_format, is_depth_copy, is_intensity, + scale_by_half); auto it = m_efb_copy_programs.emplace(uid, EFBCopyShader()); EFBCopyShader& shader = it.first->second; @@ -518,7 +519,7 @@ void TextureCache::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, if (created) { - ShaderCode code = GenerateTextureConverterShaderCode(APIType::OpenGL, uid.GetUidData()); + ShaderCode code = TextureConversionShaderGen::GenerateShader(APIType::OpenGL, uid.GetUidData()); std::string geo_program = ""; char prefix = 'f'; diff --git a/Source/Core/VideoBackends/OGL/TextureCache.h b/Source/Core/VideoBackends/OGL/TextureCache.h index f0ab838c23..4a5e921eb6 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.h +++ b/Source/Core/VideoBackends/OGL/TextureCache.h @@ -86,7 +86,7 @@ private: GLuint position_uniform; }; - std::map m_efb_copy_programs; + std::map m_efb_copy_programs; SHADER m_colorCopyProgram; GLuint m_colorCopyPositionUniform; diff --git a/Source/Core/VideoBackends/Vulkan/TextureCache.cpp b/Source/Core/VideoBackends/Vulkan/TextureCache.cpp index 130a494bb2..a97a560d55 100644 --- a/Source/Core/VideoBackends/Vulkan/TextureCache.cpp +++ b/Source/Core/VideoBackends/Vulkan/TextureCache.cpp @@ -307,7 +307,8 @@ void TextureCache::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, texture->GetRawTexIdentifier()->TransitionToLayout(command_buffer, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - auto uid = GetTextureConverterShaderUid(dst_format, is_depth_copy, is_intensity, scale_by_half); + auto uid = TextureConversionShaderGen::GetShaderUid(dst_format, is_depth_copy, is_intensity, + scale_by_half); auto it = m_efb_copy_to_tex_shaders.emplace(uid, VkShaderModule(VK_NULL_HANDLE)); VkShaderModule& shader = it.first->second; @@ -316,7 +317,8 @@ void TextureCache::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, if (created) { std::string source = g_shader_cache->GetUtilityShaderHeader(); - source += GenerateTextureConverterShaderCode(APIType::Vulkan, uid.GetUidData()).GetBuffer(); + source += + TextureConversionShaderGen::GenerateShader(APIType::Vulkan, uid.GetUidData()).GetBuffer(); shader = Util::CompileAndCreateFragmentShader(source); } diff --git a/Source/Core/VideoBackends/Vulkan/TextureCache.h b/Source/Core/VideoBackends/Vulkan/TextureCache.h index 0e29229d18..26a01be3bb 100644 --- a/Source/Core/VideoBackends/Vulkan/TextureCache.h +++ b/Source/Core/VideoBackends/Vulkan/TextureCache.h @@ -65,7 +65,7 @@ private: std::unique_ptr m_texture_converter; VkShaderModule m_copy_shader = VK_NULL_HANDLE; - std::map m_efb_copy_to_tex_shaders; + std::map m_efb_copy_to_tex_shaders; }; } // namespace Vulkan diff --git a/Source/Core/VideoCommon/TextureConverterShaderGen.cpp b/Source/Core/VideoCommon/TextureConverterShaderGen.cpp index fc9b971f8b..f5d75d18f6 100644 --- a/Source/Core/VideoCommon/TextureConverterShaderGen.cpp +++ b/Source/Core/VideoCommon/TextureConverterShaderGen.cpp @@ -12,11 +12,13 @@ #include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" -TextureConverterShaderUid GetTextureConverterShaderUid(EFBCopyFormat dst_format, bool is_depth_copy, - bool is_intensity, bool scale_by_half) +namespace TextureConversionShaderGen { - TextureConverterShaderUid out; - convertion_shader_uid_data* uid_data = out.GetUidData(); +TCShaderUid GetShaderUid(EFBCopyFormat dst_format, bool is_depth_copy, bool is_intensity, + bool scale_by_half) +{ + TCShaderUid out; + UidData* uid_data = out.GetUidData(); memset(uid_data, 0, sizeof(*uid_data)); uid_data->dst_format = dst_format; @@ -28,8 +30,7 @@ TextureConverterShaderUid GetTextureConverterShaderUid(EFBCopyFormat dst_format, return out; } -ShaderCode GenerateTextureConverterShaderCode(APIType api_type, - const convertion_shader_uid_data* uid_data) +ShaderCode GenerateShader(APIType api_type, const UidData* uid_data) { ShaderCode out; @@ -299,3 +300,5 @@ ShaderCode GenerateTextureConverterShaderCode(APIType api_type, return out; } + +} // namespace TextureConversionShaderGen diff --git a/Source/Core/VideoCommon/TextureConverterShaderGen.h b/Source/Core/VideoCommon/TextureConverterShaderGen.h index 410940a63e..b55bf57065 100644 --- a/Source/Core/VideoCommon/TextureConverterShaderGen.h +++ b/Source/Core/VideoCommon/TextureConverterShaderGen.h @@ -10,10 +10,12 @@ enum class APIType; -#pragma pack(1) -struct convertion_shader_uid_data +namespace TextureConversionShaderGen { - u32 NumValues() const { return sizeof(convertion_shader_uid_data); } +#pragma pack(1) +struct UidData +{ + u32 NumValues() const { return sizeof(UidData); } EFBCopyFormat dst_format; u32 efb_has_alpha : 1; @@ -23,10 +25,11 @@ struct convertion_shader_uid_data }; #pragma pack() -using TextureConverterShaderUid = ShaderUid; +using TCShaderUid = ShaderUid; -ShaderCode GenerateTextureConverterShaderCode(APIType api_type, - const convertion_shader_uid_data* uid_data); +ShaderCode GenerateShader(APIType api_type, const UidData* uid_data); -TextureConverterShaderUid GetTextureConverterShaderUid(EFBCopyFormat dst_format, bool is_depth_copy, - bool is_intensity, bool scale_by_half); +TCShaderUid GetShaderUid(EFBCopyFormat dst_format, bool is_depth_copy, bool is_intensity, + bool scale_by_half); + +} // namespace TextureConversionShaderGen