summaryrefslogtreecommitdiffstats
path: root/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-06-24 15:32:15 -0700
committerEric Anholt <[email protected]>2010-06-24 15:36:00 -0700
commit29285882676388aacff123e8bdf025904abf8ea9 (patch)
treea830f72e7a5273d8fd1a7781ce7da7ae91b613ab /src/glsl/builtins/tools/generate_matrixCompMultGLSL.py
parent0ee7d80269bfab14683623b0c8fc12da43db8d78 (diff)
glsl2: Move the compiler to the subdirectory it will live in in Mesa.
Diffstat (limited to 'src/glsl/builtins/tools/generate_matrixCompMultGLSL.py')
-rwxr-xr-xsrc/glsl/builtins/tools/generate_matrixCompMultGLSL.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py b/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py
new file mode 100755
index 00000000000..391ad110d37
--- /dev/null
+++ b/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+def gen_matrix(x, y = 0):
+ if y == 0:
+ y = x
+ type = "mat" + str(x)
+ if x != y:
+ type = type + "x" + str(y)
+ print type + " matrixCompMult(" + type + " x, " + type + " y)\n{"
+ print " " + type + " z;"
+
+ for i in range(x):
+ print " z[" + str(i) + "] = x[" + str(i) + "] * y[" + str(i) + "];"
+ print " return z;\n}"
+
+print "#version 120"
+# 1.10
+gen_matrix(2)
+gen_matrix(3)
+gen_matrix(4)
+
+# 1.20
+gen_matrix(2,3) # mat2x3 means 2 columns, 3 rows
+gen_matrix(3,2)
+gen_matrix(2,4)
+gen_matrix(4,2)
+gen_matrix(3,4)
+gen_matrix(4,3)