+ print ' size_t __size = __%s_size(%s, maxindex);' % (function.name, arg_names)
+
+ # Emit a fake function
+ self.array_trace_intermezzo(api, uppercase_name)
+ print ' unsigned __call = trace::localWriter.beginEnter(&__%s_sig);' % (function.name,)
+ for arg in function.args:
+ assert not arg.output
+ print ' trace::localWriter.beginArg(%u);' % (arg.index,)
+ if arg.name != 'pointer':
+ self.serializeValue(arg.type, arg.name)
+ else:
+ print ' trace::localWriter.writeBlob((const void *)%s, __size);' % (arg.name)
+ print ' trace::localWriter.endArg();'
+
+ print ' trace::localWriter.endEnter();'
+ print ' trace::localWriter.beginLeave(__call);'
+ print ' trace::localWriter.endLeave();'
+ print ' }'
+ print ' }'
+ self.array_epilog(api, uppercase_name)
+ self.array_trace_epilog(api, uppercase_name)
+ print ' }'
+ print
+
+ # Samething, but for glVertexAttribPointer*
+ #
+ # Some variants of glVertexAttribPointer alias conventional and generic attributes:
+ # - glVertexAttribPointer: no
+ # - glVertexAttribPointerARB: implementation dependent
+ # - glVertexAttribPointerNV: yes
+ #
+ # This means that the implementations of these functions do not always
+ # alias, and they need to be considered independently.
+ #
+ print ' // ES1 does not support generic vertex attributes'
+ print ' if (ctx->profile == gltrace::PROFILE_ES1)'
+ print ' return;'
+ print
+ print ' vertex_attrib __vertex_attrib = __get_vertex_attrib();'
+ print
+ for suffix in ['', 'ARB', 'NV']:
+ if suffix:
+ SUFFIX = '_' + suffix
+ else:
+ SUFFIX = suffix
+ function_name = 'glVertexAttribPointer' + suffix
+ function = api.get_function_by_name(function_name)
+
+ print ' // %s' % function.prototype()
+ print ' if (__vertex_attrib == VERTEX_ATTRIB%s) {' % SUFFIX
+ if suffix == 'NV':
+ print ' GLint __max_vertex_attribs = 16;'
+ else:
+ print ' GLint __max_vertex_attribs = 0;'
+ print ' __glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &__max_vertex_attribs);'
+ print ' for (GLint index = 0; index < __max_vertex_attribs; ++index) {'
+ print ' GLint __enabled = 0;'
+ if suffix == 'NV':
+ print ' __glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY0_NV + index, &__enabled);'
+ else:
+ print ' __glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED%s, &__enabled);' % (suffix, SUFFIX)
+ print ' if (__enabled) {'
+ print ' GLint __binding = 0;'
+ if suffix != 'NV':
+ # It doesn't seem possible to use VBOs with NV_vertex_program.
+ print ' __glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING%s, &__binding);' % (suffix, SUFFIX)
+ print ' if (!__binding) {'
+
+ # Get the arguments via glGet*
+ for arg in function.args[1:]:
+ if suffix == 'NV':
+ arg_get_enum = 'GL_ATTRIB_ARRAY_%s%s' % (arg.name.upper(), SUFFIX)
+ else:
+ arg_get_enum = 'GL_VERTEX_ATTRIB_ARRAY_%s%s' % (arg.name.upper(), SUFFIX)
+ arg_get_function, arg_type = TypeGetter('glGetVertexAttrib', False, suffix).visit(arg.type)
+ print ' %s %s = 0;' % (arg_type, arg.name)
+ print ' __%s(index, %s, &%s);' % (arg_get_function, arg_get_enum, arg.name)
+
+ arg_names = ', '.join([arg.name for arg in function.args[1:-1]])
+ print ' size_t __size = __%s_size(%s, maxindex);' % (function.name, arg_names)