summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2016-09-25 22:19:07 -0700
committerTimothy Arceri <timothy.arceri@collabora.com>2016-11-11 09:17:07 +1100
commitad9d4a4f8d57725305ab767551bf6a89b69c11e1 (patch)
tree59bbbc61306f2036ad9240f599f9df40a96ff158
parent561f2208bd6a952554e3bb043f6ff483a824a41c (diff)
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>
-rw-r--r--src/compiler/nir/nir.h2
-rw-r--r--src/compiler/nir/nir_lower_io.c33
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;