]> git.cworth.org Git - apitrace/commitdiff
glstate: Dump a few object labels.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 10 Oct 2013 01:40:14 +0000 (18:40 -0700)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 10 Oct 2013 01:40:14 +0000 (18:40 -0700)
retrace/glstate.cpp
retrace/glstate_internal.hpp
retrace/glstate_params.py

index a07b7f6a528d481aacfe580909e1d3dcbff468a8..3a65d20a0c8c052bdf2b7e0938c0084c68e0b4a2 100644 (file)
@@ -77,17 +77,22 @@ Context::Context(void) {
             glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
             for (GLint i = 0; i < num_extensions; ++i) {
                const char *extension = (const char *)glGetStringi(GL_EXTENSIONS, i);
-               if (extension &&
-                   strcmp(extension, "ARB_sampler_objects")) {
-                   ARB_sampler_objects = true;
+               if (extension) {
+                   if (strcmp(extension, "GL_ARB_sampler_objects") == 0) {
+                       ARB_sampler_objects = true;
+                   } else if (strcmp(extension, "GL_KHR_debug") == 0) {
+                       KHR_debug = true;
+                   }
                }
             }
         } else {
             const char *extensions = (const char *)glGetString(GL_EXTENSIONS);
-            if (glws::checkExtension("ARB_sampler_objects", extensions)) {
-                ARB_sampler_objects = true;
-            }
+            ARB_sampler_objects = glws::checkExtension("GL_ARB_sampler_objects", extensions);
+            KHR_debug = glws::checkExtension("GL_KHR_debug", extensions);
         }
+    } else {
+        const char *extensions = (const char *)glGetString(GL_EXTENSIONS);
+        KHR_debug = glws::checkExtension("GL_KHR_debug", extensions);
     }
 }
 
@@ -147,6 +152,39 @@ Context::restorePixelPackState(void) {
 }
 
 
+/**
+ * Dump a GL_KHR_debug object label.
+ */
+void
+dumpObjectLabel(JSONWriter &json, Context &context, GLenum identifier, GLuint name)
+{
+    if (!name) {
+        return;
+    }
+
+    if (!context.KHR_debug) {
+        return;
+    }
+
+    GLsizei length = 0;
+    glGetObjectLabel(identifier, name, 0, &length, NULL);
+    if (!length) {
+        return;
+    }
+
+    char *label = (char *)malloc(length);
+    if (!label) {
+        return;
+    }
+
+    glGetObjectLabel(identifier, name, length, NULL, label);
+
+    json.writeStringMember("GL_OBJECT_LABEL", label);
+
+    free(label);
+}
+
+
 static const GLenum bindings[] = {
     GL_DRAW_BUFFER,
     GL_READ_BUFFER,
index 942c3a69e47147c4ce461a919d10f8f36eca6f30..0fd378ba65fea784f83247e00371fab0a804b35a 100644 (file)
@@ -42,6 +42,7 @@ struct Context
 
     bool ARB_draw_buffers;
     bool ARB_sampler_objects;
+    bool KHR_debug;
 
     Context(void);
 
@@ -69,6 +70,8 @@ void dumpBoolean(JSONWriter &json, GLboolean value);
 
 void dumpEnum(JSONWriter &json, GLenum pname);
 
+void dumpObjectLabel(JSONWriter &json, Context &context, GLenum identifier, GLuint name);
+
 void dumpParameters(JSONWriter &json, Context &context);
 
 void dumpShadersUniforms(JSONWriter &json, Context &context);
index 64ac02d4f7e47448b885e62be790455e8eaeea14..094eb6c6c398fb9b41924ad773c816018724bd52 100644 (file)
@@ -345,6 +345,7 @@ class StateDumper:
         print '    if (enabled || binding) {'
         print '        json.beginMember(enumToString(target));'
         print '        json.beginObject();'
+        print '        dumpObjectLabel(json, context, GL_TEXTURE, binding);'
         self.dump_atoms(glGetTexParameter, 'target')
         print '        if (!context.ES) {'
         print '            GLenum levelTarget;'
@@ -432,6 +433,7 @@ class StateDumper:
         print '        if (sampler_binding) {'
         print '            json.beginMember("GL_SAMPLER");'
         print '            json.beginObject();'
+        print '            dumpObjectLabel(json, context, GL_SAMPLER, sampler_binding);'
         for _, _, name in glGetSamplerParameter.iter():
             self.dump_atom(glGetSamplerParameter, 'sampler_binding', name)
         print '           json.endObject();'
@@ -527,6 +529,7 @@ class StateDumper:
             print '            if (framebuffer) {'
             print '                json.beginMember("%s");' % target
             print '                json.beginObject();'
+            print '                dumpObjectLabel(json, context, GL_FRAMEBUFFER, framebuffer);'
             print '                for (GLint i = 0; i < max_color_attachments; ++i) {'
             print '                    GLint color_attachment = GL_COLOR_ATTACHMENT0 + i;'
             print '                    dumpFramebufferAttachementParameters(json, %s, color_attachment);' % target