[Bf-blender-cvs] [dd04cba9439] master: GLSamplers: Add debug object label

Clément Foucault noreply at git.blender.org
Tue Sep 8 19:57:16 CEST 2020


Commit: dd04cba943931c77b5bb4956ff6d02ca32e6cac6
Author: Clément Foucault
Date:   Tue Sep 8 19:55:53 2020 +0200
Branches: master
https://developer.blender.org/rBdd04cba943931c77b5bb4956ff6d02ca32e6cac6

GLSamplers: Add debug object label

This makes it easier to see what each sampler is supposed to be.

===================================================================

M	source/blender/gpu/opengl/gl_texture.cc

===================================================================

diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc
index ae3923b960f..e649f73d1c4 100644
--- a/source/blender/gpu/opengl/gl_texture.cc
+++ b/source/blender/gpu/opengl/gl_texture.cc
@@ -513,6 +513,25 @@ void GLTexture::samplers_init(void)
      * - GL_TEXTURE_MAX_LOD is 1000.
      * - GL_TEXTURE_LOD_BIAS is 0.0f.
      **/
+
+#ifndef __APPLE__
+    if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
+      char sampler_name[128];
+      SNPRINTF(sampler_name,
+               "Sampler%s%s%s%s%s%s%s%s%s%s",
+               (state == GPU_SAMPLER_DEFAULT) ? "_default" : "",
+               (state & GPU_SAMPLER_FILTER) ? "_filter" : "",
+               (state & GPU_SAMPLER_MIPMAP) ? "_mipmap" : "",
+               (state & GPU_SAMPLER_REPEAT) ? "_repeat-" : "",
+               (state & GPU_SAMPLER_REPEAT_S) ? "S" : "",
+               (state & GPU_SAMPLER_REPEAT_T) ? "T" : "",
+               (state & GPU_SAMPLER_REPEAT_R) ? "R" : "",
+               (state & GPU_SAMPLER_CLAMP_BORDER) ? "_clamp_border" : "",
+               (state & GPU_SAMPLER_COMPARE) ? "_compare" : "",
+               (state & GPU_SAMPLER_ANISO) ? "_aniso" : "");
+      glObjectLabel(GL_SAMPLER, samplers_[i], -1, sampler_name);
+    }
+#endif
   }
   samplers_update();
 
@@ -521,6 +540,12 @@ void GLTexture::samplers_init(void)
   glSamplerParameteri(icon_sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
   glSamplerParameteri(icon_sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glSamplerParameterf(icon_sampler, GL_TEXTURE_LOD_BIAS, -0.5f);
+
+#ifndef __APPLE__
+  if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
+    glObjectLabel(GL_SAMPLER, icon_sampler, -1, "Sampler-icons");
+  }
+#endif
 }
 
 void GLTexture::samplers_update(void)



More information about the Bf-blender-cvs mailing list