diff mbox

[2/2] gles3: Add outerProduct tests to generated_tests

Message ID 1366916938-8860-2-git-send-email-tom.gall@linaro.org
State New
Headers show

Commit Message

Tom Gall April 25, 2013, 7:08 p.m. UTC
GL SL ES 3.00 added outerProduct as a built in fuction.

http://www.khronos.org/opengles/sdk/docs/manglsl/xhtml/outerProduct.xml

Add a script which generates testcases which validate the variety
of valid and invalid parameters that may be passed. The script
is called as part of the generated_tests.

Signed-off-by: Tom Gall <tom.gall@linaro.org>
---
 generated_tests/CMakeLists.txt                     |   14 +++
 generated_tests/outerProduct-invalid-parameters.sh |   91 ++++++++++++++++++++
 2 files changed, 105 insertions(+)
 create mode 100755 generated_tests/outerProduct-invalid-parameters.sh

Comments

Eric Anholt May 3, 2013, 10:22 p.m. UTC | #1
Tom Gall <tom.gall@linaro.org> writes:

> GL SL ES 3.00 added outerProduct as a built in fuction.
>
> http://www.khronos.org/opengles/sdk/docs/manglsl/xhtml/outerProduct.xml
>
> Add a script which generates testcases which validate the variety
> of valid and invalid parameters that may be passed. The script
> is called as part of the generated_tests.

> diff --git a/generated_tests/outerProduct-invalid-parameters.sh b/generated_tests/outerProduct-invalid-parameters.sh
> new file mode 100755
> index 0000000..7def598
> --- /dev/null
> +++ b/generated_tests/outerProduct-invalid-parameters.sh
> @@ -0,0 +1,91 @@
> +#!/bin/bash
> +
> +function emit_vs
> +{
> +    targetdir=$1
> +    t=$2
> +
> +    echo "$targetdir/outerProduct-$t.vert"
> +    cat > $targetdir/outerProduct-$t.vert <<EOF
> +/* [config]
> + * expect_result: fail
> + * glsl_version: 3.00
> + * [end config]
> + * outerProduct is available in OpenGL SL ES 3.00 but
> + * not for all data types.

I'm confused what this means.  It sounds like you're saying ES3 does
fewer datatypes than desktop does, but the text of the two specs looks
the same to me.

> +set +x
> +
> +targetdir="spec/glsl-es-3.00/compiler/built-in-functions"
> +mkdir -p $targetdir
> +
> +for i in int float bool bvec2 bvec3 bvec4 mat2 mat2x2 mat2x3 mat2x4 mat3 mat3x2 mat3x3 mat3x4 mat4 mat4x2 mat4x3 mat4x4
> +do
> +    emit_vs $targetdir $i
> +done

Ah, since there's no implicit conversions, you can test that no extra
builtin prototypes are available.  If you're interested in testing this,
it seems like you could be much more thorough by making a variant on
builtin_function.py that makes glslparsertests using invalid types for
all sorts of builtins on GLSL that bans implicit conversions.

> +for i in vec2 vec3 vec4
> +do
> +    emit_valid_vs $targetdir $i
> +done
> +emit_valid_mixed_vs $targetdir vec3 vec2
> +emit_valid_mixed_vs $targetdir vec2 vec3
> +emit_valid_mixed_vs $targetdir vec4 vec2
> +emit_valid_mixed_vs $targetdir vec4 vec3
> +emit_valid_mixed_vs $targetdir vec2 vec4
> +emit_valid_mixed_vs $targetdir vec3 vec4

These should be handled by the existing built-in-functions test
generator instead of being generated as non-executing tests by a new
"invalid-parameters" test generator
diff mbox

Patch

diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index db3734f..58ff0af 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -18,6 +18,16 @@  function(piglit_make_generated_tests file_list generator_script)
 		VERBATIM)
 endfunction(piglit_make_generated_tests custom_target generator_script)
 
+function(piglit_make_sh_generated_tests file_list generator_sh_script version)
+	# Add a custom command which executes ${generator_script}
+	# during the build.
+	add_custom_command(
+		OUTPUT ${file_list}
+		COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${generator_sh_script} ${version} > ${file_list}
+		DEPENDS ${generator_sh_script} ${ARGN}
+		VERBATIM)
+endfunction(piglit_make_sh_generated_tests custom_target generator_sh_script)
+
 # Create custom commands and targets to build generated tests.
 piglit_make_generated_tests(
 	builtin_packing_tests.list
@@ -54,6 +64,9 @@  piglit_make_generated_tests(
 piglit_make_generated_tests(
 	builtin_cl_int_tests.list
 	generate-cl-int-builtins.py)
+piglit_make_sh_generated_tests(
+	outerProduct-invalid-parameters_tests.list
+	outerProduct-invalid-parameters.sh 3.00)
 
 # Add a "gen-tests" target that can be used to generate all the
 # tests without doing any other compilation.
@@ -64,5 +77,6 @@  add_custom_target(gen-tests ALL
 		builtin_cl_int_tests.list
 		interpolation_tests.list
 		non-lvalue_tests.list
+		outerProduct-invalid-parameters_tests.list
 		texture_query_lod_tests.list
 		uniform-initializer_tests.list)
diff --git a/generated_tests/outerProduct-invalid-parameters.sh b/generated_tests/outerProduct-invalid-parameters.sh
new file mode 100755
index 0000000..7def598
--- /dev/null
+++ b/generated_tests/outerProduct-invalid-parameters.sh
@@ -0,0 +1,91 @@ 
+#!/bin/bash
+
+function emit_vs
+{
+    targetdir=$1
+    t=$2
+
+    echo "$targetdir/outerProduct-$t.vert"
+    cat > $targetdir/outerProduct-$t.vert <<EOF
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00
+ * [end config]
+ * outerProduct is available in OpenGL SL ES 3.00 but
+ * not for all data types.
+ *
+ * http://www.khronos.org/opengles/sdk/docs/manglsl/xhtml/outerProduct.xml
+ */
+void main () {
+  gl_Position = vec4(0);
+  outerProduct(${t}(0), ${t}(0));
+}
+EOF
+}
+
+function emit_valid_vs
+{
+    targetdir=$1
+    t=$2
+
+    echo "$targetdir/outerProduct-$t.vert"
+    cat > $targetdir/outerProduct-$t.vert <<EOF
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00
+ * [end config]
+ * outerProduct is available in OpenGL SL ES 3.00.
+ * not for all data types.
+ *
+ * http://www.khronos.org/opengles/sdk/docs/manglsl/xhtml/outerProduct.xml
+ */
+void main () {
+  gl_Position = vec4(0);
+  outerProduct(${t}(0), ${t}(0));
+}
+EOF
+}
+
+function emit_valid_mixed_vs
+{
+    targetdir=$1
+    t=$2
+    u=$3
+
+    echo "$targetdir/outerProduct-$t.vert"
+    cat > $targetdir/outerProduct-$t.vert <<EOF
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00
+ * [end config]
+ * outerProduct is available in OpenGL SL ES 3.00.
+ * not for all data types.
+ *
+ * http://www.khronos.org/opengles/sdk/docs/manglsl/xhtml/outerProduct.xml
+ */
+void main () {
+  gl_Position = vec4(0);
+  outerProduct(${t}(0), ${u}(0));
+}
+EOF
+}
+
+set +x
+
+targetdir="spec/glsl-es-3.00/compiler/built-in-functions"
+mkdir -p $targetdir
+
+for i in int float bool bvec2 bvec3 bvec4 mat2 mat2x2 mat2x3 mat2x4 mat3 mat3x2 mat3x3 mat3x4 mat4 mat4x2 mat4x3 mat4x4
+do
+    emit_vs $targetdir $i
+done
+for i in vec2 vec3 vec4
+do
+    emit_valid_vs $targetdir $i
+done
+emit_valid_mixed_vs $targetdir vec3 vec2
+emit_valid_mixed_vs $targetdir vec2 vec3
+emit_valid_mixed_vs $targetdir vec4 vec2
+emit_valid_mixed_vs $targetdir vec4 vec3
+emit_valid_mixed_vs $targetdir vec2 vec4
+emit_valid_mixed_vs $targetdir vec3 vec4