From bb1873faad7f29986b62f9f13eb1d5930e71f0b9 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Tue, 19 Dec 2023 15:40:06 +1100 Subject: [PATCH] glsl: add additional lower mediump test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Part-of: --- .../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(