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)
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',
'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
if function.name in self.marker_functions:
return
+ # We may be faking KHR_debug, so ensure the pointer queries result is
+ # always zeroed to prevent dereference of unitialized pointers
+ if function.name == 'glGetPointerv':
+ print ' if (params &&'
+ print ' (pname == GL_DEBUG_CALLBACK_FUNCTION ||'
+ print ' pname == GL_DEBUG_CALLBACK_USER_PARAM)) {'
+ print ' *params = NULL;'
+ print ' }'
+
if function.name in self.getProcAddressFunctionNames:
else_ = ''
for marker_function in self.marker_functions: