regress: Add vertex shaders tests for constant buffers.
authorMichal Krol <michal@vmware.com>
Mon, 25 Jan 2010 11:42:17 +0000 (12:42 +0100)
committerMichal Krol <michal@vmware.com>
Thu, 28 Jan 2010 13:07:58 +0000 (14:07 +0100)
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-1d.sh [new file with mode: 0644]
src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-2d.sh [new file with mode: 0644]
src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py

diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-1d.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-1d.sh
new file mode 100644 (file)
index 0000000..b41fe5d
--- /dev/null
@@ -0,0 +1,16 @@
+VERT
+
+DCL IN[0], POSITION
+DCL IN[1], COLOR
+DCL OUT[0], POSITION
+DCL OUT[1], COLOR
+DCL CONST[1]
+DCL CONST[3]
+DCL TEMP[0..1]
+
+MOV OUT[0], IN[0]
+ADD TEMP[0], IN[1], CONST[1]
+RCP TEMP[1], CONST[3].xxxx
+MUL OUT[1], TEMP[0], TEMP[1]
+
+END
diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-2d.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-2d.sh
new file mode 100644 (file)
index 0000000..45f5e6b
--- /dev/null
@@ -0,0 +1,12 @@
+VERT
+
+DCL IN[0], POSITION
+DCL IN[1], COLOR
+DCL OUT[0], POSITION
+DCL OUT[1], COLOR
+DCL CONST[1][1..2]
+
+MOV OUT[0], IN[0]
+MAD OUT[1], IN[1], CONST[1][2], CONST[1][1]
+
+END
index 01bf5a3210d0f9bcade5a71d193d4947333fea41..96503778ae88a401e5df1ef806fd94ce4263f0a2 100644 (file)
@@ -27,6 +27,8 @@
 ##########################################################################
 
 
+import struct
+
 from gallium import *
 
 def make_image(surface):
@@ -143,6 +145,42 @@ def test(dev, name):
     ''')
     ctx.set_fragment_shader(fs)
 
+    constbuf0 = dev.buffer_create(64,
+                                  (PIPE_BUFFER_USAGE_CONSTANT |
+                                   PIPE_BUFFER_USAGE_GPU_READ |
+                                   PIPE_BUFFER_USAGE_CPU_WRITE),
+                                  4 * 4 * 4)
+
+    cbdata = ''
+    cbdata += struct.pack('4f', 0.4, 0.0, 0.0, 1.0)
+    cbdata += struct.pack('4f', 1.0, 1.0, 1.0, 1.0)
+    cbdata += struct.pack('4f', 2.0, 2.0, 2.0, 2.0)
+    cbdata += struct.pack('4f', 4.0, 8.0, 16.0, 32.0)
+
+    constbuf0.write(cbdata, 0)
+
+    ctx.set_constant_buffer(PIPE_SHADER_VERTEX,
+                            0,
+                            constbuf0)
+
+    constbuf1 = dev.buffer_create(64,
+                                  (PIPE_BUFFER_USAGE_CONSTANT |
+                                   PIPE_BUFFER_USAGE_GPU_READ |
+                                   PIPE_BUFFER_USAGE_CPU_WRITE),
+                                  4 * 4 * 4)
+
+    cbdata = ''
+    cbdata += struct.pack('4f', 0.1, 0.1, 0.1, 0.1)
+    cbdata += struct.pack('4f', 0.25, 0.25, 0.25, 0.25)
+    cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5)
+    cbdata += struct.pack('4f', 0.75, 0.75, 0.75, 0.75)
+
+    constbuf1.write(cbdata, 0)
+
+    ctx.set_constant_buffer(PIPE_SHADER_VERTEX,
+                            1,
+                            constbuf1)
+
     xy = [
          0.0,  0.8,
         -0.2,  0.4,
@@ -213,6 +251,8 @@ def main():
         'add',
         'arl',
         'arr',
+        'cb-1d',
+        'cb-2d',
         'dp3',
         'dp4',
         'dst',