[Bf-blender-cvs] [c78ea965281] master: GPUShader: Add debug labels
Clément Foucault
noreply at git.blender.org
Tue Aug 18 21:30:59 CEST 2020
Commit: c78ea96528168760382f919b8cb6251d3faac683
Author: Clément Foucault
Date: Tue Aug 18 00:10:54 2020 +0200
Branches: master
https://developer.blender.org/rBc78ea96528168760382f919b8cb6251d3faac683
GPUShader: Add debug labels
This allow better debugging inside renderdoc.
===================================================================
M source/blender/gpu/opengl/gl_shader.cc
===================================================================
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;
}
More information about the Bf-blender-cvs
mailing list