From 4c045ad11eddaf6c18019fbaa02ffcae20628848 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 10 May 2021 08:54:50 +0200 Subject: [PATCH] nir/linker: add option to ignore the IO precisions for better varying packing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backends that don't handle IO component precision can pack more varyings into one slot if the linker ignores the precision. If the IO is vectorized then this can save IO instructions. Related: 165a69d2f74aefe80b070209e77950446a97c8b5 nir: handle mediump varyings in varying compaction helpers Signed-off-by: Gert Wollny Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir.h | 5 +++++ src/compiler/nir/nir_linking_helpers.c | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 23bd1172559..5eda51c30f6 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3445,6 +3445,11 @@ typedef struct nir_shader_compiler_options { bool lower_uniforms_to_ubo; + /* If the precision is ignored, backends that don't handle + * different precisions when passing data between stages and use + * vectorized IO can pack more varyings when linking. */ + bool linker_ignore_precision; + nir_lower_int64_options lower_int64_options; nir_lower_doubles_options lower_doubles_options; nir_divergence_options divergence_analysis_options; diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c index fa451c33389..be4144ade86 100644 --- a/src/compiler/nir/nir_linking_helpers.c +++ b/src/compiler/nir/nir_linking_helpers.c @@ -582,9 +582,9 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer, vc_info->interp_loc = get_interp_loc(in_var); vc_info->is_32bit = glsl_type_is_32bit(type); vc_info->is_patch = in_var->data.patch; - vc_info->is_mediump = - in_var->data.precision == GLSL_PRECISION_MEDIUM || - in_var->data.precision == GLSL_PRECISION_LOW; + vc_info->is_mediump = !producer->options->linker_ignore_precision && + (in_var->data.precision == GLSL_PRECISION_MEDIUM || + in_var->data.precision == GLSL_PRECISION_LOW); vc_info->is_intra_stage_only = false; vc_info->initialised = true; } @@ -647,9 +647,9 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer, vc_info->interp_loc = get_interp_loc(out_var); vc_info->is_32bit = glsl_type_is_32bit(type); vc_info->is_patch = out_var->data.patch; - vc_info->is_mediump = - out_var->data.precision == GLSL_PRECISION_MEDIUM || - out_var->data.precision == GLSL_PRECISION_LOW; + vc_info->is_mediump = !producer->options->linker_ignore_precision && + (out_var->data.precision == GLSL_PRECISION_MEDIUM || + out_var->data.precision == GLSL_PRECISION_LOW); vc_info->is_intra_stage_only = true; vc_info->initialised = true; }