]> git.notmuchmail.org Git - apitrace/commitdiff
Initial stab at glDrawArrays implementation.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 20 Feb 2011 09:05:10 +0000 (09:05 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 22 Feb 2011 07:15:58 +0000 (07:15 +0000)
CMakeLists.txt
gltrace.py [new file with mode: 0644]
glxtrace.py
wgltrace.py

index 9da61a1d5a01cc7563a04548eaab311a8b643d58..848d7379411274b740005adf8b3234ec6d5ebafb 100644 (file)
@@ -166,7 +166,7 @@ if (WIN32)
     add_custom_command (
         OUTPUT wgltrace.cpp
         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
-        DEPENDS wgltrace.py trace.py wglapi.py glapi.py glenum.py winapi.py stdapi.py
+        DEPENDS wgltrace.py gltrace.py trace.py wglapi.py glapi.py glenum.py winapi.py stdapi.py
     )
     add_library (opengl SHARED opengl32.def wgltrace.cpp trace_write.cpp os_win32.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
     set_target_properties (opengl PROPERTIES
@@ -182,7 +182,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 trace.py glxapi.py glapi.py glenum.py stdapi.py
+        DEPENDS glxtrace.py gltrace.py trace.py glxapi.py glapi.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
new file mode 100644 (file)
index 0000000..9a7c2f2
--- /dev/null
@@ -0,0 +1,129 @@
+##########################################################################
+#
+# Copyright 2008-2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""GL tracing generator."""
+
+
+from glxapi import glxapi
+from trace import Tracer, dump_instance
+
+
+class GlTracer(Tracer):
+
+    pointer_function_names = {
+        "glVertexPointer": "VertexPointer",
+        "glVertexPointerEXT": "VertexPointer",
+        "glNormalPointer": "NormalPointer",
+        "glNormalPointerEXT": "NormalPointer",
+        "glColorPointer": "ColorPointer",
+        "glColorPointerEXT": "ColorPointer",
+        "glIndexPointer": "IndexPointer",
+        "glIndexPointerEXT": "IndexPointer",
+        "glTexCoordPointer": "TexCoordPointer",
+        "glTexCoordPointerEXT": "TexCoordPointer",
+        "glEdgeFlagPointer": "EdgeFlagPointer",
+        "glEdgeFlagPointerEXT": "EdgeFlagPointer",
+        "glFogCoordPointer": "FogCoordPointer",
+        "glFogCoordPointerEXT": "FogCoordPointer",
+        "glSecondaryColorPointer": "SecondaryColorPointer",
+        "glSecondaryColorPointerEXT": "SecondaryColorPointer",
+        "glInterleavedArrays": "InterleavedArrays",
+
+        #"glVertexAttribPointer": "VertexAttribPointer",
+        #"glVertexAttribPointerARB": "VertexAttribPointer",
+        #"glVertexAttribPointerNV": "VertexAttribPointer",
+        #"glVertexAttribLPointer": "VertexAttribLPointer",
+        
+        #"glMatrixIndexPointerARB": "MatrixIndexPointer",
+    }
+
+    def header(self, api):
+        Tracer.header(self, api)
+        self.state_tracker_decl(api)
+
+    def footer(self, api):
+        Tracer.footer(self, api)
+        self.state_tracker_impl(api)
+
+    def state_tracker_decl(self, api):
+        # A simple state tracker to track the pointer values
+
+        atoms = list(set(self.pointer_function_names.itervalues()))
+        atoms.sort()
+
+        # define the NEW_XXXX dirty flags
+        for i in range(len(atoms)):
+            atom = atoms[i]
+            dirtyflag = "NEW_%s" % atom.upper()
+            print '#define %s 0x%x' % (dirtyflag, 1 << i)
+        print
+
+        # declare the state structure
+        print 'struct {'
+        for atom in atoms:
+            function = api.get_function_by_name('gl%s' % atom)
+            print '    struct {'
+            for arg in function.args:
+                print '        %s %s;' % (arg.type, arg.name)
+            print '    } %s;' % atom
+        print '    unsigned dirty;'
+        print '} __state;'
+        print
+
+    def state_tracker_impl(self, api):
+        # A simple state tracker to track the pointer values
+
+        atoms = list(set(self.pointer_function_names.itervalues()))
+        atoms.sort()
+
+        # update the state
+        print 'void __state_update(GLsizei )'
+        print '{'
+        print '    GLint __array_buffer = 0;'
+        print '    glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);'
+        for atom in atoms:
+            function = api.get_function_by_name('gl%s' % atom)
+            dirtyflag = "NEW_%s" % atom.upper()
+            print '    if (__state.dirty & %s) {' % dirtyflag
+            print '        unsigned __call = Trace::BeginEnter(__%s_sig);' % (function.name,)
+            for arg in function.args:
+                assert not arg.output
+                print '        Trace::BeginArg(%u);' % (arg.index,)
+                dump_instance(arg.type, '__state.%s.%s' % (atom, arg.name))
+                print '        Trace::EndArg();'
+            print '        Trace::EndEnter();'
+            print '        Trace::BeginLeave(__call);'
+            print '        Trace::EndLeave();'
+            print '    }'
+        print '}'
+        print
+
+
+
+
+
+
+
index bd86e5b35538ce95760d5afedc8093f05c5635d0..04680dae44a590e3de64e40a5f1d093dd9df6f10 100644 (file)
 from stdapi import API
 from glapi import glapi
 from glxapi import glxapi
-from trace import Tracer
+from gltrace import GlTracer
 
 
-class GlxTracer(Tracer):
+class GlxTracer(GlTracer):
 
     def get_function_address(self, function):
         return '__%s' % (function.name,)
index 5c860d79ab99fb855aace1cb6da4722c47df6c9a..a1c66bb69b8fb0e989d6de0964eee7729d1f1ff2 100644 (file)
@@ -30,7 +30,7 @@
 from stdapi import API
 from glapi import glapi
 from wglapi import wglapi
-from trace import Tracer
+from gltrace import GlTracer
 from codegen import *
 
 
@@ -399,7 +399,7 @@ public_symbols = set([
        "wglUseFontOutlinesW",
 ])
 
-class WglTracer(Tracer):
+class WglTracer(GlTracer):
 
     def get_function_address(self, function):
         return '__%s' % (function.name,)