diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index d0147986220..756e6e1b277 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -1040,6 +1040,7 @@ v3d_nir_lower_vs_early(struct v3d_compile *c) NIR_PASS(_, c->s, nir_lower_io, nir_var_shader_in | nir_var_shader_out, type_size_vec4, (nir_lower_io_options)0); + c->s->info.disable_output_offset_src_constant_folding = true; /* For geometry stages using the same segment for inputs and outputs * we need to read all inputs before writing any output. If we switch @@ -1082,6 +1083,8 @@ v3d_nir_lower_gs_early(struct v3d_compile *c) NIR_PASS(_, c->s, nir_lower_io, nir_var_shader_in | nir_var_shader_out, type_size_vec4, (nir_lower_io_options)0); + c->s->info.disable_output_offset_src_constant_folding = true; + /* clean up nir_lower_io's deref_var remains and do a constant folding pass * on the code it generated. */ diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h index b082a6fc1ea..b66f6c61a7f 100644 --- a/src/compiler/shader_info.h +++ b/src/compiler/shader_info.h @@ -244,6 +244,12 @@ typedef struct shader_info { /* Whether flrp has been lowered. */ bool flrp_lowered:1; + /* Whether nir_opt_constant_folding should not fold offset srcs of + * IO intrinsics. + */ + bool disable_input_offset_src_constant_folding:1; + bool disable_output_offset_src_constant_folding:1; + /* Whether nir_lower_io has been called to lower derefs. * nir_variables for inputs and outputs might not be present in the IR. */ diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 0fdd8a4b254..1cfa7a884e7 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -2514,6 +2514,7 @@ vc4_shader_state_create(struct pipe_context *pctx, NIR_PASS(_, s, nir_lower_io, nir_var_shader_in | nir_var_shader_out | nir_var_uniform, type_size, (nir_lower_io_options)0); + s->info.disable_output_offset_src_constant_folding = true; NIR_PASS(_, s, nir_normalize_cubemap_coords); diff --git a/src/intel/compiler/brw/brw_nir.c b/src/intel/compiler/brw/brw_nir.c index 44d0fcce3d2..492103f44f4 100644 --- a/src/intel/compiler/brw/brw_nir.c +++ b/src/intel/compiler/brw/brw_nir.c @@ -1165,6 +1165,7 @@ brw_nir_lower_fs_outputs(nir_shader *nir) } NIR_PASS(_, nir, nir_lower_io, nir_var_shader_out, type_size_vec4, 0); + nir->info.disable_output_offset_src_constant_folding = true; } static bool diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index d084ff15eb6..a7d49adb748 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -6636,6 +6636,8 @@ nir_to_dxil(struct nir_shader *s, const struct nir_to_dxil_options *opts, NIR_PASS(_, s, nir_lower_frexp); NIR_PASS(_, s, nir_lower_flrp, 16 | 32 | 64, true); NIR_PASS(_, s, nir_lower_io, nir_var_shader_in | nir_var_shader_out, type_size_vec4, nir_lower_io_lower_64bit_to_32); + s->info.disable_input_offset_src_constant_folding = true; + s->info.disable_output_offset_src_constant_folding = true; NIR_PASS(_, s, dxil_nir_ensure_position_writes); NIR_PASS(_, s, dxil_nir_lower_system_values); NIR_PASS(_, s, nir_lower_io_to_scalar, nir_var_shader_in | nir_var_system_value | nir_var_shader_out, NULL, NULL);