]> git.cworth.org Git - apitrace/commitdiff
Dump symbolic names in glTexEnv/Gen/Parameter and similar functions.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 26 Apr 2011 07:50:32 +0000 (08:50 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 26 Apr 2011 07:59:41 +0000 (08:59 +0100)
CMakeLists.txt
gltrace.py

index 27778573ea23f5019de33a2c2044edf87013bf68..fdf0f53eb5f2fea087180b2e03203b535118d959 100755 (executable)
@@ -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)
index 4d81d2e673f28a68fd32b1700c4bd8e7754845e5..dadb8f22369b97cf21c65ba937ca56dd3ee9d174 100644 (file)
@@ -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<class T>'
+        print 'static inline bool'
+        print 'is_symbolic_param(T param) {'
+        print '    return static_cast<T>(static_cast<GLenum>(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):