X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glretrace.py;h=7570ebde957822cab1a3f35ae606e7be549cbfa9;hb=225193db0f50a8f3a1d59d7cff351c9be31e8044;hp=e80fedbaf852565e2c7c820c92744f054b47094c;hpb=46a4839cd1b65981bec9f33b1d7978b821866a51;p=apitrace diff --git a/glretrace.py b/glretrace.py index e80fedb..7570ebd 100644 --- a/glretrace.py +++ b/glretrace.py @@ -29,6 +29,7 @@ import specs.stdapi as stdapi import specs.glapi as glapi +import specs.glesapi as glesapi from retrace import Retracer @@ -36,8 +37,8 @@ class GlRetracer(Retracer): table_name = 'glretrace::gl_callbacks' - def retrace_function(self, function): - Retracer.retrace_function(self, function) + def retraceFunction(self, function): + Retracer.retraceFunction(self, function) array_pointer_function_names = set(( "glVertexPointer", @@ -119,8 +120,8 @@ class GlRetracer(Retracer): bind_framebuffer_function_names = set([ "glBindFramebuffer", - "glBindFramebufferARB", "glBindFramebufferEXT", + "glBindFramebufferOES", ]) # Names of the functions that can pack into the current pixel buffer @@ -153,6 +154,7 @@ class GlRetracer(Retracer): map_function_names = set([ 'glMapBuffer', 'glMapBufferARB', + 'glMapBufferOES', 'glMapBufferRange', 'glMapNamedBufferEXT', 'glMapNamedBufferRangeEXT' @@ -161,10 +163,11 @@ class GlRetracer(Retracer): unmap_function_names = set([ 'glUnmapBuffer', 'glUnmapBufferARB', + 'glUnmapBufferOES', 'glUnmapNamedBufferEXT', ]) - def retrace_function_body(self, function): + def retraceFunctionBody(self, function): is_array_pointer = function.name in self.array_pointer_function_names is_draw_array = function.name in self.draw_array_function_names is_draw_elements = function.name in self.draw_elements_function_names @@ -177,14 +180,14 @@ class GlRetracer(Retracer): print ' GLint __array_buffer = 0;' print ' glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);' print ' if (!__array_buffer) {' - self.fail_function(function) + self.failFunction(function) print ' }' if is_draw_elements: print ' GLint __element_array_buffer = 0;' print ' glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &__element_array_buffer);' print ' if (!__element_array_buffer) {' - self.fail_function(function) + self.failFunction(function) print ' }' print ' }' @@ -194,38 +197,28 @@ class GlRetracer(Retracer): print ' GLint __pack_buffer = 0;' print ' glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &__pack_buffer);' print ' if (!__pack_buffer) {' - if function.name == 'glReadPixels': - print ' glFinish();' - print ' if (glretrace::snapshot_frequency == glretrace::FREQUENCY_FRAME ||' - print ' glretrace::snapshot_frequency == glretrace::FREQUENCY_FRAMEBUFFER) {' - print ' glretrace::snapshot(call.no);' - print ' }' print ' return;' print ' }' # Pre-snapshots if function.name in self.bind_framebuffer_function_names: - print ' if (glretrace::snapshot_frequency == glretrace::FREQUENCY_FRAMEBUFFER) {' - print ' glretrace::snapshot(call.no - 1);' - print ' }' + print ' assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);' if function.name == 'glFrameTerminatorGREMEDY': - print ' glretrace::frame_complete(call.no);' + print ' glretrace::frame_complete(call);' return - Retracer.retrace_function_body(self, function) + Retracer.retraceFunctionBody(self, function) # Post-snapshots if function.name in ('glFlush', 'glFinish'): print ' if (!glretrace::double_buffer) {' - print ' glretrace::frame_complete(call.no);' + print ' glretrace::frame_complete(call);' print ' }' if is_draw_array or is_draw_elements or is_misc_draw: - print ' if (glretrace::snapshot_frequency == glretrace::FREQUENCY_DRAW) {' - print ' glretrace::snapshot(call.no);' - print ' }' + print ' assert(call.flags & trace::CALL_FLAG_RENDER);' - def call_function(self, function): + def invokeFunction(self, function): # Infer the drawable size from GL calls if function.name == "glViewport": print ' glretrace::updateDrawable(x + width, y + height);' @@ -240,7 +233,7 @@ class GlRetracer(Retracer): if function.name == 'memcpy': print ' if (!dest || !src || !n) return;' - Retracer.call_function(self, function) + Retracer.invokeFunction(self, function) # Error checking if function.name == "glBegin": @@ -317,28 +310,30 @@ class GlRetracer(Retracer): print r' }' print ' }' - # Update buffer mappings + # Query the buffer length for whole buffer mappings if function.name in self.map_function_names: - print r' if (__result) {' - print r' unsigned long long __address = call.ret->toUIntPtr();' - if 'BufferRange' not in function.name: - print r' GLint length = 0;' - if function.name == 'glMapBuffer': - print r' glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);' + if 'length' in function.argNames(): + assert 'BufferRange' in function.name + else: + assert 'BufferRange' not in function.name + print r' GLint length = 0;' + if function.name in ('glMapBuffer', 'glMapBufferOES'): + print r' glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);' elif function.name == 'glMapBufferARB': - print r' glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);' + print r' glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);' elif function.name == 'glMapNamedBufferEXT': - print r' glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);' + print r' glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);' else: assert False - print r' retrace::addRegion(__address, __result, length);' - print r' }' + # Destroy the buffer mapping if function.name in self.unmap_function_names: print r' GLvoid *ptr = NULL;' if function.name == 'glUnmapBuffer': print r' glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);' elif function.name == 'glUnmapBufferARB': print r' glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);' + elif function.name == 'glUnmapBufferOES': + print r' glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);' elif function.name == 'glUnmapNamedBufferEXT': print r' glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);' else: @@ -347,32 +342,32 @@ class GlRetracer(Retracer): print r' retrace::delRegionByPointer(ptr);' print r' }' - def extract_arg(self, function, arg, arg_type, lvalue, rvalue): + def extractArg(self, function, arg, arg_type, lvalue, rvalue): if function.name in self.array_pointer_function_names and arg.name == 'pointer': print ' %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue) return if function.name in self.draw_elements_function_names and arg.name == 'indices' or\ function.name in self.draw_indirect_function_names and arg.name == 'indirect': - self.extract_opaque_arg(function, arg, arg_type, lvalue, rvalue) + self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue) return # Handle pointer with offsets into the current pack pixel buffer # object. if function.name in self.pack_function_names and arg.output: - self.extract_opaque_arg(function, arg, arg_type, lvalue, rvalue) + self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue) return if arg.type is glapi.GLlocation \ - and 'program' not in [arg.name for arg in function.args]: + and 'program' not in function.argNames(): print ' GLint program = -1;' print ' glGetIntegerv(GL_CURRENT_PROGRAM, &program);' if arg.type is glapi.GLlocationARB \ - and 'programObj' not in [arg.name for arg in function.args]: + and 'programObj' not in function.argNames(): print ' GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);' - Retracer.extract_arg(self, function, arg, arg_type, lvalue, rvalue) + Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue) # Don't try to use more samples than the implementation supports if arg.name == 'samples': @@ -395,5 +390,6 @@ if __name__ == '__main__': ''' api = glapi.glapi + api.addApi(glesapi.glesapi) retracer = GlRetracer() - retracer.retrace_api(api) + retracer.retraceApi(api)