]> git.cworth.org Git - apitrace/blobdiff - gltrace.py
Add GL_ANY_SAMPLES_PASSED from occ_query2 to the list of enums.
[apitrace] / gltrace.py
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):