diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-18 01:10:54 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-08-18 22:30:10 +0300 |
commit | c78ea96528168760382f919b8cb6251d3faac683 (patch) | |
tree | 441268f5f3a45c5c05ea9264e577c8e235d9e4c8 | |
parent | ba3c18f4b23e2154a81af4d765a19b136695dc05 (diff) |
GPUShader: Add debug labels
This allow better debugging inside renderdoc.
-rw-r--r-- | source/blender/gpu/opengl/gl_shader.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index 6c746d91336..ea33ff00d69 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -44,6 +44,14 @@ GLShader::GLShader(const char *name) : Shader(name) BLI_assert(GPU_context_active_get() != NULL); #endif shader_program_ = glCreateProgram(); + +#ifndef __APPLE__ + if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) { + char sh_name[64]; + BLI_snprintf(sh_name, sizeof(sh_name), "ShaderProgram-%s", name); + glObjectLabel(GL_PROGRAM, shader_program_, -1, sh_name); + } +#endif } GLShader::~GLShader(void) @@ -144,6 +152,25 @@ GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *> glDeleteShader(shader); return 0; } + +#ifndef __APPLE__ + if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) { + char sh_name[64]; + switch (gl_stage) { + case GL_VERTEX_SHADER: + BLI_snprintf(sh_name, sizeof(sh_name), "VertShader-%s", name); + break; + case GL_GEOMETRY_SHADER: + BLI_snprintf(sh_name, sizeof(sh_name), "GeomShader-%s", name); + break; + case GL_FRAGMENT_SHADER: + BLI_snprintf(sh_name, sizeof(sh_name), "FragShader-%s", name); + break; + } + glObjectLabel(GL_SHADER, shader, -1, sh_name); + } +#endif + glAttachShader(shader_program_, shader); return shader; } |