[Piglit] [PATCH 10/11] arb_shader_subroutine: Add tests for calling through subroutine uniforms

Ian Romanick idr at freedesktop.org
Wed Aug 27 16:30:04 PDT 2014


On 08/10/2014 04:07 AM, Chris Forbes wrote:
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
>  .../compiler/array-call-const-indexed.vert         | 23 ++++++++++++++++++
>  .../array-call-dynamically-uniform-indexed.vert    | 27 ++++++++++++++++++++++
>  .../compiler/call-param-mismatch.vert              | 19 +++++++++++++++
>  .../compiler/direct-call.vert                      | 27 ++++++++++++++++++++++
>  .../compiler/simple-call.vert                      | 23 ++++++++++++++++++
>  5 files changed, 119 insertions(+)
>  create mode 100644 tests/spec/arb_shader_subroutine/compiler/array-call-const-indexed.vert
>  create mode 100644 tests/spec/arb_shader_subroutine/compiler/array-call-dynamically-uniform-indexed.vert
>  create mode 100644 tests/spec/arb_shader_subroutine/compiler/call-param-mismatch.vert
>  create mode 100644 tests/spec/arb_shader_subroutine/compiler/direct-call.vert
>  create mode 100644 tests/spec/arb_shader_subroutine/compiler/simple-call.vert
> 
> diff --git a/tests/spec/arb_shader_subroutine/compiler/array-call-const-indexed.vert b/tests/spec/arb_shader_subroutine/compiler/array-call-const-indexed.vert
> new file mode 100644
> index 0000000..929f571
> --- /dev/null
> +++ b/tests/spec/arb_shader_subroutine/compiler/array-call-const-indexed.vert
> @@ -0,0 +1,23 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// require_extensions: GL_ARB_shader_subroutine
> +// [end config]
> +
> +#version 150
> +#extension GL_ARB_shader_subroutine: require
> +
> +subroutine void func_type();
> +
> +/* A subroutine matching the above type */
> +subroutine (func_type) void impl() {}
> +
> +/* An array of subroutine uniforms matching the above */
> +subroutine uniform func_type f[4];
> +
> +/* Elements of an array of subroutine uniforms are callable
> + * as if they were any other function
> + */
> +void foo() {
> +	f[0]();
> +}
> diff --git a/tests/spec/arb_shader_subroutine/compiler/array-call-dynamically-uniform-indexed.vert b/tests/spec/arb_shader_subroutine/compiler/array-call-dynamically-uniform-indexed.vert
> new file mode 100644
> index 0000000..0f7c71d
> --- /dev/null
> +++ b/tests/spec/arb_shader_subroutine/compiler/array-call-dynamically-uniform-indexed.vert
> @@ -0,0 +1,27 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// require_extensions: GL_ARB_shader_subroutine
> +// [end config]
> +
> +#version 150
> +#extension GL_ARB_shader_subroutine: require
> +
> +subroutine void func_type();
> +
> +subroutine (func_type) void impl() {}
> +
> +subroutine uniform func_type f[4];
> +
> +uniform int n;
> +
> +/* Arrays of subroutine uniforms may be indexed with
> + * dynamically uniform expressions. GLSL 4.00-4.30
> + * leave this underspecified as 'dynamically indexed'
> + * but GLSL 4.40 clarifies that the intent all along
> + * was to require the indexing expression to be
> + * dynamically uniform.
> + */
> +void foo() {
> +	f[n]();
> +}
> diff --git a/tests/spec/arb_shader_subroutine/compiler/call-param-mismatch.vert b/tests/spec/arb_shader_subroutine/compiler/call-param-mismatch.vert
> new file mode 100644
> index 0000000..870d0ca
> --- /dev/null
> +++ b/tests/spec/arb_shader_subroutine/compiler/call-param-mismatch.vert
> @@ -0,0 +1,19 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// require_extensions: GL_ARB_shader_subroutine
> +// [end config]
> +
> +#version 150
> +#extension GL_ARB_shader_subroutine: require
> +
> +subroutine void func_type();
> +
> +subroutine (func_type) void impl() {}
> +
> +subroutine uniform func_type f;
> +
> +/* Call f() with a mismatched parameter list */
> +void foo() {
> +	f(42);
> +}
> diff --git a/tests/spec/arb_shader_subroutine/compiler/direct-call.vert b/tests/spec/arb_shader_subroutine/compiler/direct-call.vert
> new file mode 100644
> index 0000000..6d5f1d4
> --- /dev/null
> +++ b/tests/spec/arb_shader_subroutine/compiler/direct-call.vert
> @@ -0,0 +1,27 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// require_extensions: GL_ARB_shader_subroutine
> +// [end config]
> +
> +#version 150
> +#extension GL_ARB_shader_subroutine: require
> +
> +/* The ARB_shader_subroutine spec says nothing to
> + * explicitly disallow calling subroutine implementations
> + * as normal functions.
> + *
> + * It seems reasonable that this would still work.

There is some clarification of this on GLSL 4.50.

Section 6.1.2 (Subroutines) of the GLSL 4.50 spec says:

    "A function declared with subroutine can also be called
    directly with a static use of functionName, as is done
    with non-subroutine function declarations and calls."

I believe this was intended to be a clarification of previous specs (not
a new feature of 4.50).

> + */
> +
> +subroutine void func_type();
> +
> +/* A subroutine matching the above type */
> +subroutine (func_type) void impl() {}
> +
> +/* Call the function directly, rather than via
> + * a subroutine uniform.
> + */
> +void foo() {
> +	impl();
> +}
> diff --git a/tests/spec/arb_shader_subroutine/compiler/simple-call.vert b/tests/spec/arb_shader_subroutine/compiler/simple-call.vert
> new file mode 100644
> index 0000000..52dc538
> --- /dev/null
> +++ b/tests/spec/arb_shader_subroutine/compiler/simple-call.vert
> @@ -0,0 +1,23 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// require_extensions: GL_ARB_shader_subroutine
> +// [end config]
> +
> +#version 150
> +#extension GL_ARB_shader_subroutine: require
> +
> +subroutine void func_type();
> +
> +/* A subroutine matching the above type */
> +subroutine (func_type) void impl() {}
> +
> +/* A subroutine uniform for the above type */
> +subroutine uniform func_type f;
> +
> +/* Subroutines are called via the uniform as
> + * if they were any other function
> + */
> +void foo() {
> +	f();
> +}
> 



More information about the Piglit mailing list