VideoCommon: Create a namespace for TextureConversionShaderGen.
This commit is contained in:
parent
491c10ec96
commit
e8febd0cef
|
@ -510,7 +510,8 @@ void TextureCache::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
||||||
|
|
||||||
glViewport(0, 0, destination_texture->GetConfig().width, destination_texture->GetConfig().height);
|
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());
|
auto it = m_efb_copy_programs.emplace(uid, EFBCopyShader());
|
||||||
EFBCopyShader& shader = it.first->second;
|
EFBCopyShader& shader = it.first->second;
|
||||||
|
@ -518,7 +519,7 @@ void TextureCache::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
||||||
|
|
||||||
if (created)
|
if (created)
|
||||||
{
|
{
|
||||||
ShaderCode code = GenerateTextureConverterShaderCode(APIType::OpenGL, uid.GetUidData());
|
ShaderCode code = TextureConversionShaderGen::GenerateShader(APIType::OpenGL, uid.GetUidData());
|
||||||
|
|
||||||
std::string geo_program = "";
|
std::string geo_program = "";
|
||||||
char prefix = 'f';
|
char prefix = 'f';
|
||||||
|
|
|
@ -86,7 +86,7 @@ private:
|
||||||
GLuint position_uniform;
|
GLuint position_uniform;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<TextureConverterShaderUid, EFBCopyShader> m_efb_copy_programs;
|
std::map<TextureConversionShaderGen::TCShaderUid, EFBCopyShader> m_efb_copy_programs;
|
||||||
|
|
||||||
SHADER m_colorCopyProgram;
|
SHADER m_colorCopyProgram;
|
||||||
GLuint m_colorCopyPositionUniform;
|
GLuint m_colorCopyPositionUniform;
|
||||||
|
|
|
@ -307,7 +307,8 @@ void TextureCache::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
||||||
texture->GetRawTexIdentifier()->TransitionToLayout(command_buffer,
|
texture->GetRawTexIdentifier()->TransitionToLayout(command_buffer,
|
||||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
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));
|
auto it = m_efb_copy_to_tex_shaders.emplace(uid, VkShaderModule(VK_NULL_HANDLE));
|
||||||
VkShaderModule& shader = it.first->second;
|
VkShaderModule& shader = it.first->second;
|
||||||
|
@ -316,7 +317,8 @@ void TextureCache::CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy,
|
||||||
if (created)
|
if (created)
|
||||||
{
|
{
|
||||||
std::string source = g_shader_cache->GetUtilityShaderHeader();
|
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);
|
shader = Util::CompileAndCreateFragmentShader(source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ private:
|
||||||
std::unique_ptr<TextureConverter> m_texture_converter;
|
std::unique_ptr<TextureConverter> m_texture_converter;
|
||||||
|
|
||||||
VkShaderModule m_copy_shader = VK_NULL_HANDLE;
|
VkShaderModule m_copy_shader = VK_NULL_HANDLE;
|
||||||
std::map<TextureConverterShaderUid, VkShaderModule> m_efb_copy_to_tex_shaders;
|
std::map<TextureConversionShaderGen::TCShaderUid, VkShaderModule> m_efb_copy_to_tex_shaders;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -12,11 +12,13 @@
|
||||||
#include "VideoCommon/VideoCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
TextureConverterShaderUid GetTextureConverterShaderUid(EFBCopyFormat dst_format, bool is_depth_copy,
|
namespace TextureConversionShaderGen
|
||||||
bool is_intensity, bool scale_by_half)
|
|
||||||
{
|
{
|
||||||
TextureConverterShaderUid out;
|
TCShaderUid GetShaderUid(EFBCopyFormat dst_format, bool is_depth_copy, bool is_intensity,
|
||||||
convertion_shader_uid_data* uid_data = out.GetUidData<convertion_shader_uid_data>();
|
bool scale_by_half)
|
||||||
|
{
|
||||||
|
TCShaderUid out;
|
||||||
|
UidData* uid_data = out.GetUidData<UidData>();
|
||||||
memset(uid_data, 0, sizeof(*uid_data));
|
memset(uid_data, 0, sizeof(*uid_data));
|
||||||
|
|
||||||
uid_data->dst_format = dst_format;
|
uid_data->dst_format = dst_format;
|
||||||
|
@ -28,8 +30,7 @@ TextureConverterShaderUid GetTextureConverterShaderUid(EFBCopyFormat dst_format,
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderCode GenerateTextureConverterShaderCode(APIType api_type,
|
ShaderCode GenerateShader(APIType api_type, const UidData* uid_data)
|
||||||
const convertion_shader_uid_data* uid_data)
|
|
||||||
{
|
{
|
||||||
ShaderCode out;
|
ShaderCode out;
|
||||||
|
|
||||||
|
@ -299,3 +300,5 @@ ShaderCode GenerateTextureConverterShaderCode(APIType api_type,
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace TextureConversionShaderGen
|
||||||
|
|
|
@ -10,10 +10,12 @@
|
||||||
|
|
||||||
enum class APIType;
|
enum class APIType;
|
||||||
|
|
||||||
#pragma pack(1)
|
namespace TextureConversionShaderGen
|
||||||
struct convertion_shader_uid_data
|
|
||||||
{
|
{
|
||||||
u32 NumValues() const { return sizeof(convertion_shader_uid_data); }
|
#pragma pack(1)
|
||||||
|
struct UidData
|
||||||
|
{
|
||||||
|
u32 NumValues() const { return sizeof(UidData); }
|
||||||
EFBCopyFormat dst_format;
|
EFBCopyFormat dst_format;
|
||||||
|
|
||||||
u32 efb_has_alpha : 1;
|
u32 efb_has_alpha : 1;
|
||||||
|
@ -23,10 +25,11 @@ struct convertion_shader_uid_data
|
||||||
};
|
};
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
using TextureConverterShaderUid = ShaderUid<convertion_shader_uid_data>;
|
using TCShaderUid = ShaderUid<UidData>;
|
||||||
|
|
||||||
ShaderCode GenerateTextureConverterShaderCode(APIType api_type,
|
ShaderCode GenerateShader(APIType api_type, const UidData* uid_data);
|
||||||
const convertion_shader_uid_data* uid_data);
|
|
||||||
|
|
||||||
TextureConverterShaderUid GetTextureConverterShaderUid(EFBCopyFormat dst_format, bool is_depth_copy,
|
TCShaderUid GetShaderUid(EFBCopyFormat dst_format, bool is_depth_copy, bool is_intensity,
|
||||||
bool is_intensity, bool scale_by_half);
|
bool scale_by_half);
|
||||||
|
|
||||||
|
} // namespace TextureConversionShaderGen
|
||||||
|
|
Loading…
Reference in New Issue