nir/lower_io: add a new doubles-only 64bit lowering option
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 4 Aug 2023 18:59:14 +0000 (14:59 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Aug 2023 09:02:53 +0000 (09:02 +0000)
this allows lowering only 64bit float operations for drivers that
support 64bit integers

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24565>

src/compiler/nir/nir.h
src/compiler/nir/nir_lower_io.c

index 1dd90bb..15997fc 100644 (file)
@@ -4883,6 +4883,11 @@ typedef enum {
     * modes.
     */
    nir_lower_io_lower_64bit_to_32 = (1 << 0),
+   /* If set, this causes the subset of 64-bit IO operations involving floats to be lowered on-the-fly
+    * to 32-bit operations.  This is only valid for nir_var_shader_in/out
+    * modes.
+    */
+   nir_lower_io_lower_64bit_float_to_32 = (1 << 1),
 } nir_lower_io_options;
 bool nir_lower_io(nir_shader *shader,
                   nir_variable_mode modes,
index ebf6388..38ed2a8 100644 (file)
@@ -345,8 +345,9 @@ lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state,
            nir_ssa_def *array_index, nir_variable *var, nir_ssa_def *offset,
            unsigned component, const struct glsl_type *type)
 {
+   const bool lower_double = !glsl_type_is_integer(type) && state->options & nir_lower_io_lower_64bit_float_to_32;
    if (intrin->dest.ssa.bit_size == 64 &&
-       (state->options & nir_lower_io_lower_64bit_to_32)) {
+       (lower_double || (state->options & nir_lower_io_lower_64bit_to_32))) {
       nir_builder *b = &state->builder;
 
       const unsigned slot_size = state->type_size(glsl_dvec_type(2), false);
@@ -456,8 +457,9 @@ lower_store(nir_intrinsic_instr *intrin, struct lower_io_state *state,
             nir_ssa_def *array_index, nir_variable *var, nir_ssa_def *offset,
             unsigned component, const struct glsl_type *type)
 {
+   const bool lower_double = !glsl_type_is_integer(type) && state->options & nir_lower_io_lower_64bit_float_to_32;
    if (intrin->src[1].ssa->bit_size == 64 &&
-       (state->options & nir_lower_io_lower_64bit_to_32)) {
+       (lower_double || (state->options & nir_lower_io_lower_64bit_to_32))) {
       nir_builder *b = &state->builder;
 
       const unsigned slot_size = state->type_size(glsl_dvec_type(2), false);