From: Mikko Rasa Date: Sat, 25 Aug 2012 08:09:18 +0000 (+0300) Subject: Add an errata system to avoid the need of putting special cases in code X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=11fa21c4cf08dd383581a241b939e2c4b6f49a50;p=gldbg.git Add an errata system to avoid the need of putting special cases in code --- diff --git a/flavors/gl/gl.api b/flavors/gl/gl.api index 40b44c7..3ddc17f 100644 --- a/flavors/gl/gl.api +++ b/flavors/gl/gl.api @@ -1,6 +1,7 @@ typemap gl.tm iomap gl.io spec gl.spec +errata gl.errata prefix gl enumspec enum.spec enumprefix GL_ diff --git a/flavors/gl/gl.errata b/flavors/gl/gl.errata new file mode 100644 index 0000000..b1681fc --- /dev/null +++ b/flavors/gl/gl.errata @@ -0,0 +1,29 @@ +UniformMatrix2fv(...) + param value Float32 in array [count*4] + +UniformMatrix3fv(...) + param value Float32 in array [count*9] + +UniformMatrix4fv(...) + param value Float32 in array [count*16] + +Uniform2fv(...) + param value Float32 in array [count*2] + +Uniform3fv(...) + param value Float32 in array [count*3] + +Uniform4fv(...) + param value Float32 in array [count*4] + +Uniform2iv(...) + param value Int32 in array [count*2] + +Uniform3iv(...) + param value Int32 in array [count*3] + +Uniform4iv(...) + param value Int32 in array [count*4] + +GetActiveUniformsiv(...) + param params Int32 out array [COMPSIZE(pname/uniformCount)] diff --git a/generate.py b/generate.py index 229ecc3..3877e6d 100755 --- a/generate.py +++ b/generate.py @@ -146,10 +146,6 @@ class Function: 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: @@ -307,6 +303,8 @@ class Template: iomap = IOmap(api.iomap) for spec in api.specs: funcs = read_spec(spec, api.prefix) + for err in api.errata: + read_spec(err, api.prefix, funcs) funcs = [f for f in funcs if f.name not in api.ignore_funcs and f.category not in api.ignore_categs] for func in funcs: func.finalize(typemap, iomap) @@ -328,6 +326,7 @@ class Api: self.typemap = None self.iomap = None self.specs = [] + self.errata = [] self.prefix = None self.enumspecs = [] self.enumprefix = None @@ -344,6 +343,8 @@ class Api: self.iomap = os.path.join(path, parts[1]) elif parts[0]=="spec": self.specs.append(os.path.join(path, parts[1])) + elif parts[0]=="errata": + self.errata.append(os.path.join(path, parts[1])) elif parts[0]=="prefix": self.prefix = parts[1] elif parts[0]=="enumspec": @@ -359,8 +360,9 @@ class Api: sys.stderr.write("Unknown keyword '%s'\n", parts[0]) -def read_spec(fn, prefix): - funcs = [] +def read_spec(fn, prefix, funcs=None): + if funcs is None: + funcs = [] cur_func = None for line in InputFile(fn): @@ -392,8 +394,15 @@ def read_spec(fn, prefix): pnames = [n.strip() for n in line[paren+1:cparen].split(",")] else: pnames = [] - cur_func = Function(prefix+line[:paren], pnames) - funcs.append(cur_func) + fname = prefix+line[:paren] + cur_func = None + for f in funcs: + if f.name==fname: + cur_func = f + break + if not cur_func: + cur_func = Function(prefix+line[:paren], pnames) + funcs.append(cur_func) return funcs