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);
}
}
}
+/**
+ * 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,
bool ARB_draw_buffers;
bool ARB_sampler_objects;
+ bool KHR_debug;
Context(void);
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);
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;'
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();'
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