diff options
Diffstat (limited to 'src/broadcom')
-rw-r--r-- | src/broadcom/compiler/v3d_nir_lower_io.c | 42 | ||||
-rw-r--r-- | src/broadcom/compiler/vir.c | 16 |
2 files changed, 13 insertions, 45 deletions
diff --git a/src/broadcom/compiler/v3d_nir_lower_io.c b/src/broadcom/compiler/v3d_nir_lower_io.c index 9cdcc02195c..10bc25811a8 100644 --- a/src/broadcom/compiler/v3d_nir_lower_io.c +++ b/src/broadcom/compiler/v3d_nir_lower_io.c @@ -52,44 +52,6 @@ replace_intrinsic_with_vec(nir_builder *b, nir_intrinsic_instr *intr, } static void -v3d_nir_lower_output(struct v3d_compile *c, nir_builder *b, - nir_intrinsic_instr *intr) -{ - nir_variable *output_var = NULL; - nir_foreach_variable(var, &c->s->outputs) { - if (var->data.driver_location == nir_intrinsic_base(intr)) { - output_var = var; - break; - } - } - assert(output_var); - - if (c->vs_key) { - int slot = output_var->data.location; - bool used = false; - - switch (slot) { - case VARYING_SLOT_PSIZ: - case VARYING_SLOT_POS: - used = true; - break; - - default: - for (int i = 0; i < c->vs_key->num_fs_inputs; i++) { - if (v3d_slot_get_slot(c->vs_key->fs_inputs[i]) == slot) { - used = true; - break; - } - } - break; - } - - if (!used) - nir_instr_remove(&intr->instr); - } -} - -static void v3d_nir_lower_uniform(struct v3d_compile *c, nir_builder *b, nir_intrinsic_instr *intr) { @@ -135,10 +97,6 @@ v3d_nir_lower_io_instr(struct v3d_compile *c, nir_builder *b, case nir_intrinsic_load_input: break; - case nir_intrinsic_store_output: - v3d_nir_lower_output(c, b, intr); - break; - case nir_intrinsic_load_uniform: v3d_nir_lower_uniform(c, b, intr); break; diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index faad6541151..3f5a28d1be0 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -719,13 +719,23 @@ uint64_t *v3d_compile_vs(const struct v3d_compiler *compiler, c->vs_key = key; - /* Split our input vars and dead code eliminate the unused + /* Split our I/O vars and dead code eliminate the unused * components. */ - NIR_PASS_V(c->s, nir_lower_io_to_scalar_early, nir_var_shader_in); + NIR_PASS_V(c->s, nir_lower_io_to_scalar_early, + nir_var_shader_in | nir_var_shader_out); + uint64_t used_outputs[4] = {0}; + for (int i = 0; i < c->vs_key->num_fs_inputs; i++) { + int slot = v3d_slot_get_slot(c->vs_key->fs_inputs[i]); + int comp = v3d_slot_get_component(c->vs_key->fs_inputs[i]); + used_outputs[comp] |= 1ull << slot; + } + NIR_PASS_V(c->s, nir_remove_unused_io_vars, + &c->s->outputs, used_outputs, NULL); /* demotes to globals */ + NIR_PASS_V(c->s, nir_lower_global_vars_to_local); v3d_optimize_nir(c->s); NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_shader_in); - NIR_PASS_V(c->s, nir_lower_io, nir_var_shader_in, + NIR_PASS_V(c->s, nir_lower_io, nir_var_shader_in | nir_var_shader_out, type_size_vec4, (nir_lower_io_options)0); |