diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2021-08-28 00:30:05 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2021-08-30 13:47:48 -0500 |
| commit | 1f2f5053735b4e94dac29237e9482befd9a2687b (patch) | |
| tree | dfe18ba017a6cda4a79c01c10431c7c37e8f74a3 /Source/Core/VideoBackends/OGL/OGLShader.cpp | |
| parent | 9b83cf3e7fdf6fc4d15b78193461fd1081d61008 (diff) | |
VideoBackends / VideoCommon: allow the ability to set debug names for shaders / textures. These names are visible in applications like RenderDoc
Diffstat (limited to 'Source/Core/VideoBackends/OGL/OGLShader.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/OGLShader.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/Source/Core/VideoBackends/OGL/OGLShader.cpp b/Source/Core/VideoBackends/OGL/OGLShader.cpp index 9a4db8b856..11914f0355 100644 --- a/Source/Core/VideoBackends/OGL/OGLShader.cpp +++ b/Source/Core/VideoBackends/OGL/OGLShader.cpp @@ -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 |
