From: Timothy Arceri <[email protected]> vs-array-inout-self-assignment-vec2: Tests for nir assert.
vs-array-inout-self-assignment-vec2-swizzle: Test that the assignment is not optimised out if it involves a swizzle. Cc: Ilia Mirkin <[email protected]> --- ...-inout-self-assignment-vec2-swizzle.shader_test | 44 +++++++++++++++++++ ...vs-array-inout-self-assignment-vec2.shader_test | 49 ++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 tests/spec/glsl-1.20/execution/vs-array-inout-self-assignment-vec2-swizzle.shader_test create mode 100644 tests/spec/glsl-1.20/execution/vs-array-inout-self-assignment-vec2.shader_test diff --git a/tests/spec/glsl-1.20/execution/vs-array-inout-self-assignment-vec2-swizzle.shader_test b/tests/spec/glsl-1.20/execution/vs-array-inout-self-assignment-vec2-swizzle.shader_test new file mode 100644 index 0000000..5ca4030 --- /dev/null +++ b/tests/spec/glsl-1.20/execution/vs-array-inout-self-assignment-vec2-swizzle.shader_test @@ -0,0 +1,44 @@ +// Tests to make sure we don't optimise out an assignment that involves an +// array element being swizzled then assigned back to the same element. +[require] +GLSL >= 1.20 + +[vertex shader] +#version 120 +varying vec4 color; + +void array_mod(inout vec2 b[2]) +{ + b[0] = vec2(2.0); + b[1] = b[1].yx; +} + +void main() +{ + vec2 a[2]; + + a[0] = vec2(1.0); + a[1] = vec2(1.0, 2.0); + array_mod(a); + + if (a[0] == vec2(2.0) && a[1] == vec2(2.0, 1.0)) { + color = vec4(0, 1, 0, 1); + } else { + color = vec4(1, 0, 0, 1); + } + + gl_Position = gl_Vertex; +} + +[fragment shader] +#version 120 +varying vec4 color; + +void main() +{ + gl_FragColor = color; +} + +[test] +draw rect -1 -1 2 2 +probe all rgb 0 1 0 diff --git a/tests/spec/glsl-1.20/execution/vs-array-inout-self-assignment-vec2.shader_test b/tests/spec/glsl-1.20/execution/vs-array-inout-self-assignment-vec2.shader_test new file mode 100644 index 0000000..65bd10e --- /dev/null +++ b/tests/spec/glsl-1.20/execution/vs-array-inout-self-assignment-vec2.shader_test @@ -0,0 +1,49 @@ +// Tests a scenario in Mesa with function inout parameters which only +// seems to appear when an assignment is done to an array element followed by +// an assignment to another element where the element is assigned to itself. +// +// The result is we end up with an assignment in the IR where the lhs and rhs +// are referencing the same variable. This ends up tripping an assert, +// presumably the assignment should just be detected and optimised out. +[require] +GLSL >= 1.20 + +[vertex shader] +#version 120 +varying vec4 color; + +void array_mod(inout vec2 b[2]) +{ + b[0] = vec2(2.0); + b[1] = b[1].xy; +} + +void main() +{ + vec2 a[2]; + + a[0] = vec2(1.0); + a[1] = vec2(1.0, 2.0); + array_mod(a); + + if (a[0] == vec2(2.0) && a[1] == vec2(1.0, 2.0)) { + color = vec4(0, 1, 0, 1); + } else { + color = vec4(1, 0, 0, 1); + } + + gl_Position = gl_Vertex; +} + +[fragment shader] +#version 120 +varying vec4 color; + +void main() +{ + gl_FragColor = color; +} + +[test] +draw rect -1 -1 2 2 +probe all rgb 0 1 0 -- 2.4.3 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
