X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glretrace.py;h=97a6ecc1c8f07063c0ea24bf68168bbc2d09ccc4;hb=cbabe34c0bc4c5190f53c2b4e6991ad10ad36e44;hp=f3ae91bda830965e951e6b20c00ab7ae534c6998;hpb=a96b725fcfa0dbd20d27e7eef2ce04ca7a8bfdf1;p=apitrace diff --git a/glretrace.py b/glretrace.py index f3ae91b..97a6ecc 100644 --- a/glretrace.py +++ b/glretrace.py @@ -111,6 +111,8 @@ class GlRetracer(Retracer): ]) misc_draw_function_names = set([ + "glCallList", + "glCallLists", "glClear", "glEnd", "glDrawPixels", @@ -157,7 +159,8 @@ class GlRetracer(Retracer): 'glMapBufferOES', 'glMapBufferRange', 'glMapNamedBufferEXT', - 'glMapNamedBufferRangeEXT' + 'glMapNamedBufferRangeEXT', + 'glMapObjectBufferATI', ]) unmap_function_names = set([ @@ -165,6 +168,7 @@ class GlRetracer(Retracer): 'glUnmapBufferARB', 'glUnmapBufferOES', 'glUnmapNamedBufferEXT', + 'glUnmapObjectBufferATI', ]) def retraceFunctionBody(self, function): @@ -197,21 +201,12 @@ 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 ' assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);' - print ' if (glretrace::snapshot_frequency == glretrace::FREQUENCY_FRAMEBUFFER) {' - print ' glretrace::snapshot(call.no - 1);' - print ' }' if function.name == 'glFrameTerminatorGREMEDY': print ' glretrace::frame_complete(call);' return @@ -225,15 +220,27 @@ class GlRetracer(Retracer): print ' }' if is_draw_array or is_draw_elements or is_misc_draw: print ' assert(call.flags & trace::CALL_FLAG_RENDER);' - print ' if (glretrace::snapshot_frequency == glretrace::FREQUENCY_DRAW) {' - print ' glretrace::snapshot(call.no);' - print ' }' def invokeFunction(self, function): # Infer the drawable size from GL calls if function.name == "glViewport": print ' glretrace::updateDrawable(x + width, y + height);' + if function.name == "glViewportArray": + # We are concerned about drawables so only care for the first viewport + print ' if (first == 0 && count > 0) {' + print ' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];' + print ' glretrace::updateDrawable(x + w, y + h);' + print ' }' + if function.name == "glViewportIndexedf": + print ' if (index == 0) {' + print ' glretrace::updateDrawable(x + w, y + h);' + print ' }' + if function.name == "glViewportIndexedfv": + print ' if (index == 0) {' + print ' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];' + print ' glretrace::updateDrawable(x + w, y + h);' + print ' }' if function.name in ('glBlitFramebuffer', 'glBlitFramebufferEXT'): # Some applications do all their rendering in a framebuffer, and # then just blit to the drawable without ever calling glViewport. @@ -242,8 +249,35 @@ class GlRetracer(Retracer): if function.name == "glEnd": print ' glretrace::insideGlBeginEnd = false;' + if function.name.startswith('gl') and not function.name.startswith('glX'): + print r' if (!glretrace::context && !glretrace::benchmark && !retrace::profiling) {' + print r' retrace::warning(call) << "no current context\n";' + print r' }' + if function.name == 'memcpy': print ' if (!dest || !src || !n) return;' + + # 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);' + elif function.name == 'glUnmapObjectBufferATI': + # TODO + pass + else: + assert False + print r' if (ptr) {' + print r' retrace::delRegionByPointer(ptr);' + print r' } else {' + print r' retrace::warning(call) << "no current context\n";' + print r' }' Retracer.invokeFunction(self, function) @@ -252,7 +286,7 @@ class GlRetracer(Retracer): print ' glretrace::insideGlBeginEnd = true;' elif function.name.startswith('gl'): # glGetError is not allowed inside glBegin/glEnd - print ' if (!glretrace::benchmark && !glretrace::insideGlBeginEnd) {' + print ' if (!glretrace::benchmark && !retrace::profiling && !glretrace::insideGlBeginEnd) {' print ' glretrace::checkGlError(call);' if function.name in ('glProgramStringARB', 'glProgramStringNV'): print r' GLint error_position = -1;' @@ -309,6 +343,10 @@ class GlRetracer(Retracer): print r' if (!__result) {' print r' retrace::warning(call) << "failed to map buffer\n";' print r' }' + if function.name in self.unmap_function_names and function.type is not stdapi.Void: + print r' if (!__result) {' + print r' retrace::warning(call) << "failed to unmap buffer\n";' + print r' }' if function.name in ('glGetAttribLocation', 'glGetAttribLocationARB'): print r' GLint __orig_result = call.ret->toSInt();' print r' if (__result != __orig_result) {' @@ -322,37 +360,23 @@ class GlRetracer(Retracer): print r' }' print ' }' - # Query the buffer length for whole buffer mappings - if function.name in self.map_function_names: - 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);' - elif function.name == 'glMapNamedBufferEXT': - print r' glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);' - else: - assert False - # 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);' + # Query the buffer length for whole buffer mappings + if function.name in self.map_function_names: + 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);' + elif function.name == 'glMapNamedBufferEXT': + print r' glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);' + elif function.name == 'glMapObjectBufferATI': + print r' glGetObjectBufferivATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI, &length);' else: assert False - print r' if (ptr) {' - print r' retrace::delRegionByPointer(ptr);' - print r' }' def extractArg(self, function, arg, arg_type, lvalue, rvalue): if function.name in self.array_pointer_function_names and arg.name == 'pointer':