glsl: Fix the precision of atomic counter builtin function args.
authorEmma Anholt <emma@anholt.net>
Thu, 2 Mar 2023 21:10:06 +0000 (13:10 -0800)
committerMarge Bot <emma+marge@anholt.net>
Tue, 21 Mar 2023 00:51:24 +0000 (00:51 +0000)
More special-casing dropped from GLSL lower_precision.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21666>

src/compiler/glsl/builtin_functions.cpp
src/compiler/glsl/lower_precision.cpp

index 8604e80..c827980 100644 (file)
@@ -7991,11 +7991,16 @@ builtin_builder::_interpolateAtSample(const glsl_type *type)
    return sig;
 }
 
+/* The highp isn't specified in the built-in function descriptions, but in the
+ * atomic counter description: "The default precision of all atomic types is
+ * highp. It is an error to declare an atomic type with a different precision or
+ * to specify the default precision for an atomic type to be lowp or mediump."
+ */
 ir_function_signature *
 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail,
                                            enum ir_intrinsic_id id)
 {
-   ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");
+   ir_variable *counter = in_highp_var(glsl_type::atomic_uint_type, "counter");
    MAKE_INTRINSIC(glsl_type::uint_type, id, avail, 1, counter);
    return sig;
 }
@@ -8004,7 +8009,7 @@ ir_function_signature *
 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail,
                                             enum ir_intrinsic_id id)
 {
-   ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");
+   ir_variable *counter = in_highp_var(glsl_type::atomic_uint_type, "counter");
    ir_variable *data = in_var(glsl_type::uint_type, "data");
    MAKE_INTRINSIC(glsl_type::uint_type, id, avail, 2, counter, data);
    return sig;
@@ -8014,7 +8019,7 @@ ir_function_signature *
 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail,
                                             enum ir_intrinsic_id id)
 {
-   ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");
+   ir_variable *counter = in_highp_var(glsl_type::atomic_uint_type, "counter");
    ir_variable *compare = in_var(glsl_type::uint_type, "compare");
    ir_variable *data = in_var(glsl_type::uint_type, "data");
    MAKE_INTRINSIC(glsl_type::uint_type, id, avail, 3, counter, compare, data);
@@ -8048,7 +8053,7 @@ ir_function_signature *
 builtin_builder::_atomic_counter_op(const char *intrinsic,
                                     builtin_available_predicate avail)
 {
-   ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");
+   ir_variable *counter = in_highp_var(glsl_type::atomic_uint_type, "atomic_counter");
    MAKE_SIG(glsl_type::uint_type, avail, 1, counter);
 
    ir_variable *retval = body.make_temp(glsl_type::uint_type, "atomic_retval");
@@ -8062,7 +8067,7 @@ ir_function_signature *
 builtin_builder::_atomic_counter_op1(const char *intrinsic,
                                      builtin_available_predicate avail)
 {
-   ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");
+   ir_variable *counter = in_highp_var(glsl_type::atomic_uint_type, "atomic_counter");
    ir_variable *data = in_var(glsl_type::uint_type, "data");
    MAKE_SIG(glsl_type::uint_type, avail, 2, counter, data);
 
@@ -8103,7 +8108,7 @@ ir_function_signature *
 builtin_builder::_atomic_counter_op2(const char *intrinsic,
                                     builtin_available_predicate avail)
 {
-   ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");
+   ir_variable *counter = in_highp_var(glsl_type::atomic_uint_type, "atomic_counter");
    ir_variable *compare = in_var(glsl_type::uint_type, "compare");
    ir_variable *data = in_var(glsl_type::uint_type, "data");
    MAKE_SIG(glsl_type::uint_type, avail, 3, counter, compare, data);
index 7265366..c07c5a8 100644 (file)
@@ -485,9 +485,7 @@ handle_call(ir_call *ir, const struct set *lowerable_rvalues)
        !strcmp(ir->callee_name(), "floatBitsToInt") ||
        !strcmp(ir->callee_name(), "floatBitsToUint") ||
        !strcmp(ir->callee_name(), "intBitsToFloat") ||
-       !strcmp(ir->callee_name(), "uintBitsToFloat") ||
-       /* Atomic functions are not lowered. */
-       strstr(ir->callee_name(), "atomic") == ir->callee_name())
+       !strcmp(ir->callee_name(), "uintBitsToFloat"))
       return GLSL_PRECISION_HIGH;
 
    /* Number of parameters to check if they are lowerable. */