mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
VideoBackends / VideoCommon: allow the ability to set debug names for shaders / textures. These names are visible in applications like RenderDoc
This commit is contained in:
@ -23,17 +23,26 @@ static GLenum GetGLShaderTypeForStage(ShaderStage stage)
|
||||
}
|
||||
}
|
||||
|
||||
OGLShader::OGLShader(ShaderStage stage, GLenum gl_type, GLuint gl_id, std::string source)
|
||||
OGLShader::OGLShader(ShaderStage stage, GLenum gl_type, GLuint gl_id, std::string source,
|
||||
std::string name)
|
||||
: AbstractShader(stage), m_id(ProgramShaderCache::GenerateShaderID()), m_type(gl_type),
|
||||
m_gl_id(gl_id), m_source(std::move(source))
|
||||
m_gl_id(gl_id), m_source(std::move(source)), m_name(std::move(name))
|
||||
{
|
||||
if (!m_name.empty())
|
||||
{
|
||||
glObjectLabel(GetGLShaderTypeForStage(stage), m_gl_id, -1, m_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
OGLShader::OGLShader(GLuint gl_compute_program_id, std::string source)
|
||||
OGLShader::OGLShader(GLuint gl_compute_program_id, std::string source, std::string name)
|
||||
: AbstractShader(ShaderStage::Compute), m_id(ProgramShaderCache::GenerateShaderID()),
|
||||
m_type(GL_COMPUTE_SHADER), m_gl_compute_program_id(gl_compute_program_id),
|
||||
m_source(std::move(source))
|
||||
m_source(std::move(source)), m_name(std::move(name))
|
||||
{
|
||||
if (!m_name.empty())
|
||||
{
|
||||
glObjectLabel(GL_COMPUTE_SHADER, m_gl_compute_program_id, -1, m_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
OGLShader::~OGLShader()
|
||||
@ -44,9 +53,11 @@ OGLShader::~OGLShader()
|
||||
glDeleteProgram(m_gl_compute_program_id);
|
||||
}
|
||||
|
||||
std::unique_ptr<OGLShader> OGLShader::CreateFromSource(ShaderStage stage, std::string_view source)
|
||||
std::unique_ptr<OGLShader> OGLShader::CreateFromSource(ShaderStage stage, std::string_view source,
|
||||
std::string_view name)
|
||||
{
|
||||
std::string source_str(source);
|
||||
std::string name_str(name);
|
||||
if (stage != ShaderStage::Compute)
|
||||
{
|
||||
GLenum shader_type = GetGLShaderTypeForStage(stage);
|
||||
@ -54,14 +65,15 @@ std::unique_ptr<OGLShader> OGLShader::CreateFromSource(ShaderStage stage, std::s
|
||||
if (!shader_id)
|
||||
return nullptr;
|
||||
|
||||
return std::make_unique<OGLShader>(stage, shader_type, shader_id, std::move(source_str));
|
||||
return std::make_unique<OGLShader>(stage, shader_type, shader_id, std::move(source_str),
|
||||
std::move(name_str));
|
||||
}
|
||||
|
||||
// Compute shaders.
|
||||
SHADER prog;
|
||||
if (!ProgramShaderCache::CompileComputeShader(prog, source_str))
|
||||
return nullptr;
|
||||
return std::make_unique<OGLShader>(prog.glprogid, std::move(source_str));
|
||||
return std::make_unique<OGLShader>(prog.glprogid, std::move(source_str), std::move(name_str));
|
||||
}
|
||||
|
||||
} // namespace OGL
|
||||
|
Reference in New Issue
Block a user