From: Dave Airlie <airl...@redhat.com> This adds some basic shader tests to exercise ARB_shader_subroutine using the shader_runner interface I added.
Signed-off-by: Dave Airlie <airl...@redhat.com> --- .../array-subroutines-nonconst.shader_test | 51 ++++++++++++++++ .../execution/array-subroutines.shader_test | 47 +++++++++++++++ .../execution/simple-subroutine.shader_test | 44 ++++++++++++++ .../execution/two-subroutines-2.shader_test | 49 +++++++++++++++ .../execution/two-subroutines-nested.shader_test | 69 ++++++++++++++++++++++ .../execution/two-subroutines-uniform.shader_test | 66 +++++++++++++++++++++ .../execution/two-subroutines.shader_test | 63 ++++++++++++++++++++ 7 files changed, 389 insertions(+) create mode 100644 tests/spec/arb_shader_subroutine/execution/array-subroutines-nonconst.shader_test create mode 100644 tests/spec/arb_shader_subroutine/execution/array-subroutines.shader_test create mode 100644 tests/spec/arb_shader_subroutine/execution/simple-subroutine.shader_test create mode 100644 tests/spec/arb_shader_subroutine/execution/two-subroutines-2.shader_test create mode 100644 tests/spec/arb_shader_subroutine/execution/two-subroutines-nested.shader_test create mode 100644 tests/spec/arb_shader_subroutine/execution/two-subroutines-uniform.shader_test create mode 100644 tests/spec/arb_shader_subroutine/execution/two-subroutines.shader_test diff --git a/tests/spec/arb_shader_subroutine/execution/array-subroutines-nonconst.shader_test b/tests/spec/arb_shader_subroutine/execution/array-subroutines-nonconst.shader_test new file mode 100644 index 0000000..50daed3 --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/array-subroutines-nonconst.shader_test @@ -0,0 +1,51 @@ +# test calling subroutine uniforms with +# a non constant array index works. +[require] +GLSL >= 1.50 +GL_ARB_shader_subroutine + +[vertex shader passthrough] + +[fragment shader] +#version 150 +#extension GL_ARB_shader_subroutine: enable + +out vec4 color; + +subroutine float getchan1(); + +subroutine uniform getchan1 GetChan1[2]; + +uniform int pick; + +subroutine(getchan1) +float chan_full() +{ + return 1.0; +} + +subroutine(getchan1) +float chan_empty() +{ + return 0.0; +} + +void main() +{ + color = vec4(GetChan1[pick](), GetChan1[1 - pick](), 0.0, 1.0); +} + + +[test] +clear color 0.0 0.0 1.0 0.0 +clear +uniform int pick 0 +subuniform GL_FRAGMENT_SHADER GetChan1[0] chan_full +subuniform GL_FRAGMENT_SHADER GetChan1[1] chan_empty +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 0.0 1.0 +uniform int pick 1 +subuniform GL_FRAGMENT_SHADER GetChan1[0] chan_empty +subuniform GL_FRAGMENT_SHADER GetChan1[1] chan_full +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 0.0 1.0 diff --git a/tests/spec/arb_shader_subroutine/execution/array-subroutines.shader_test b/tests/spec/arb_shader_subroutine/execution/array-subroutines.shader_test new file mode 100644 index 0000000..98d0d98 --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/array-subroutines.shader_test @@ -0,0 +1,47 @@ +# test calling subroutine uniforms in an array +# with a constant value works. +[require] +GLSL >= 1.50 +GL_ARB_shader_subroutine + +[vertex shader passthrough] + +[fragment shader] +#version 150 +#extension GL_ARB_shader_subroutine: enable + +out vec4 color; + +subroutine float getchan1(); + +subroutine uniform getchan1 GetChan1[2]; + +subroutine(getchan1) +float chan_full() +{ + return 1.0; +} + +subroutine(getchan1) +float chan_empty() +{ + return 0.0; +} + +void main() +{ + color = vec4(GetChan1[0](), GetChan1[1](), 0.0, 1.0); +} + + +[test] +clear color 0.0 0.0 1.0 0.0 +clear +subuniform GL_FRAGMENT_SHADER GetChan1[0] chan_full +subuniform GL_FRAGMENT_SHADER GetChan1[1] chan_empty +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 0.0 1.0 +subuniform GL_FRAGMENT_SHADER GetChan1[0] chan_empty +subuniform GL_FRAGMENT_SHADER GetChan1[1] chan_full +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_shader_subroutine/execution/simple-subroutine.shader_test b/tests/spec/arb_shader_subroutine/execution/simple-subroutine.shader_test new file mode 100644 index 0000000..3f07dd9 --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/simple-subroutine.shader_test @@ -0,0 +1,44 @@ +# simple test using one shader subroutine. + +[require] +GLSL >= 1.50 +GL_ARB_shader_subroutine + +[vertex shader passthrough] + +[fragment shader] +#version 150 +#extension GL_ARB_shader_subroutine: enable + +out vec4 color; + +subroutine vec4 getcolor(); +subroutine uniform getcolor GetColor; + +subroutine(getcolor) +vec4 color_red() +{ + return vec4(1.0, 0.0, 0.0, 1.0); +} + +subroutine(getcolor) +vec4 color_green() +{ + return vec4(0.0, 1.0, 0.0, 1.0); +} + +void main() +{ + color = GetColor(); +} + + +[test] +clear color 0.0 0.0 1.0 0.0 +clear +subuniform GL_FRAGMENT_SHADER GetColor color_red +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 0.0 1.0 +subuniform GL_FRAGMENT_SHADER GetColor color_green +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_shader_subroutine/execution/two-subroutines-2.shader_test b/tests/spec/arb_shader_subroutine/execution/two-subroutines-2.shader_test new file mode 100644 index 0000000..74c2421 --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/two-subroutines-2.shader_test @@ -0,0 +1,49 @@ +# two subroutines using the same functions +# as backends for the types. +[require] +GLSL >= 1.50 +GL_ARB_shader_subroutine + +[vertex shader passthrough] + +[fragment shader] +#version 150 +#extension GL_ARB_shader_subroutine: enable + +out vec4 color; + +subroutine float getchan1(); +subroutine uniform getchan1 GetChan1; + +subroutine float getchan2(); +subroutine uniform getchan2 GetChan2; + +subroutine(getchan1, getchan2) +float chan_full() +{ + return 1.0; +} + +subroutine(getchan1, getchan2) +float chan_empty() +{ + return 0.0; +} + +void main() +{ + color = vec4(GetChan1(), GetChan2(), 0.0, 1.0); +} + + +[test] +clear color 0.0 0.0 1.0 0.0 +clear +subuniform GL_FRAGMENT_SHADER GetChan1 chan_full +subuniform GL_FRAGMENT_SHADER GetChan2 chan_empty +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 0.0 1.0 +subuniform GL_FRAGMENT_SHADER GetChan1 chan_empty +subuniform GL_FRAGMENT_SHADER GetChan2 chan_full +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_shader_subroutine/execution/two-subroutines-nested.shader_test b/tests/spec/arb_shader_subroutine/execution/two-subroutines-nested.shader_test new file mode 100644 index 0000000..b65a020 --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/two-subroutines-nested.shader_test @@ -0,0 +1,69 @@ +# two subroutines, once calls into the other. +# ensure a subroutine calling a subroutine +# before all members have been parsed +# works fine. +# Initial mesa implementation generated +# the lowered call too early. + +[require] +GLSL >= 1.50 +GL_ARB_shader_subroutine + +[vertex shader passthrough] + +[fragment shader] +#version 150 +#extension GL_ARB_shader_subroutine: enable + +uniform float myin; +out vec4 color; + +subroutine float getchan1(); +subroutine uniform getchan1 GetChan1; + +subroutine float getchan2(); +subroutine uniform getchan2 GetChan2; + +subroutine(getchan1) +float chan1_full() +{ + return 1.0; +} + +subroutine(getchan2) +float chan2_full() +{ + return GetChan1(); +} + +subroutine(getchan1) +float chan1_empty() +{ + return 0.0; +} + +subroutine(getchan2) +float chan2_empty() +{ + return 0.0; +} + +void main() +{ + color = vec4(GetChan1(), GetChan2(), myin, 1.0); +} + + +[test] +clear color 0.0 0.0 1.0 0.0 +clear +subuniform GL_FRAGMENT_SHADER GetChan1 chan1_full +subuniform GL_FRAGMENT_SHADER GetChan2 chan2_empty +uniform float myin 1.0 +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 1.0 1.0 +subuniform GL_FRAGMENT_SHADER GetChan1 chan1_empty +subuniform GL_FRAGMENT_SHADER GetChan2 chan2_full +uniform float myin 1.0 +draw rect -1 -1 2 2 +probe all rgba 0.0 0.0 1.0 1.0 diff --git a/tests/spec/arb_shader_subroutine/execution/two-subroutines-uniform.shader_test b/tests/spec/arb_shader_subroutine/execution/two-subroutines-uniform.shader_test new file mode 100644 index 0000000..9068e95 --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/two-subroutines-uniform.shader_test @@ -0,0 +1,66 @@ +# two subroutine test adding a uniform in +# this makes sure normal uniforms and +# subroutine uniforms don't interfere. + +[require] +GLSL >= 1.50 +GL_ARB_shader_subroutine + +[vertex shader passthrough] + +[fragment shader] +#version 150 +#extension GL_ARB_shader_subroutine: enable + +uniform float myin; +out vec4 color; + +subroutine float getchan1(); +subroutine uniform getchan1 GetChan1; + +subroutine float getchan2(); +subroutine uniform getchan2 GetChan2; + +subroutine(getchan1) +float chan1_full() +{ + return 1.0; +} + +subroutine(getchan1) +float chan1_empty() +{ + return 0.0; +} + +subroutine(getchan2) +float chan2_full() +{ + return 1.0; +} + +subroutine(getchan2) +float chan2_empty() +{ + return 0.0; +} + +void main() +{ + color = vec4(GetChan1(), GetChan2(), myin, 1.0); +} + + +[test] +clear color 0.0 0.0 1.0 0.0 +clear +subuniform GL_FRAGMENT_SHADER GetChan1 chan1_full +subuniform GL_FRAGMENT_SHADER GetChan2 chan2_empty +uniform float myin 1.0 +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 1.0 1.0 +subuniform GL_FRAGMENT_SHADER GetChan1 chan1_empty +subuniform GL_FRAGMENT_SHADER GetChan2 chan2_full +uniform float myin 1.0 +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 1.0 1.0 diff --git a/tests/spec/arb_shader_subroutine/execution/two-subroutines.shader_test b/tests/spec/arb_shader_subroutine/execution/two-subroutines.shader_test new file mode 100644 index 0000000..b506cf1 --- /dev/null +++ b/tests/spec/arb_shader_subroutine/execution/two-subroutines.shader_test @@ -0,0 +1,63 @@ +# shader subroutine test using two +# shader subroutines with two functions +# in each. + +[require] +GLSL >= 1.50 +GL_ARB_shader_subroutine + +[vertex shader passthrough] + +[fragment shader] +#version 150 +#extension GL_ARB_shader_subroutine: enable + +out vec4 color; + +subroutine float getchan1(); +subroutine uniform getchan1 GetChan1; + +subroutine float getchan2(); +subroutine uniform getchan2 GetChan2; + +subroutine(getchan1) +float chan1_full() +{ + return 1.0; +} + +subroutine(getchan1) +float chan1_empty() +{ + return 0.0; +} + +subroutine(getchan2) +float chan2_full() +{ + return 1.0; +} + +subroutine(getchan2) +float chan2_empty() +{ + return 0.0; +} + +void main() +{ + color = vec4(GetChan1(), GetChan2(), 0.0, 1.0); +} + + +[test] +clear color 0.0 0.0 1.0 0.0 +clear +subuniform GL_FRAGMENT_SHADER GetChan1 chan1_full +subuniform GL_FRAGMENT_SHADER GetChan2 chan2_empty +draw rect -1 -1 2 2 +probe all rgba 1.0 0.0 0.0 1.0 +subuniform GL_FRAGMENT_SHADER GetChan1 chan1_empty +subuniform GL_FRAGMENT_SHADER GetChan2 chan2_full +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 -- 2.1.0 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit