nir: Generalize the "is per-vertex variable?" helpers and export them.
I want this function for nir_gather_info(), and realized it's basically the same as the ones in nir_lower_io(). Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
This commit is contained in:

committed by
Timothy Arceri

parent
561f2208bd
commit
ad9d4a4f8d
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user