From: José Fonseca Date: Tue, 26 Apr 2011 07:50:32 +0000 (+0100) Subject: Dump symbolic names in glTexEnv/Gen/Parameter and similar functions. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=a3f89ae8128e4beb4f4a23ea76928884a73fd806;p=apitrace Dump symbolic names in glTexEnv/Gen/Parameter and similar functions. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2777857..fdf0f53 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -207,7 +207,7 @@ else () add_custom_command ( OUTPUT glxtrace.cpp COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp - DEPENDS glxtrace.py gltrace.py trace.py glxapi.py glapi.py glenum.py stdapi.py + DEPENDS glxtrace.py gltrace.py trace.py glxapi.py glapi.py glstate.py glenum.py stdapi.py ) add_library (glxtrace SHARED glxtrace.cpp trace_write.cpp os_posix.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp) diff --git a/gltrace.py b/gltrace.py index 4d81d2e..dadb8f2 100644 --- a/gltrace.py +++ b/gltrace.py @@ -29,6 +29,7 @@ import stdapi import glapi +import glstate from glxapi import glxapi from trace import Tracer, dump_instance @@ -176,6 +177,29 @@ class GlTracer(Tracer): # Generate memcpy's signature self.trace_function_decl(glapi.memcpy) + + # Generate a helper function to determine whether a parameter name + # refers to a symbolic value or not + print 'static bool' + print 'is_symbolic_pname(GLenum pname) {' + print ' switch(pname) {' + for function, type, count, name in glstate.parameters: + if type is glapi.GLenum: + print ' case %s: return true;' % name + print ' default: return false;' + print ' }' + print '}' + print + + # Generate a helper function to determine whether a parameter value is + # potentially symbolic or not; i.e., if the value can be represented in + # an enum or not + print 'template' + print 'static inline bool' + print 'is_symbolic_param(T param) {' + print ' return static_cast(static_cast(param)) == param;' + print '}' + print array_pointer_function_names = set(( "glVertexPointer", @@ -363,6 +387,19 @@ class GlTracer(Tracer): print ' }' return + # Several GL state functions take GLenum symbolic names as + # integer/floats; so dump the symbolic name whenever possible + if arg.type in (glapi.GLint, glapi.GLfloat) and arg.name == 'param': + assert arg.index > 0 + assert function.args[arg.index - 1].name == 'pname' + assert function.args[arg.index - 1].type == glapi.GLenum + print ' if (is_symbolic_pname(pname) && is_symbolic_param(%s)) {' % arg.name + dump_instance(glapi.GLenum, arg.name) + print ' } else {' + Tracer.dump_arg_instance(self, function, arg) + print ' }' + return + Tracer.dump_arg_instance(self, function, arg) def state_tracker_impl(self, api):