VideoCommon: Create a namespace for TextureConversionShaderGen.

This commit is contained in:
degasus 2017-11-25 11:07:14 +01:00
parent 491c10ec96
commit e8febd0cef
6 changed files with 29 additions and 20 deletions

View File

@ -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';

View File

@ -86,7 +86,7 @@ private:
GLuint position_uniform;
};
std::map<TextureConverterShaderUid, EFBCopyShader> m_efb_copy_programs;
std::map<TextureConversionShaderGen::TCShaderUid, EFBCopyShader> m_efb_copy_programs;
SHADER m_colorCopyProgram;
GLuint m_colorCopyPositionUniform;

View File

@ -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);
}

View File

@ -65,7 +65,7 @@ private:
std::unique_ptr<TextureConverter> m_texture_converter;
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

View File

@ -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<convertion_shader_uid_data>();
TCShaderUid GetShaderUid(EFBCopyFormat dst_format, bool is_depth_copy, bool is_intensity,
bool scale_by_half)
{
TCShaderUid out;
UidData* uid_data = out.GetUidData<UidData>();
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

View File

@ -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<convertion_shader_uid_data>;
using TCShaderUid = ShaderUid<UidData>;
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