From 550f3dc437021c8b512687943fc955906f380d6f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 4 Aug 2023 14:59:14 -0400 Subject: [PATCH] nir/lower_io: add a new doubles-only 64bit lowering option MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit this allows lowering only 64bit float operations for drivers that support 64bit integers Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir.h | 5 +++++ src/compiler/nir/nir_lower_io.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 1dd90bb..15997fc 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -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, diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index ebf6388..38ed2a8 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -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); -- 2.7.4