summaryrefslogtreecommitdiff
path: root/retrace
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2013-10-09 18:40:14 -0700
committerJosé Fonseca <jfonseca@vmware.com>2013-10-09 18:40:14 -0700
commit17f8a32687c040c652e6d018100bab08bb0487bd (patch)
treec5be52071eb65d10255c82a050abff2702998428 /retrace
parent9d9eb81d94075181c360d4712b9fd3baa58d5782 (diff)
glstate: Dump a few object labels.
Diffstat (limited to 'retrace')
-rw-r--r--retrace/glstate.cpp50
-rw-r--r--retrace/glstate_internal.hpp3
-rw-r--r--retrace/glstate_params.py3
3 files changed, 50 insertions, 6 deletions
diff --git a/retrace/glstate.cpp b/retrace/glstate.cpp
index a07b7f6a..3a65d20a 100644
--- a/retrace/glstate.cpp
+++ b/retrace/glstate.cpp
@@ -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,
diff --git a/retrace/glstate_internal.hpp b/retrace/glstate_internal.hpp
index 942c3a69..0fd378ba 100644
--- a/retrace/glstate_internal.hpp
+++ b/retrace/glstate_internal.hpp
@@ -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);
diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py
index 64ac02d4..094eb6c6 100644
--- a/retrace/glstate_params.py
+++ b/retrace/glstate_params.py
@@ -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