From: Mikko Rasa Date: Sat, 7 Nov 2009 12:38:02 +0000 (+0000) Subject: Fix some array size calculations X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=68bbf8f302d01d2ee82dee28b9f64cff3660e234;p=gldbg.git Fix some array size calculations --- diff --git a/genwrap.py b/genwrap.py index 1ee97ce..07dd914 100755 --- a/genwrap.py +++ b/genwrap.py @@ -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: diff --git a/source/arraysize.c b/source/arraysize.c index b81ea4b..779fbea 100644 --- a/source/arraysize.c +++ b/source/arraysize.c @@ -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; + } } diff --git a/source/arraysize.h b/source/arraysize.h index 7202136..1ab0ae7 100644 --- a/source/arraysize.h +++ b/source/arraysize.h @@ -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