]> git.tdb.fi Git - gldbg.git/commitdiff
Fix some array size calculations
authorMikko Rasa <tdb@tdb.fi>
Sat, 7 Nov 2009 12:38:02 +0000 (12:38 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sat, 7 Nov 2009 12:38:02 +0000 (12:38 +0000)
genwrap.py
source/arraysize.c
source/arraysize.h

index 1ee97cef332853da9e6c8ffb0d5033e7ae980b7f..07dd914f09d20b9a5bcda4adf6fa2000f33caf52 100755 (executable)
@@ -142,10 +142,17 @@ class Function:
                                        self.csize = "paramsize(pname)*sizeof(%s)"%self.base_ctype
                                else:
                                        s = self.func.get_param(self.size.split('*')[0])
-                                       if (s.type=="SizeI" or s.type.endswith("Int32") or s.type.startswith("BufferSize")) and s.kind=="value":
-                                               self.csize = "%s*sizeof(%s)"%(self.size, self.base_ctype)
-                                               if self.func.name.startswith("Uniform") and self.func.name[7].isdigit():
-                                                       self.csize += "*%s"%func.name[7]
+                                       if (s.type=="SizeI" or s.type.endswith("Int32") or s.type.startswith("BufferSize")):
+                                               if s.kind=="value":
+                                                       self.csize = "%s"%self.size
+                                                       if self.func.name.startswith("glUniformMatrix") and self.func.name[16]!='x':
+                                                               self.csize += "*%d"%(int(self.func.name[15])**2)
+                                                       elif self.func.name.startswith("glUniform") and self.func.name[9].isdigit():
+                                                               self.csize += "*%s"%self.func.name[9]
+                                                       if strip_name(self.base_ctype)!="void":
+                                                               self.csize += "*sizeof(%s)"%self.base_ctype
+                                               elif s.kind=="array" and s.size==1:
+                                                       self.csize = "*%s"%s.name
                                        if not self.csize:
                                                sys.stderr.write("Could not determine size for array parameter '%s[%s]' of function '%s'\n"%(self.name, self.size, self.func.name))
                        elif self.kind=="reference":
@@ -187,10 +194,10 @@ class Function:
                                have_type = True
                        elif cn.endswith("Format"):
                                res += "formatsize(%s)"%param.name
-                       elif param.name=="pname" or cn.endswith("Parameter"):
+                       elif param.name=="pname" or cn.endswith("Parameter") or (param.name=="target" and cn=="enum"):
                                res += "paramsize(%s)"%param.name
-                       elif cn=="MapTarget":
-                               res += "mapsize(%s)"%param.name
+                       elif param.name=="buffer" and cn=="enum":
+                               res += "buffersize(%s)"%param.name
                        elif (cn=="SizeI" or cn.endswith("Int32")) and not param.size:
                                res += param.name
                        else:
index b81ea4beaf1b311a3e5fbc7487e0c2c7fc1bc187..779fbea6c5f376c165614a798acc7a3e80bbe218 100644 (file)
@@ -89,8 +89,13 @@ int paramsize(GLenum pname)
        }
 }
 
-int mapsize(GLenum target __attribute__((unused)))
+int buffersize(GLenum buffer)
 {
-       // XXX Implement this
-       return 1;
+       switch(buffer)
+       {
+       case GL_COLOR: return 4;
+       case GL_DEPTH: return 1;
+       case GL_STENCIL: return 1;
+       default: return 1;
+       }
 }
index 7202136a29808c343f3d4a35074e932b05a8ae84..1ab0ae7a91dc6b6c994f206b0cbe409865c5f94d 100644 (file)
@@ -13,6 +13,6 @@ Distributed under the GPL
 extern int typesize(GLenum);
 extern int formatsize(GLenum);
 extern int paramsize(GLenum);
-extern int mapsize(GLenum);
+extern int buffersize(GLenum);
 
 #endif