]> git.cworth.org Git - apitrace/commitdiff
Handle more calls correctly.
authorJosé Fonseca <jfonseca@vmware.com>
Sun, 21 Nov 2010 01:53:58 +0000 (01:53 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Sun, 21 Nov 2010 01:53:58 +0000 (01:53 +0000)
glhelpers.hpp
glretrace.py
glx.py

index cfd9545993aae289123b3066a4e26b18db6dda84..99df9dd048ffd4801d9f7255673bf5b132f670eb 100644 (file)
 
 #include <cassert>
 
+static inline size_t
+__gl_calllists_size(GLsizei n, GLenum type)
+{
+   size_t bytes;
+   switch(type) {
+   case GL_BYTE:
+   case GL_UNSIGNED_BYTE:
+      bytes = 1;
+      break;
+   case GL_2_BYTES:
+   case GL_SHORT:
+   case GL_UNSIGNED_SHORT:
+      bytes = 2;
+      break;
+   case GL_3_BYTES:
+      bytes = 3;
+      break;
+   case GL_4_BYTES:
+   case GL_INT:
+   case GL_UNSIGNED_INT:
+   case GL_FLOAT:
+      bytes = 4;
+      break;
+   default:
+      assert(0);
+      bytes = 1;
+   }
+
+   return n*bytes;
+}
+
 static inline size_t
 __gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLint border) {
    size_t num_channels;
@@ -111,4 +142,9 @@ __gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsiz
    return depth*slice_stride;
 }
 
+static inline size_t
+__gl_bitmap_size(GLsizei width, GLsizei height) {
+   return __gl_image_size(GL_COLOR_INDEX, GL_BITMAP, width, height, 1, 0);
+}
+
 #endif /* _GL_HELPERS_HPP_ */
index d8a38610c40348f9e54e6ca083f0ffa32804e897..e6c3fb8109f7a5cc0c92a9d7c7e3cf049edebe11 100644 (file)
@@ -37,17 +37,17 @@ class ConstRemover(base.Rebuilder):
 
 class ValueExtractor(base.Visitor):
 
-    def visit_literal(self, type, lvalue, rvalue):
+    def visit_literal(self, literal, lvalue, rvalue):
         print '    %s = %s;' % (lvalue, rvalue)
 
-    def visit_alias(self, type, lvalue, rvalue):
-        self.visit(type.type, lvalue, rvalue)
+    def visit_alias(self, alias, lvalue, rvalue):
+        self.visit(alias.type, lvalue, rvalue)
     
-    def visit_enum(self, type, lvalue, rvalue):
+    def visit_enum(self, enum, lvalue, rvalue):
         print '    %s = %s;' % (lvalue, rvalue)
 
-    def visit_bitmask(self, type, lvalue, rvalue):
-        self.visit(type.type, lvalue, rvalue)
+    def visit_bitmask(self, bitmask, lvalue, rvalue):
+        self.visit(bitmask.type, lvalue, rvalue)
 
     def visit_array(self, array, lvalue, rvalue):
         print '    %s = new %s[%s];' % (lvalue, array.type, array.length)
@@ -56,8 +56,8 @@ class ValueExtractor(base.Visitor):
         self.visit(array.type, '%s[%s]' % (lvalue, index), '%s[%s]' % (rvalue, index))
         print '    }'
 
-    def visit_blob(self, type, lvalue, rvalue):
-        print '    %s = %s;' % (lvalue, rvalue)
+    def visit_blob(self, blob, lvalue, rvalue):
+        print '    %s = (%s)(void *)%s;' % (lvalue, blob, rvalue)
 
 
 
diff --git a/glx.py b/glx.py
index 30ae7b9aa7d7c6aad8a4f07105c2fa07ea1efa88..f2285772b66bd3af38975bae67c966ab28b71a2c 100644 (file)
--- a/glx.py
+++ b/glx.py
@@ -31,12 +31,12 @@ libgl.functions += [
     DllFunction(Void, "glNewList", [(GLuint, "list"), (GLenum, "mode")]),
     DllFunction(Void, "glEndList", []),
     DllFunction(Void, "glCallList", [(GLuint, "list")]),
-    DllFunction(Void, "glCallLists", [(GLsizei, "n"), (GLenum, "type"), (Pointer(Const(GLvoid)), "lists")]),
+    DllFunction(Void, "glCallLists", [(GLsizei, "n"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_calllists_size(n, type)"), "lists")]),
     DllFunction(Void, "glDeleteLists", [(GLuint, "list"), (GLsizei, "range")]),
     DllFunction(GLuint, "glGenLists", [(GLsizei, "range")]),
     DllFunction(Void, "glListBase", [(GLuint, "base")]),
     DllFunction(Void, "glBegin", [(GLprimenum, "mode")]),
-    DllFunction(Void, "glBitmap", [(GLsizei, "width"), (GLsizei, "height"), (GLfloat, "xorig"), (GLfloat, "yorig"), (GLfloat, "xmove"), (GLfloat, "ymove"), (Pointer(Const(GLubyte)), "bitmap")]),
+    DllFunction(Void, "glBitmap", [(GLsizei, "width"), (GLsizei, "height"), (GLfloat, "xorig"), (GLfloat, "yorig"), (GLfloat, "xmove"), (GLfloat, "ymove"), (Blob(Const(GLubyte), "__gl_bitmap_size(width, height)"), "bitmap")]),
     DllFunction(Void, "glColor3b", [(GLbyte, "red"), (GLbyte, "green"), (GLbyte, "blue")]),
     DllFunction(Void, "glColor3bv", [(Array(Const(GLbyte), "3"), "v")]),
     DllFunction(Void, "glColor3d", [(GLdouble, "red"), (GLdouble, "green"), (GLdouble, "blue")]),
@@ -182,9 +182,9 @@ libgl.functions += [
     DllFunction(Void, "glColorMaterial", [(GLenum, "face"), (GLenum, "mode")]),
     DllFunction(Void, "glCullFace", [(GLenum, "mode")]),
     DllFunction(Void, "glFogf", [(GLenum, "pname"), (GLfloat, "param")]),
-    DllFunction(Void, "glFogfv", [(GLenum, "pname"), (Pointer(Const(GLfloat)), "params")]),
+    DllFunction(Void, "glFogfv", [(GLenum, "pname"), (Array(Const(GLfloat), "(pname == GL_FOG_COLOR ? 4 : 1)"), "params")]),
     DllFunction(Void, "glFogi", [(GLenum, "pname"), (GLint, "param")]),
-    DllFunction(Void, "glFogiv", [(GLenum, "pname"), (Pointer(Const(GLint)), "params")]),
+    DllFunction(Void, "glFogiv", [(GLenum, "pname"), (Array(Const(GLint), "(pname == GL_FOG_COLOR ? 4 : 1)"), "params")]),
     DllFunction(Void, "glFrontFace", [(GLenum, "mode")]),
     DllFunction(Void, "glHint", [(GLenum, "target"), (GLenum, "mode")]),
     DllFunction(Void, "glLightf", [(GLenum, "light"), (GLenum, "pname"), (GLfloat, "param")]),
@@ -203,27 +203,27 @@ libgl.functions += [
     DllFunction(Void, "glMaterialiv", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLint), "4"), "params")]), # XXX
     DllFunction(Void, "glPointSize", [(GLfloat, "size")]),
     DllFunction(Void, "glPolygonMode", [(GLenum, "face"), (GLenum, "mode")]),
-    DllFunction(Void, "glPolygonStipple", [(Pointer(Const(GLubyte)), "mask")]),
+    DllFunction(Void, "glPolygonStipple", [(Blob(Const(GLubyte), "__gl_bitmap_size(32, 32)"), "mask")]),
     DllFunction(Void, "glScissor", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
     DllFunction(Void, "glShadeModel", [(GLenum, "mode")]),
     DllFunction(Void, "glTexParameterf", [(GLenum, "target"), (GLenum, "pname"), (GLfloat, "param")]),
-    DllFunction(Void, "glTexParameterfv", [(GLenum, "target"), (GLenum, "pname"), (Pointer(Const(GLfloat)), "params")]),
+    DllFunction(Void, "glTexParameterfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "(pname == GL_TEXTURE_BORDER_COLOR ? 4 : 1)"), "params")]),
     DllFunction(Void, "glTexParameteri", [(GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
-    DllFunction(Void, "glTexParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Pointer(Const(GLint)), "params")]),
+    DllFunction(Void, "glTexParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "(pname == GL_TEXTURE_BORDER_COLOR ? 4 : 1)"), "params")]),
     DllFunction(Void, "glTexImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_image_size(format, type, width, 1, 1, border)"), "pixels")]),
     DllFunction(Void, "glTexImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_image_size(format, type, width, height, 1, border)"), "pixels")]),
     DllFunction(Void, "glTexEnvf", [(GLenum, "target"), (GLenum, "pname"), (GLfloat, "param")]),
-    DllFunction(Void, "glTexEnvfv", [(GLenum, "target"), (GLenum, "pname"), (Pointer(Const(GLfloat)), "params")]),
+    DllFunction(Void, "glTexEnvfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "(pname == GL_TEXTURE_ENV_COLOR ? 4 : 1)"), "params")]),
     DllFunction(Void, "glTexEnvi", [(GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
-    DllFunction(Void, "glTexEnviv", [(GLenum, "target"), (GLenum, "pname"), (Pointer(Const(GLint)), "params")]),
+    DllFunction(Void, "glTexEnviv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "(pname == GL_TEXTURE_ENV_COLOR ? 4 : 1)"), "params")]),
     DllFunction(Void, "glTexGend", [(GLenum, "coord"), (GLenum, "pname"), (GLdouble, "param")]),
     DllFunction(Void, "glTexGendv", [(GLenum, "coord"), (GLenum, "pname"), (Pointer(Const(GLdouble)), "params")]),
     DllFunction(Void, "glTexGenf", [(GLenum, "coord"), (GLenum, "pname"), (GLfloat, "param")]),
     DllFunction(Void, "glTexGenfv", [(GLenum, "coord"), (GLenum, "pname"), (Pointer(Const(GLfloat)), "params")]),
     DllFunction(Void, "glTexGeni", [(GLenum, "coord"), (GLenum, "pname"), (GLint, "param")]),
     DllFunction(Void, "glTexGeniv", [(GLenum, "coord"), (GLenum, "pname"), (Pointer(Const(GLint)), "params")]),
-    DllFunction(Void, "glFeedbackBuffer", [(GLsizei, "size"), (GLenum, "type"), (OutPointer(GLfloat), "buffer")]),
-    DllFunction(Void, "glSelectBuffer", [(GLsizei, "size"), (OutPointer(GLuint), "buffer")]),
+    DllFunction(Void, "glFeedbackBuffer", [(GLsizei, "size"), (GLenum, "type"), (OutArray(GLfloat, "size"), "buffer")]),
+    DllFunction(Void, "glSelectBuffer", [(GLsizei, "size"), (OutArray(GLuint, "size"), "buffer")]),
     DllFunction(GLint, "glRenderMode", [(GLenum, "mode")]),
     DllFunction(Void, "glInitNames", []),
     DllFunction(Void, "glLoadName", [(GLuint, "name")]),
@@ -279,9 +279,9 @@ libgl.functions += [
     DllFunction(Void, "glPixelTransferi", [(GLenum, "pname"), (GLint, "param")]),
     DllFunction(Void, "glPixelStoref", [(GLenum, "pname"), (GLfloat, "param")]),
     DllFunction(Void, "glPixelStorei", [(GLenum, "pname"), (GLint, "param")]),
-    DllFunction(Void, "glPixelMapfv", [(GLenum, "map"), (GLsizei, "mapsize"), (Pointer(Const(GLfloat)), "values")]),
-    DllFunction(Void, "glPixelMapuiv", [(GLenum, "map"), (GLsizei, "mapsize"), (Pointer(Const(GLuint)), "values")]),
-    DllFunction(Void, "glPixelMapusv", [(GLenum, "map"), (GLsizei, "mapsize"), (Pointer(Const(GLushort)), "values")]),
+    DllFunction(Void, "glPixelMapfv", [(GLenum, "map"), (GLsizei, "mapsize"), (Array(Const(GLfloat), "mapsize"), "values")]),
+    DllFunction(Void, "glPixelMapuiv", [(GLenum, "map"), (GLsizei, "mapsize"), (Array(Const(GLuint), "mapsize"), "values")]),
+    DllFunction(Void, "glPixelMapusv", [(GLenum, "map"), (GLsizei, "mapsize"), (Array(Const(GLushort), "mapsize"), "values")]),
     DllFunction(Void, "glReadBuffer", [(GLenum, "mode")]),
     DllFunction(Void, "glCopyPixels", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "type")]),
     DllFunction(Void, "glReadPixels", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (OutPointer(GLvoid), "pixels")]),
@@ -355,13 +355,13 @@ libgl.functions += [
     DllFunction(Void, "glCopyTexImage2D", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border")]),
     DllFunction(Void, "glCopyTexSubImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
     DllFunction(Void, "glCopyTexSubImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
-    DllFunction(Void, "glDeleteTextures", [(GLsizei, "n"), (Pointer(Const(GLuint)), "textures")]),
-    DllFunction(Void, "glGenTextures", [(GLsizei, "n"), (OutPointer(GLuint), "textures")]),
+    DllFunction(Void, "glDeleteTextures", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "textures")]),
+    DllFunction(Void, "glGenTextures", [(GLsizei, "n"), (OutArray(GLuint, "n"), "textures")]),
     DllFunction(Void, "glGetPointerv", [(GLenum, "pname"), (OutPointer(Pointer(GLvoid)), "params")]),
     DllFunction(GLboolean, "glIsTexture", [(GLuint, "texture")]),
-    DllFunction(Void, "glPrioritizeTextures", [(GLsizei, "n"), (Pointer(Const(GLuint)), "textures"), (Pointer(Const(GLclampf)), "priorities")]),
-    DllFunction(Void, "glTexSubImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Pointer(Const(GLvoid)), "pixels")]),
-    DllFunction(Void, "glTexSubImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Pointer(Const(GLvoid)), "pixels")]),
+    DllFunction(Void, "glPrioritizeTextures", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "textures"), (Array(Const(GLclampf), "n"), "priorities")]),
+    DllFunction(Void, "glTexSubImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_image_size(format, type, width, 1, 1, 0)"), "pixels")]),
+    DllFunction(Void, "glTexSubImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_image_size(format, type, width, height, 1, 0)"), "pixels")]),
     DllFunction(Void, "glPopClientAttrib", []),
     DllFunction(Void, "glPushClientAttrib", [(GLbitfield, "mask")]),
     DllFunction(Void, "glBlendColor", [(GLclampf, "red"), (GLclampf, "green"), (GLclampf, "blue"), (GLclampf, "alpha")]),