diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir.h | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_io.c | 33 |
2 files changed, 17 insertions, 18 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 2a7713934bc..3d463840793 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2337,6 +2337,8 @@ void nir_lower_io(nir_shader *shader, nir_src *nir_get_io_offset_src(nir_intrinsic_instr *instr); nir_src *nir_get_io_vertex_index_src(nir_intrinsic_instr *instr); +bool nir_is_per_vertex_io(nir_variable *var, gl_shader_stage stage); + void nir_lower_io_types(nir_shader *shader); void nir_lower_vars_to_ssa(nir_shader *shader); diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 25cca186193..a7e7f148f13 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -65,26 +65,24 @@ nir_assign_var_locations(struct exec_list *var_list, unsigned *size, } /** - * Returns true if we're processing a stage whose inputs are arrays indexed - * by a vertex number (such as geometry shader inputs). + * Return true if the given variable is a per-vertex input/output array. + * (such as geometry shader inputs). */ -static bool -is_per_vertex_input(struct lower_io_state *state, nir_variable *var) +bool +nir_is_per_vertex_io(nir_variable *var, gl_shader_stage stage) { - gl_shader_stage stage = state->builder.shader->stage; + if (var->data.patch || !glsl_type_is_array(var->type)) + return false; - return var->data.mode == nir_var_shader_in && !var->data.patch && - (stage == MESA_SHADER_TESS_CTRL || - stage == MESA_SHADER_TESS_EVAL || - stage == MESA_SHADER_GEOMETRY); -} + if (var->data.mode == nir_var_shader_in) + return stage == MESA_SHADER_GEOMETRY || + stage == MESA_SHADER_TESS_CTRL || + stage == MESA_SHADER_TESS_EVAL; -static bool -is_per_vertex_output(struct lower_io_state *state, nir_variable *var) -{ - gl_shader_stage stage = state->builder.shader->stage; - return var->data.mode == nir_var_shader_out && !var->data.patch && - stage == MESA_SHADER_TESS_CTRL; + if (var->data.mode == nir_var_shader_out) + return stage == MESA_SHADER_TESS_CTRL; + + return false; } static nir_ssa_def * @@ -396,8 +394,7 @@ nir_lower_io_block(nir_block *block, b->cursor = nir_before_instr(instr); - const bool per_vertex = - is_per_vertex_input(state, var) || is_per_vertex_output(state, var); + const bool per_vertex = nir_is_per_vertex_io(var, b->shader->stage); nir_ssa_def *offset; nir_ssa_def *vertex_index = NULL; |