aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/builtins/tools/generate_transposeGLSL.py
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2010-08-16 19:08:53 -0700
committerIan Romanick <[email protected]>2010-08-16 19:08:53 -0700
commit6c03c576cc49bbb008de66d374f4302ff0fe0390 (patch)
tree7ddeb3ee88532d9aef8728b9aa256edf7c125247 /src/glsl/builtins/tools/generate_transposeGLSL.py
parent15a3b42e135a3a2cb463ec3cff80a55dd8528051 (diff)
parenta433cd286c60eb9d4c2114f042709eda0f3de676 (diff)
Merge branch 'glsl2'
Conflicts: src/mesa/program/prog_optimize.c
Diffstat (limited to 'src/glsl/builtins/tools/generate_transposeGLSL.py')
-rwxr-xr-xsrc/glsl/builtins/tools/generate_transposeGLSL.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/glsl/builtins/tools/generate_transposeGLSL.py b/src/glsl/builtins/tools/generate_transposeGLSL.py
new file mode 100755
index 00000000000..8f669ce9839
--- /dev/null
+++ b/src/glsl/builtins/tools/generate_transposeGLSL.py
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+def gen(x, y):
+ origtype = "mat" + str(x)
+ trantype = "mat" + str(y)
+ if x != y:
+ origtype = origtype + "x" + str(y)
+ trantype = trantype + "x" + str(x)
+ print trantype + " transpose(" + origtype + " m)\n{"
+ print " " + trantype + " t;"
+
+ # The obvious implementation of transpose
+ for i in range(x):
+ for j in range(y):
+ print " t[" + str(j) + "][" + str(i) + "] =",
+ print "m[" + str(i) + "][" + str(j) + "];"
+ print " return t;\n}"
+
+print "#version 120"
+gen(2,2)
+gen(2,3) # mat2x3 means 2 columns, 3 rows
+gen(2,4)
+gen(3,2)
+gen(3,3)
+gen(3,4)
+gen(4,2)
+gen(4,3)
+gen(4,4)