Mesa (master): regress: Add two-dimension constant buffer test.

Michał Król michal at kemper.freedesktop.org
Thu Jan 28 13:12:27 UTC 2010


Module: Mesa
Branch: master
Commit: 4771e536e16699a0488b68e153de3478dfbc55d0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4771e536e16699a0488b68e153de3478dfbc55d0

Author: Michal Krol <michal at vmware.com>
Date:   Thu Jan 21 20:03:13 2010 +0100

regress: Add two-dimension constant buffer test.

---

 .../tests/regress/fragment-shader/frag-cb-2d.sh    |    9 +++++
 .../regress/fragment-shader/fragment-shader.py     |   38 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-2d.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-2d.sh
new file mode 100644
index 0000000..f70a514
--- /dev/null
+++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-2d.sh
@@ -0,0 +1,9 @@
+FRAG
+
+DCL IN[0], COLOR, LINEAR
+DCL OUT[0], COLOR
+DCL CONST[1][1..2]
+
+MAD OUT[0], IN[0], CONST[1][2], CONST[1][1]
+
+END
diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
index 8d3bf9d..6a0c1f8 100644
--- a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
+++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py
@@ -26,6 +26,7 @@
 # 
 ##########################################################################
 
+import struct
 
 from gallium import *
 
@@ -146,6 +147,42 @@ def test(dev, name):
     fs = Shader(file('frag-' + name + '.sh', 'rt').read())
     ctx.set_fragment_shader(fs)
 
+    constbuf0 = dev.buffer_create(16,
+                                  (PIPE_BUFFER_USAGE_CONSTANT |
+                                   PIPE_BUFFER_USAGE_GPU_READ |
+                                   PIPE_BUFFER_USAGE_CPU_WRITE),
+                                  4 * 4 * 4)
+
+    cbdata = ''
+    cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5)
+    cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5)
+    cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5)
+    cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5)
+
+    constbuf0.write(cbdata, 0)
+
+    ctx.set_constant_buffer(PIPE_SHADER_FRAGMENT,
+                            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_FRAGMENT,
+                            1,
+                            constbuf1)
+
     xy = [
         -0.8, -0.8,
          0.8, -0.8,
@@ -184,6 +221,7 @@ def main():
     tests = [
         'abs',
         'add',
+        'cb-2d',
         'dp3',
         'dp4',
         'dst',




More information about the mesa-commit mailing list