Module: Mesa
Branch: main
Commit: bb1873faad7f29986b62f9f13eb1d5930e71f0b9
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb1873faad7f29986b62f9f13eb1d5930e71f0b9

Author: Timothy Arceri <[email protected]>
Date:   Tue Dec 19 15:40:06 2023 +1100

glsl: add additional lower mediump test

There were tests for inputs and inout, but no test for out which turned
out to not be behaving correctly.

Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26755>

---

 src/compiler/glsl/tests/test_gl_lower_mediump.cpp | 30 +++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/compiler/glsl/tests/test_gl_lower_mediump.cpp 
b/src/compiler/glsl/tests/test_gl_lower_mediump.cpp
index 0dd0ecf9dcf..1310913d677 100644
--- a/src/compiler/glsl/tests/test_gl_lower_mediump.cpp
+++ b/src/compiler/glsl/tests/test_gl_lower_mediump.cpp
@@ -474,6 +474,36 @@ TEST_F(gl_nir_lower_mediump_test, func_args_inout_mediump)
    EXPECT_EQ(op_dest_bits(nir_op_fmul), 16);
 }
 
+TEST_F(gl_nir_lower_mediump_test, func_args_in_out_mediump)
+{
+   ASSERT_NO_FATAL_FAILURE(compile(
+       R"(#version 310 es
+         precision highp float; /* Make sure that default highp temps in 
function handling don't break our mediump inout. */
+         uniform highp float a, b;
+         out float result;
+
+         void func(mediump float x, mediump float y, out mediump float w)
+         {
+            w = x * y; /* should be mediump due to x and y, but propagating 
qualifiers from a,b by inlining could trick it. */
+         }
+
+         void main()
+         {
+            /* The spec says "function input and output is done through copies,
+             * and therefore qualifiers do not have to match."  So we use a
+             * highp here for our mediump out.
+             */
+            highp float x;
+            func(a, b, x);
+            result = x;
+         }
+    )"));
+
+   EXPECT_PRED_FORMAT2(glsl_ir_contains, fs_ir, "expression float16_t * ");
+
+   EXPECT_EQ(op_dest_bits(nir_op_fmul), 16);
+}
+
 TEST_F(gl_nir_lower_mediump_test, func_args_inout_highp)
 {
    ASSERT_NO_FATAL_FAILURE(compile(

Reply via email to