print ' VERTEX_ATTRIB_NV,'
print '};'
print
- print 'gltrace::Context *'
- print 'gltrace::getContext(void)'
- print '{'
- print ' // TODO return the context set by other APIs (GLX, EGL, and etc.)'
- print ' static gltrace::Context _ctx = { gltrace::PROFILE_COMPAT, false, false, false };'
- print ' return &_ctx;'
- print '}'
- print
print 'static vertex_attrib _get_vertex_attrib(void) {'
print ' gltrace::Context *ctx = gltrace::getContext();'
print ' if (ctx->user_arrays_arb || ctx->user_arrays_nv) {'
print '}'
print
+ self.defineShadowBufferHelper()
+
# Whether we need user arrays
print 'static inline bool _need_user_arrays(void)'
print '{'
print '}'
print
- print 'static void _trace_user_arrays(GLuint maxindex);'
+ print 'static void _trace_user_arrays(GLuint count);'
print
# Buffer mappings
else:
Tracer.traceApi(self, api)
+ def defineShadowBufferHelper(self):
+ print 'void _shadow_glGetBufferSubData(GLenum target, GLintptr offset,'
+ print ' GLsizeiptr size, GLvoid *data)'
+ print '{'
+ print ' struct gltrace::Context *ctx = gltrace::getContext();'
+ print ' if (!ctx->needsShadowBuffers() || target != GL_ELEMENT_ARRAY_BUFFER) {'
+ print ' _glGetBufferSubData(target, offset, size, data);'
+ print ' return;'
+ print ' }'
+ print
+ print ' GLint buffer_binding = 0;'
+ print ' _glGetIntegerv(target, &buffer_binding);'
+ print ' if (buffer_binding > 0) {'
+ print ' gltrace::Buffer & buf = ctx->buffers[buffer_binding];'
+ print ' buf.getSubData(offset, size, data);'
+ print ' }'
+ print '}'
+
+ def shadowBufferMethod(self, method):
+ # Emit code to fetch the shadow buffer, and invoke a method
+ print ' gltrace::Context *ctx = gltrace::getContext();'
+ print ' if (ctx->needsShadowBuffers() && target == GL_ELEMENT_ARRAY_BUFFER) {'
+ print ' GLint buffer_binding = 0;'
+ print ' _glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &buffer_binding);'
+ print ' if (buffer_binding > 0) {'
+ print ' gltrace::Buffer & buf = ctx->buffers[buffer_binding];'
+ print ' buf.' + method + ';'
+ print ' }'
+ print ' }'
+ print
+
+ def shadowBufferProlog(self, function):
+ if function.name == 'glBufferData':
+ self.shadowBufferMethod('bufferData(size, data)')
+
+ if function.name == 'glBufferSubData':
+ self.shadowBufferMethod('bufferSubData(offset, size, data)')
+
+ if function.name == 'glDeleteBuffers':
+ print ' gltrace::Context *ctx = gltrace::getContext();'
+ print ' if (ctx->needsShadowBuffers()) {'
+ print ' for (GLsizei i = 0; i < n; i++) {'
+ print ' ctx->buffers.erase(buffer[i]);'
+ print ' }'
+ print ' }'
+
array_pointer_function_names = set((
"glVertexPointer",
"glNormalPointer",
if function.name in self.draw_function_names:
print ' if (_need_user_arrays()) {'
arg_names = ', '.join([arg.name for arg in function.args[1:]])
- print ' GLuint maxindex = _%s_maxindex(%s);' % (function.name, arg_names)
- print ' _trace_user_arrays(maxindex);'
+ print ' GLuint _count = _%s_count(%s);' % (function.name, arg_names)
+ print ' _trace_user_arrays(_count);'
print ' }'
# Emit a fake memcpy on buffer uploads
print ' _glGetBufferParameteriv(target, GL_BUFFER_SIZE, &size);'
print ' if (map && size > 0) {'
self.emit_memcpy('map', 'map', 'size')
+ self.shadowBufferMethod('bufferSubData(0, size, map)')
print ' }'
print ' }'
if function.name == 'glUnmapNamedBufferEXT':
print ' }'
print ' }'
+ self.shadowBufferProlog(function)
+
Tracer.traceFunctionImplBody(self, function)
marker_functions = [
# A simple state tracker to track the pointer values
# update the state
- print 'static void _trace_user_arrays(GLuint maxindex)'
+ print 'static void _trace_user_arrays(GLuint count)'
print '{'
print ' gltrace::Context *ctx = gltrace::getContext();'
print ' _%s(%s, &%s);' % (arg_get_function, arg_get_enum, arg.name)
arg_names = ', '.join([arg.name for arg in function.args[:-1]])
- print ' size_t _size = _%s_size(%s, maxindex);' % (function.name, arg_names)
+ print ' size_t _size = _%s_size(%s, count);' % (function.name, arg_names)
# Emit a fake function
self.array_trace_intermezzo(api, uppercase_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)
+ print ' size_t _size = _%s_size(%s, count);' % (function.name, arg_names)
# Emit a fake function
print ' unsigned _call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
function = api.getFunctionByName('glClientActiveTexture')
self.fake_call(function, [texture])
- def fake_call(self, function, args):
- print ' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
- for arg, instance in zip(function.args, args):
- assert not arg.output
- print ' trace::localWriter.beginArg(%u);' % (arg.index,)
- self.serializeValue(arg.type, instance)
- print ' trace::localWriter.endArg();'
- print ' trace::localWriter.endEnter();'
- print ' trace::localWriter.beginLeave(_fake_call);'
- print ' trace::localWriter.endLeave();'