summaryrefslogtreecommitdiff
path: root/tests/spec/glsl-1.20/execution
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2019-05-07 10:04:28 -0700
committerIan Romanick <ian.d.romanick@intel.com>2019-05-16 13:35:44 -0700
commit0a7b72021c0802531c23282ecedbfe46834586da (patch)
treeb9927ad5b293b48a232c42f987eda044dd96997c /tests/spec/glsl-1.20/execution
parenta5e466d7a8bc68e575815be01deeab4ed510bcc7 (diff)
glsl-1.20: Test mix(±1, b, c)
Mesa commit 5b908db604b ("nir/flrp: Lower flrp(±1, b, c) and flrp(a, ±1, c) differently") added an optimization for the lowering of mix() on platforms that lack a native LRP instruction. There was a bug in this lowering, and this test exercises it. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'tests/spec/glsl-1.20/execution')
-rw-r--r--tests/spec/glsl-1.20/execution/fs-mix-1.0.shader_test40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.20/execution/fs-mix-1.0.shader_test b/tests/spec/glsl-1.20/execution/fs-mix-1.0.shader_test
new file mode 100644
index 000000000..8d2016b9e
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/fs-mix-1.0.shader_test
@@ -0,0 +1,40 @@
+# In commit 5b908db604b ("nir/flrp: Lower flrp(±1, b, c) and flrp(a,
+# ±1, c) differently"), Mesa added an optimization for the lowering of
+# mix() on platforms that lack a native LRP instruction. There was a
+# bug in this lowering, and this test exercises it.
+
+[require]
+GLSL >= 1.20
+
+[vertex shader passthrough]
+
+[fragment shader]
+
+uniform vec4 p[] = vec4[](
+ vec4(1.0, 0.5, 1.0, 0.0),
+ vec4(-1.0, 0.5, 0.0, -1.0),
+ vec4(2.0, 1.0, 2.0, 2.0),
+ vec4(2.0, 0.5, 1.5, 0.5)
+);
+
+void
+main()
+{
+ bool pass = true;
+
+ for (int i = 0; i < p.length(); i++) {
+ if (mix(1.0, p[i].x, p[i].y) != p[i].z)
+ pass = false;
+
+ if (mix(-1.0, p[i].x, p[i].y) != p[i].w)
+ pass = false;
+ }
+
+ gl_FragColor = pass ? vec4(0.0, 1.0, 0.0, 1.0)
+ : vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+
+[test]
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0