VideoCommon: Rename TextureConversionShader namespace.

This commit is contained in:
degasus 2017-11-25 11:13:22 +01:00
parent e8febd0cef
commit e2a9ee384f
8 changed files with 29 additions and 26 deletions

View File

@ -143,7 +143,7 @@ ID3D11PixelShader* PSTextureEncoder::GetEncodingPixelShader(const EFBCopyParams&
return iter->second; return iter->second;
D3DBlob* bytecode = nullptr; D3DBlob* bytecode = nullptr;
const char* shader = TextureConversionShader::GenerateEncodingShader(params, APIType::D3D); const char* shader = TextureConversionShaderTiled::GenerateEncodingShader(params, APIType::D3D);
if (!D3D::CompilePixelShader(shader, &bytecode)) if (!D3D::CompilePixelShader(shader, &bytecode))
{ {
PanicAlert("Failed to compile texture encoding shader."); PanicAlert("Failed to compile texture encoding shader.");

View File

@ -337,16 +337,16 @@ void main()
void TextureCache::CreateTextureDecodingResources() void TextureCache::CreateTextureDecodingResources()
{ {
static const GLenum gl_view_types[TextureConversionShader::BUFFER_FORMAT_COUNT] = { static const GLenum gl_view_types[TextureConversionShaderTiled::BUFFER_FORMAT_COUNT] = {
GL_R8UI, // BUFFER_FORMAT_R8_UINT GL_R8UI, // BUFFER_FORMAT_R8_UINT
GL_R16UI, // BUFFER_FORMAT_R16_UINT GL_R16UI, // BUFFER_FORMAT_R16_UINT
GL_RG32UI, // BUFFER_FORMAT_R32G32_UINT GL_RG32UI, // BUFFER_FORMAT_R32G32_UINT
GL_RGBA8UI, // BUFFER_FORMAT_RGBA8_UINT GL_RGBA8UI, // BUFFER_FORMAT_RGBA8_UINT
}; };
glGenTextures(TextureConversionShader::BUFFER_FORMAT_COUNT, glGenTextures(TextureConversionShaderTiled::BUFFER_FORMAT_COUNT,
m_texture_decoding_buffer_views.data()); m_texture_decoding_buffer_views.data());
for (size_t i = 0; i < TextureConversionShader::BUFFER_FORMAT_COUNT; i++) for (size_t i = 0; i < TextureConversionShaderTiled::BUFFER_FORMAT_COUNT; i++)
{ {
glBindTexture(GL_TEXTURE_BUFFER, m_texture_decoding_buffer_views[i]); glBindTexture(GL_TEXTURE_BUFFER, m_texture_decoding_buffer_views[i]);
glTexBuffer(GL_TEXTURE_BUFFER, gl_view_types[i], m_palette_stream_buffer->m_buffer); glTexBuffer(GL_TEXTURE_BUFFER, gl_view_types[i], m_palette_stream_buffer->m_buffer);
@ -355,7 +355,7 @@ void TextureCache::CreateTextureDecodingResources()
void TextureCache::DestroyTextureDecodingResources() void TextureCache::DestroyTextureDecodingResources()
{ {
glDeleteTextures(TextureConversionShader::BUFFER_FORMAT_COUNT, glDeleteTextures(TextureConversionShaderTiled::BUFFER_FORMAT_COUNT,
m_texture_decoding_buffer_views.data()); m_texture_decoding_buffer_views.data());
m_texture_decoding_buffer_views.fill(0); m_texture_decoding_buffer_views.fill(0);
m_texture_decoding_program_info.clear(); m_texture_decoding_program_info.clear();
@ -369,7 +369,7 @@ bool TextureCache::SupportsGPUTextureDecode(TextureFormat format, TLUTFormat pal
return iter->second.valid; return iter->second.valid;
TextureDecodingProgramInfo info; TextureDecodingProgramInfo info;
info.base_info = TextureConversionShader::GetDecodingShaderInfo(format); info.base_info = TextureConversionShaderTiled::GetDecodingShaderInfo(format);
if (!info.base_info) if (!info.base_info)
{ {
m_texture_decoding_program_info.emplace(key, info); m_texture_decoding_program_info.emplace(key, info);
@ -377,7 +377,7 @@ bool TextureCache::SupportsGPUTextureDecode(TextureFormat format, TLUTFormat pal
} }
std::string shader_source = std::string shader_source =
TextureConversionShader::GenerateDecodingShader(format, palette_format, APIType::OpenGL); TextureConversionShaderTiled::GenerateDecodingShader(format, palette_format, APIType::OpenGL);
if (shader_source.empty()) if (shader_source.empty())
{ {
m_texture_decoding_program_info.emplace(key, info); m_texture_decoding_program_info.emplace(key, info);
@ -417,7 +417,7 @@ void TextureCache::DecodeTextureOnGPU(TCacheEntry* entry, u32 dst_level, const u
// Copy to GPU-visible buffer, aligned to the data type. // Copy to GPU-visible buffer, aligned to the data type.
auto info = iter->second; auto info = iter->second;
u32 bytes_per_buffer_elem = u32 bytes_per_buffer_elem =
TextureConversionShader::GetBytesPerBufferElement(info.base_info->buffer_format); TextureConversionShaderTiled::GetBytesPerBufferElement(info.base_info->buffer_format);
// Only copy palette if it is required. // Only copy palette if it is required.
bool has_palette = info.base_info->palette_size > 0; bool has_palette = info.base_info->palette_size > 0;
@ -470,7 +470,7 @@ void TextureCache::DecodeTextureOnGPU(TCacheEntry* entry, u32 dst_level, const u
} }
auto dispatch_groups = auto dispatch_groups =
TextureConversionShader::GetDispatchCount(info.base_info, aligned_width, aligned_height); TextureConversionShaderTiled::GetDispatchCount(info.base_info, aligned_width, aligned_height);
glBindImageTexture(0, static_cast<OGLTexture*>(entry->texture.get())->GetRawTexIdentifier(), glBindImageTexture(0, static_cast<OGLTexture*>(entry->texture.get())->GetRawTexIdentifier(),
dst_level, GL_TRUE, 0, GL_WRITE_ONLY, GL_RGBA8); dst_level, GL_TRUE, 0, GL_WRITE_ONLY, GL_RGBA8);
glDispatchCompute(dispatch_groups.first, dispatch_groups.second, 1); glDispatchCompute(dispatch_groups.first, dispatch_groups.second, 1);

View File

@ -50,7 +50,7 @@ private:
struct TextureDecodingProgramInfo struct TextureDecodingProgramInfo
{ {
const TextureConversionShader::DecodingShaderInfo* base_info = nullptr; const TextureConversionShaderTiled::DecodingShaderInfo* base_info = nullptr;
SHADER program; SHADER program;
GLint uniform_dst_size = -1; GLint uniform_dst_size = -1;
GLint uniform_src_size = -1; GLint uniform_src_size = -1;
@ -96,6 +96,7 @@ private:
GLuint m_palette_resolv_texture = 0; GLuint m_palette_resolv_texture = 0;
std::map<std::pair<u32, u32>, TextureDecodingProgramInfo> m_texture_decoding_program_info; std::map<std::pair<u32, u32>, TextureDecodingProgramInfo> m_texture_decoding_program_info;
std::array<GLuint, TextureConversionShader::BUFFER_FORMAT_COUNT> m_texture_decoding_buffer_views; std::array<GLuint, TextureConversionShaderTiled::BUFFER_FORMAT_COUNT>
m_texture_decoding_buffer_views;
}; };
} }

View File

@ -54,7 +54,8 @@ static EncodingProgram& GetOrCreateEncodingShader(const EFBCopyParams& params)
if (iter != s_encoding_programs.end()) if (iter != s_encoding_programs.end())
return iter->second; return iter->second;
const char* shader = TextureConversionShader::GenerateEncodingShader(params, APIType::OpenGL); const char* shader =
TextureConversionShaderTiled::GenerateEncodingShader(params, APIType::OpenGL);
#if defined(_DEBUG) || defined(DEBUGFAST) #if defined(_DEBUG) || defined(DEBUGFAST)
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && shader) if (g_ActiveConfig.iLog & CONF_SAVESHADERS && shader)

View File

@ -389,7 +389,7 @@ bool TextureConverter::SupportsTextureDecoding(TextureFormat format, TLUTFormat
return iter->second.valid; return iter->second.valid;
TextureDecodingPipeline pipeline; TextureDecodingPipeline pipeline;
pipeline.base_info = TextureConversionShader::GetDecodingShaderInfo(format); pipeline.base_info = TextureConversionShaderTiled::GetDecodingShaderInfo(format);
pipeline.compute_shader = VK_NULL_HANDLE; pipeline.compute_shader = VK_NULL_HANDLE;
pipeline.valid = false; pipeline.valid = false;
@ -400,7 +400,7 @@ bool TextureConverter::SupportsTextureDecoding(TextureFormat format, TLUTFormat
} }
std::string shader_source = std::string shader_source =
TextureConversionShader::GenerateDecodingShader(format, palette_format, APIType::Vulkan); TextureConversionShaderTiled::GenerateDecodingShader(format, palette_format, APIType::Vulkan);
pipeline.compute_shader = Util::CompileAndCreateComputeShader(shader_source); pipeline.compute_shader = Util::CompileAndCreateComputeShader(shader_source);
if (pipeline.compute_shader == VK_NULL_HANDLE) if (pipeline.compute_shader == VK_NULL_HANDLE)
@ -438,7 +438,7 @@ void TextureConverter::DecodeTexture(VkCommandBuffer command_buffer,
// Copy to GPU-visible buffer, aligned to the data type // Copy to GPU-visible buffer, aligned to the data type
auto info = iter->second; auto info = iter->second;
u32 bytes_per_buffer_elem = u32 bytes_per_buffer_elem =
TextureConversionShader::GetBytesPerBufferElement(info.base_info->buffer_format); TextureConversionShaderTiled::GetBytesPerBufferElement(info.base_info->buffer_format);
// Calculate total data size, including palette. // Calculate total data size, including palette.
// Only copy palette if it is required. // Only copy palette if it is required.
@ -496,16 +496,16 @@ void TextureConverter::DecodeTexture(VkCommandBuffer command_buffer,
VkBufferView data_view = VK_NULL_HANDLE; VkBufferView data_view = VK_NULL_HANDLE;
switch (iter->second.base_info->buffer_format) switch (iter->second.base_info->buffer_format)
{ {
case TextureConversionShader::BUFFER_FORMAT_R8_UINT: case TextureConversionShaderTiled::BUFFER_FORMAT_R8_UINT:
data_view = m_texel_buffer_view_r8_uint; data_view = m_texel_buffer_view_r8_uint;
break; break;
case TextureConversionShader::BUFFER_FORMAT_R16_UINT: case TextureConversionShaderTiled::BUFFER_FORMAT_R16_UINT:
data_view = m_texel_buffer_view_r16_uint; data_view = m_texel_buffer_view_r16_uint;
break; break;
case TextureConversionShader::BUFFER_FORMAT_R32G32_UINT: case TextureConversionShaderTiled::BUFFER_FORMAT_R32G32_UINT:
data_view = m_texel_buffer_view_r32g32_uint; data_view = m_texel_buffer_view_r32g32_uint;
break; break;
case TextureConversionShader::BUFFER_FORMAT_RGBA8_UINT: case TextureConversionShaderTiled::BUFFER_FORMAT_RGBA8_UINT:
data_view = m_texel_buffer_view_rgba8_uint; data_view = m_texel_buffer_view_rgba8_uint;
break; break;
default: default:
@ -522,8 +522,8 @@ void TextureConverter::DecodeTexture(VkCommandBuffer command_buffer,
dispatcher.SetTexelBuffer(0, data_view); dispatcher.SetTexelBuffer(0, data_view);
if (has_palette) if (has_palette)
dispatcher.SetTexelBuffer(1, m_texel_buffer_view_r16_uint); dispatcher.SetTexelBuffer(1, m_texel_buffer_view_r16_uint);
auto groups = TextureConversionShader::GetDispatchCount(iter->second.base_info, aligned_width, auto groups = TextureConversionShaderTiled::GetDispatchCount(iter->second.base_info,
aligned_height); aligned_width, aligned_height);
dispatcher.Dispatch(groups.first, groups.second, 1); dispatcher.Dispatch(groups.first, groups.second, 1);
// Copy from temporary texture to final destination. // Copy from temporary texture to final destination.
@ -691,7 +691,8 @@ bool TextureConverter::CompilePaletteConversionShaders()
VkShaderModule TextureConverter::CompileEncodingShader(const EFBCopyParams& params) VkShaderModule TextureConverter::CompileEncodingShader(const EFBCopyParams& params)
{ {
const char* shader = TextureConversionShader::GenerateEncodingShader(params, APIType::Vulkan); const char* shader =
TextureConversionShaderTiled::GenerateEncodingShader(params, APIType::Vulkan);
VkShaderModule module = Util::CompileAndCreateFragmentShader(shader); VkShaderModule module = Util::CompileAndCreateFragmentShader(shader);
if (module == VK_NULL_HANDLE) if (module == VK_NULL_HANDLE)
PanicAlert("Failed to compile texture encoding shader."); PanicAlert("Failed to compile texture encoding shader.");

View File

@ -114,7 +114,7 @@ private:
// Texture decoding - GX format in memory->RGBA8 // Texture decoding - GX format in memory->RGBA8
struct TextureDecodingPipeline struct TextureDecodingPipeline
{ {
const TextureConversionShader::DecodingShaderInfo* base_info; const TextureConversionShaderTiled::DecodingShaderInfo* base_info;
VkShaderModule compute_shader; VkShaderModule compute_shader;
bool valid; bool valid;
}; };

View File

@ -22,7 +22,7 @@
static char text[16384]; static char text[16384];
static bool IntensityConstantAdded = false; static bool IntensityConstantAdded = false;
namespace TextureConversionShader namespace TextureConversionShaderTiled
{ {
u16 GetEncodedSampleCount(EFBCopyFormat format) u16 GetEncodedSampleCount(EFBCopyFormat format)
{ {

View File

@ -15,7 +15,7 @@ enum class EFBCopyFormat;
enum class TLUTFormat; enum class TLUTFormat;
struct EFBCopyParams; struct EFBCopyParams;
namespace TextureConversionShader namespace TextureConversionShaderTiled
{ {
u16 GetEncodedSampleCount(EFBCopyFormat format); u16 GetEncodedSampleCount(EFBCopyFormat format);
@ -58,4 +58,4 @@ std::pair<u32, u32> GetDispatchCount(const DecodingShaderInfo* info, u32 width,
std::string GenerateDecodingShader(TextureFormat format, TLUTFormat palette_format, std::string GenerateDecodingShader(TextureFormat format, TLUTFormat palette_format,
APIType api_type); APIType api_type);
} // namespace TextureConversionShader } // namespace TextureConversionShaderTiled