From: Peter Lohrmann Date: Mon, 3 Jun 2013 21:58:41 +0000 (-0700) Subject: trace: Additional support for GL_KHR_debug, GL_ARB_debug_output, and GL_AMD_debug_output. X-Git-Url: https://git.cworth.org/git?p=apitrace;a=commitdiff_plain;h=0b5b75e507df681260ea9c43b142ee48fff780c5 trace: Additional support for GL_KHR_debug, GL_ARB_debug_output, and GL_AMD_debug_output. * Mark some of the entrypoints as having sideeffects so that they will be replayed and can be seen in other 3rd party tools. * Add the three additional extensions to the supported extensions list. * Create new list of debug_entrypoints which may be implemented by a driver. These entrypoints need to be handled differently from the marker_entrypoints in that debug_entrypoints may be exposed by the driver via wglGetProcAddress and apitrace should pass the calls along if they are available. The marker_extensions are not expected to be implemented by the driver, so wglGetProcAddress(..) does not need to be called on them. Note that even though this causes apitrace to return the extension strings, the full extension implementation has not been completed, but the entrypoints are exposed for the application to call. Signed-off-by: José Fonseca --- diff --git a/specs/glapi.py b/specs/glapi.py index 3c89034..701b56f 100644 --- a/specs/glapi.py +++ b/specs/glapi.py @@ -1306,8 +1306,8 @@ glapi.addFunctions([ #GlFunction(GLsync, "glCreateSyncFromCLeventARB", [(OpaquePointer("struct _cl_context"), "context"), (OpaquePointer("struct _cl_event"), "event"), (GLbitfield, "flags")]), # GL_ARB_debug_output - GlFunction(Void, "glDebugMessageControlARB", [(GLenum, "source"), (GLenum, "type"), (GLenum, "severity"), (GLsizei, "count"), (Array(Const(GLuint), "count"), "ids"), (GLboolean, "enabled")], sideeffects=False), - GlFunction(Void, "glDebugMessageInsertARB", [(GLenum, "source"), (GLenum, "type"), (GLuint, "id"), (GLenum, "severity"), (GLsizei, "length"), InGlString(GLchar, "length", "buf")], sideeffects=False), + GlFunction(Void, "glDebugMessageControlARB", [(GLenum, "source"), (GLenum, "type"), (GLenum, "severity"), (GLsizei, "count"), (Array(Const(GLuint), "count"), "ids"), (GLboolean, "enabled")], sideeffects=True), + GlFunction(Void, "glDebugMessageInsertARB", [(GLenum, "source"), (GLenum, "type"), (GLuint, "id"), (GLenum, "severity"), (GLsizei, "length"), InGlString(GLchar, "length", "buf")], sideeffects=True), GlFunction(Void, "glDebugMessageCallbackARB", [(GLDEBUGPROCARB, "callback"), (GLpointerConst, "userParam")], sideeffects=False), GlFunction(GLuint, "glGetDebugMessageLogARB", [(GLuint, "count"), (GLsizei, "bufsize"), Out(Array(GLenum, "count"), "sources"), Out(Array(GLenum, "count"), "types"), Out(Array(GLuint, "count"), "ids"), Out(Array(GLenum, "count"), "severities"), Out(Array(GLsizei, "count"), "lengths"), Out(String(GLchar, "_glGetDebugMessageLog_length(messageLog, lengths, _result)"), "messageLog")], sideeffects=False), @@ -1361,15 +1361,15 @@ glapi.addFunctions([ GlFunction(Void, "glTextureStorage3DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLsizei, "levels"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth")]), # GL_KHR_debug - GlFunction(Void, "glDebugMessageControl", [(GLenum, "source"), (GLenum, "type"), (GLenum, "severity"), (GLsizei, "count"), (Array(Const(GLuint), "count"), "ids"), (GLboolean, "enabled")], sideeffects=False), - GlFunction(Void, "glDebugMessageInsert", [(GLenum, "source"), (GLenum, "type"), (GLuint, "id"), (GLenum, "severity"), (GLsizei, "length"), InGlString(GLchar, "length", "buf")], sideeffects=False), + GlFunction(Void, "glDebugMessageControl", [(GLenum, "source"), (GLenum, "type"), (GLenum, "severity"), (GLsizei, "count"), (Array(Const(GLuint), "count"), "ids"), (GLboolean, "enabled")], sideeffects=True), + GlFunction(Void, "glDebugMessageInsert", [(GLenum, "source"), (GLenum, "type"), (GLuint, "id"), (GLenum, "severity"), (GLsizei, "length"), InGlString(GLchar, "length", "buf")], sideeffects=True), GlFunction(Void, "glDebugMessageCallback", [(GLDEBUGPROC, "callback"), (OpaquePointer(Const(Void)), "userParam")], sideeffects=False), GlFunction(GLuint, "glGetDebugMessageLog", [(GLuint, "count"), (GLsizei, "bufsize"), Out(Array(GLenum, "count"), "sources"), Out(Array(GLenum, "count"), "types"), Out(Array(GLuint, "count"), "ids"), Out(Array(GLenum, "count"), "severities"), Out(Array(GLsizei, "count"), "lengths"), Out(String(GLchar, "_glGetDebugMessageLog_length(messageLog, lengths, _result)"), "messageLog")], sideeffects=False), - GlFunction(Void, "glPushDebugGroup", [(GLenum, "source"), (GLuint, "id"), (GLsizei, "length"), InGlString(GLchar, "length", "message")], sideeffects=False), - GlFunction(Void, "glPopDebugGroup", [], sideeffects=False), - GlFunction(Void, "glObjectLabel", [(GLenum, "identifier"), (GLuint, "name"), (GLsizei, "length"), InGlString(GLchar, "length", "label")], sideeffects=False), + GlFunction(Void, "glPushDebugGroup", [(GLenum, "source"), (GLuint, "id"), (GLsizei, "length"), InGlString(GLchar, "length", "message")], sideeffects=True), + GlFunction(Void, "glPopDebugGroup", [], sideeffects=True), + GlFunction(Void, "glObjectLabel", [(GLenum, "identifier"), (GLuint, "name"), (GLsizei, "length"), InGlString(GLchar, "length", "label")], sideeffects=True), GlFunction(Void, "glGetObjectLabel", [(GLenum, "identifier"), (GLuint, "name"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), OutGlString(GLchar, "length", "label")], sideeffects=False), - GlFunction(Void, "glObjectPtrLabel", [(OpaquePointer(Const(Void)), "ptr"), (GLsizei, "length"), InGlString(GLchar, "length", "label")], sideeffects=False), + GlFunction(Void, "glObjectPtrLabel", [(OpaquePointer(Const(Void)), "ptr"), (GLsizei, "length"), InGlString(GLchar, "length", "label")], sideeffects=True), GlFunction(Void, "glGetObjectPtrLabel", [(OpaquePointer(Const(Void)), "ptr"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), OutGlString(GLchar, "length", "label")], sideeffects=False), # GL_ARB_clear_buffer_object @@ -2333,7 +2333,7 @@ glapi.addFunctions([ GlFunction(Void, "glGenerateMipmapEXT", [(GLenum, "target")]), # GL_GREMEDY_string_marker - GlFunction(Void, "glStringMarkerGREMEDY", [(GLsizei, "len"), (String(Const(GLvoid), "len > 0 ? len : strlen((const char *)string)"), "string")], sideeffects=False), + GlFunction(Void, "glStringMarkerGREMEDY", [(GLsizei, "len"), (String(Const(GLvoid), "len > 0 ? len : strlen((const char *)string)"), "string")], sideeffects=True), # GL_EXT_stencil_clear_tag GlFunction(Void, "glStencilClearTagEXT", [(GLsizei, "stencilTagBits"), (GLuint, "stencilClearTag")]), @@ -2928,8 +2928,8 @@ glapi.addFunctions([ GlFunction(GLboolean, "glIsNameAMD", [(GLenum, "identifier"), (GLuint, "name")], sideeffects=False), # GL_AMD_debug_output - GlFunction(Void, "glDebugMessageEnableAMD", [(GLenum, "category"), (GLenum, "severity"), (GLsizei, "count"), (Array(Const(GLuint), "count"), "ids"), (GLboolean, "enabled")], sideeffects=False), - GlFunction(Void, "glDebugMessageInsertAMD", [(GLenum, "category"), (GLenum, "severity"), (GLuint, "id"), (GLsizei, "length"), InGlString(GLchar, "length", "buf")], sideeffects=False), + GlFunction(Void, "glDebugMessageEnableAMD", [(GLenum, "category"), (GLenum, "severity"), (GLsizei, "count"), (Array(Const(GLuint), "count"), "ids"), (GLboolean, "enabled")], sideeffects=True), + GlFunction(Void, "glDebugMessageInsertAMD", [(GLenum, "category"), (GLenum, "severity"), (GLuint, "id"), (GLsizei, "length"), InGlString(GLchar, "length", "buf")], sideeffects=True), GlFunction(Void, "glDebugMessageCallbackAMD", [(GLDEBUGPROCAMD, "callback"), (GLpointer, "userParam")], sideeffects=False), GlFunction(GLuint, "glGetDebugMessageLogAMD", [(GLuint, "count"), (GLsizei, "bufsize"), Out(Array(GLenum, "count"), "categories"), Out(Array(GLuint, "count"), "severities"), Out(Array(GLuint, "count"), "ids"), Out(Array(GLsizei, "count"), "lengths"), Out(String(GLchar, "_glGetDebugMessageLog_length(message, lengths, _result)"), "message")], sideeffects=False), diff --git a/wrappers/glcaps.cpp b/wrappers/glcaps.cpp index 1f2bbe6..43d5e5d 100644 --- a/wrappers/glcaps.cpp +++ b/wrappers/glcaps.cpp @@ -57,6 +57,9 @@ static const char * extraExtension_stringsFull[] = { "GL_GREMEDY_string_marker", "GL_GREMEDY_frame_terminator", + "GL_ARB_debug_output", + "GL_AMD_debug_output", + "GL_KHR_debug", }; static const char * diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py index e73c591..7bf2a35 100644 --- a/wrappers/gltrace.py +++ b/wrappers/gltrace.py @@ -329,9 +329,21 @@ class GlTracer(Tracer): Tracer.traceApi(self, api) print 'static %s _wrapProcAddress(%s procName, %s procPtr) {' % (retType, argType, retType) + + # Provide fallback functions to missing debug functions print ' if (!procPtr) {' - print ' return procPtr;' + else_ = '' + for function_name in self.debug_functions: + if self.api.getFunctionByName(function_name): + print ' %sif (strcmp("%s", (const char *)procName) == 0) {' % (else_, function_name) + print ' return (%s)&%s;' % (retType, function_name) + print ' }' + else_ = 'else ' + print ' %s{' % else_ + print ' return NULL;' + print ' }' print ' }' + for function in api.getAllFunctions(): ptype = function_pointer_type(function) pvalue = function_pointer_value(function) @@ -684,6 +696,8 @@ class GlTracer(Tracer): Tracer.traceFunctionImplBody(self, function) + # These entrypoints are only expected to be implemented by tools; + # drivers will probably not implement them. marker_functions = [ # GL_GREMEDY_string_marker 'glStringMarkerGREMEDY', @@ -695,6 +709,32 @@ class GlTracer(Tracer): 'glPopGroupMarkerEXT', ] + # These entrypoints may be implemented by drivers, but are also very useful + # for debugging / analysis tools. + debug_functions = [ + # GL_KHR_debug + 'glDebugMessageControl', + 'glDebugMessageInsert', + 'glDebugMessageCallback', + 'glGetDebugMessageLog', + 'glPushDebugGroup', + 'glPopDebugGroup', + 'glObjectLabel', + 'glGetObjectLabel', + 'glObjectPtrLabel', + 'glGetObjectPtrLabel', + # GL_ARB_debug_output + 'glDebugMessageControlARB', + 'glDebugMessageInsertARB', + 'glDebugMessageCallbackARB', + 'glGetDebugMessageLogARB', + # GL_AMD_debug_output + 'glDebugMessageEnableAMD', + 'glDebugMessageInsertAMD', + 'glDebugMessageCallbackAMD', + 'glGetDebugMessageLogAMD', + ] + def invokeFunction(self, function): if function.name in ('glLinkProgram', 'glLinkProgramARB'): # These functions have been dispatched already