[Piglit] [PATCH 3/3] GL_ARB_uniform_buffer_object: Add "ubo" arg to variable-index-read.sh script

Vincent Lejeune vljn at ovi.com
Mon Apr 23 16:17:33 PDT 2012


---
 tests/spec/glsl-1.10/variable-index-read.sh |  125 ++++++++++++++++++++++-----
 1 files changed, 102 insertions(+), 23 deletions(-)

diff --git a/tests/spec/glsl-1.10/variable-index-read.sh b/tests/spec/glsl-1.10/variable-index-read.sh
index b9f342e..c1a2ccb 100755
--- a/tests/spec/glsl-1.10/variable-index-read.sh
+++ b/tests/spec/glsl-1.10/variable-index-read.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Generate a set of data for a sized matrix.  Elements start with a specified
 # value and increment by 1.0 for each element.
@@ -61,6 +61,10 @@ function emit_globals
 	fi
     fi
 
+    if [ $mode = "ubo" ]; then
+	  echo "uniform ubo1 {"
+    fi
+
     if [ $array_dim -ne 0 -a "x$index_value" = "xindex" ]; then
 	echo "uniform int index;"
     fi
@@ -85,9 +89,19 @@ function emit_globals
 	    emit_matrix_array_initializer $matrix_dim $array_dim $base_type ""
 	    echo ");"
 	fi
+    elif [ "x$mode" = "xubo" ]; then
+	if [ $array_dim -eq 0 ]; then
+            echo -n "uniform ${type} m;"
+	else
+	    echo "uniform ${type} m${dim};"
+	fi
+	echo "};"
     elif [ "x$mode" != "xtemp" ]; then
         echo "${mode} ${type} m${dim};"
     fi
+
+
+
     echo "varying vec4 color;"
     echo
 }
@@ -165,6 +179,9 @@ function emit_vs
 
     echo "[vertex shader]"
     echo "#version ${version/./}"
+   if [ $mode = "ubo" ];then
+    echo "#extension GL_ARB_uniform_buffer_object : enable"
+   fi
     emit_globals $*
 
     echo "void main()"
@@ -219,6 +236,9 @@ emit_fs()
 
     echo "[fragment shader]"
     echo "#version ${version/./}"
+   if [ $mode = "ubo" ];then
+    echo "#extension GL_ARB_uniform_buffer_object : enable"
+   fi
     emit_globals $*
 
     echo "void main()"
@@ -293,6 +313,10 @@ ortho
 
 EOF
 
+    if [ "x$mode" = "xubo" ]; then
+        echo "ubo-buffer ubo1"
+    fi
+
     # NOTE: shader_runner uses the matCxR names even for GLSL 1.10
     v=${version/./}
     type="mat${matrix_dim}x${matrix_dim}"
@@ -304,6 +328,14 @@ EOF
 	fi
     fi
 
+    if [ "x$mode" = "xubo" ]; then
+	if [ $array_dim -eq 0 ]; then
+	    echo -n "ubo-uniform 0 ${type} m "
+	    matrix_data 1 $matrix_dim | sed 's/,//g'
+	    echo
+	fi
+    fi
+
     if [ $array_dim -eq 0 ]; then
 	sizes="1"
     elif [ "x$index_value" = "xindex" ]; then
@@ -336,26 +368,62 @@ EOF
 	    fi
 	fi
 
-	if [ $array_dim -ne 0 -a "x$index_value" = "xindex" ]; then
-	    echo "uniform int index $((i - 1))"
+	if [ "x$mode" = "xubo" ]; then
+	    if [ $array_dim -ne 0 ]; then
+		matrixcontent=""
+		for c in $(seq 0 $(($array_dim - 1))); do
+		    first=$((1 + c * matrix_dim * matrix_dim))
+		    matrixcontent="$matrixcontent  $(matrix_data $first $matrix_dim | sed 's/,//g')"
+		done
+		echo -n "ubo-uniform 0 ${type}[$array_dim] m $matrixcontent"
+		echo
+
+	    fi
+	fi
+
+	if [ "x$mode" = "xubo" ]; then
+		if [ $array_dim -ne 0 -a "x$index_value" = "xindex" ]; then
+			 echo "ubo-uniform 0 int index $((i - 1))"
+		fi
+	else
+		if [ $array_dim -ne 0 -a "x$index_value" = "xindex" ]; then
+			 echo "uniform int index $((i - 1))"
+		fi
 	fi
 
 	x_base=$(((i - 1) * (15 * matrix_dim + 10)))
 	for c in $columns; do
 	    if [ "x$col" = "xcol" ]; then
-		echo "uniform int col $((c - 1))"
+          if [ "x$mode" = "xubo" ]; then
+           echo "ubo-uniform 0 int col $((c - 1))"
+          else
+		     echo "uniform int col $((c - 1))"
+          fi
 	    fi
 
 	    for r in $rows; do
 		expect=$(((i - 1) * (matrix_dim * matrix_dim) + (c - 1) * matrix_dim + r))
 		if [ "x$expect_type" = "xfloat" ]; then
-		    echo "uniform int row $((r - 1))"
-		    echo "uniform float expect $expect"
+          if [ "x$mode" = "xubo" ]; then
+ 		     echo "ubo-uniform 0 int row $((r - 1))"
+		     echo "ubo-uniform 0 float expect $expect"
+          else
+		     echo "uniform int row $((r - 1))"
+		     echo "uniform float expect $expect"
+          fi
 		else
 		    e=$(seq $expect $((expect + matrix_dim - 1)) | tr '\n' ' ' | sed 's/[[:space:]]*$//g')
-		    echo "uniform ${expect_type} expect $e"
+          if [ "x$mode" = "xubo" ]; then
+		     echo "ubo-uniform 0 ${expect_type} expect $e"
+          else
+		     echo "uniform ${expect_type} expect $e"
+          fi
 		fi
 
+          if [ "x$mode" = "xubo" ]; then
+                echo "ubo-bind 0"
+          fi
+
 		x=$((x_base + 15 * c - 10))
 		y=$((15 * r - 10))
 		echo "draw rect $x $y 10 10"
@@ -404,21 +472,9 @@ function emit_vs_rd_test
     emit_test_vectors $*
 }
 
-cmd="$0 $*"
-
-if [ "x$1" = "x" ]; then
-    version="1.10"
-else
-    case "$1" in
-	1.[12]0) version="$1";;
-	*)
-	    echo "Bogus GLSL version \"$1\" specified."
-	    exit 1
-	    ;;
-    esac
-fi
-
-for mode in temp uniform varying; do
+function test_mode
+{
+    mode=$1
     # More than 3 is unlikely to work for the varying tests due to using too
     # many varying vectors.  mat4[3] uses 12 varying vectors by itself.
     for array_dim in 0 3; do
@@ -480,4 +536,27 @@ for mode in temp uniform varying; do
 		> vs-${mode}-${arr}mat${matrix_dim}-${idx_txt}rd.shader_test
 	done
     done
-done
+}
+
+cmd="$0 $*"
+
+if [ "x$1" = "x" ]; then
+    version="1.10"
+else
+    case "$1" in
+	1.[12]0) version="$1";;
+	ubo) version="1.20"; ubo="1";;
+	*)
+	    echo "Bogus GLSL version \"$1\" specified."
+	    exit 1
+	    ;;
+    esac
+fi
+
+if [ $ubo = "1" ]; then
+   test_mode "ubo"
+else
+   for mode in temp uniform varying;do
+      test_mode $mode
+   done
+fi
-- 
1.7.7



More information about the Piglit mailing list