+ gremedy_functions = [
+ 'glStringMarkerGREMEDY',
+ 'glFrameTerminatorGREMEDY',
+ ]
+
+ def dispatch_function(self, function):
+ if function.name in ('glLinkProgram', 'glLinkProgramARB'):
+ # These functions have been dispatched already
+ return
+
+ # We implement the GREMEDY extensions, not the driver
+ if function.name in self.gremedy_functions:
+ return
+
+ if function.name in ('glXGetProcAddress', 'glXGetProcAddressARB', 'wglGetProcAddress'):
+ if_ = 'if'
+ for gremedy_function in self.gremedy_functions:
+ print ' %s (strcmp("%s", (const char *)%s) == 0) {' % (if_, gremedy_function, function.args[0].name)
+ print ' __result = (%s)&%s;' % (function.type, gremedy_function)
+ print ' }'
+ if_ = 'else if'
+ print ' else {'
+ Tracer.dispatch_function(self, function)
+ print ' }'
+ return
+
+ # Override GL extensions
+ if function.name in ('glGetString', 'glGetIntegerv', 'glGetStringi'):
+ Tracer.dispatch_function(self, function, prefix = 'gltrace::__', suffix = '_override')
+ return
+
+ Tracer.dispatch_function(self, function)
+
+ def emit_memcpy(self, dest, src, length):
+ print ' unsigned __call = Trace::localWriter.beginEnter(&__memcpy_sig);'
+ print ' Trace::localWriter.beginArg(0);'
+ print ' Trace::localWriter.writeOpaque(%s);' % dest
+ print ' Trace::localWriter.endArg();'
+ print ' Trace::localWriter.beginArg(1);'
+ print ' Trace::localWriter.writeBlob(%s, %s);' % (src, length)
+ print ' Trace::localWriter.endArg();'
+ print ' Trace::localWriter.beginArg(2);'
+ print ' Trace::localWriter.writeUInt(%s);' % length
+ print ' Trace::localWriter.endArg();'
+ print ' Trace::localWriter.endEnter();'
+ print ' Trace::localWriter.beginLeave(__call);'
+ print ' Trace::localWriter.endLeave();'
+
+ buffer_targets = [
+ 'ARRAY_BUFFER',
+ 'ELEMENT_ARRAY_BUFFER',
+ 'PIXEL_PACK_BUFFER',
+ 'PIXEL_UNPACK_BUFFER',
+ ]
+
+ def wrap_ret(self, function, instance):
+ Tracer.wrap_ret(self, function, instance)
+
+
+ if function.name in ('glMapBuffer', 'glMapBufferARB'):
+ print ' struct buffer_mapping *mapping = get_buffer_mapping(target);'
+ print ' if (mapping) {'
+ print ' mapping->map = %s;' % (instance)
+ print ' mapping->length = 0;'
+ print ' __glGetBufferParameteriv(target, GL_BUFFER_SIZE, &mapping->length);'
+ print ' mapping->write = (access != GL_READ_ONLY);'
+ print ' mapping->explicit_flush = false;'
+ print ' }'
+
+ if function.name == 'glMapBufferRange':
+ print ' struct buffer_mapping *mapping = get_buffer_mapping(target);'
+ print ' if (mapping) {'
+ print ' mapping->map = %s;' % (instance)
+ print ' mapping->length = length;'
+ print ' mapping->write = access & GL_MAP_WRITE_BIT;'
+ print ' mapping->explicit_flush = access & GL_MAP_FLUSH_EXPLICIT_BIT;'
+ print ' }'
+
+ boolean_names = [
+ 'GL_FALSE',
+ 'GL_TRUE',
+ ]
+
+ def gl_boolean(self, value):
+ return self.boolean_names[int(bool(value))]
+
+ # Names of the functions that unpack from a pixel buffer object. See the
+ # ARB_pixel_buffer_object specification.
+ unpack_function_names = set([
+ 'glBitmap',
+ 'glColorSubTable',
+ 'glColorTable',
+ 'glCompressedTexImage1D',
+ 'glCompressedTexImage2D',
+ 'glCompressedTexImage3D',
+ 'glCompressedTexSubImage1D',
+ 'glCompressedTexSubImage2D',
+ 'glCompressedTexSubImage3D',
+ 'glConvolutionFilter1D',
+ 'glConvolutionFilter2D',
+ 'glDrawPixels',
+ 'glMultiTexImage1DEXT',
+ 'glMultiTexImage2DEXT',
+ 'glMultiTexImage3DEXT',
+ 'glMultiTexSubImage1DEXT',
+ 'glMultiTexSubImage2DEXT',
+ 'glMultiTexSubImage3DEXT',
+ 'glPixelMapfv',
+ 'glPixelMapuiv',
+ 'glPixelMapusv',
+ 'glPolygonStipple',
+ 'glSeparableFilter2D',
+ 'glTexImage1D',
+ 'glTexImage1DEXT',
+ 'glTexImage2D',
+ 'glTexImage2DEXT',
+ 'glTexImage3D',
+ 'glTexImage3DEXT',
+ 'glTexSubImage1D',
+ 'glTexSubImage1DEXT',
+ 'glTexSubImage2D',
+ 'glTexSubImage2DEXT',
+ 'glTexSubImage3D',
+ 'glTexSubImage3DEXT',
+ 'glTextureImage1DEXT',
+ 'glTextureImage2DEXT',
+ 'glTextureImage3DEXT',
+ 'glTextureSubImage1DEXT',
+ 'glTextureSubImage2DEXT',
+ 'glTextureSubImage3DEXT',
+ ])
+