summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-08-12 15:14:35 -0700
committerKenneth Graunke <[email protected]>2015-10-01 10:58:30 -0700
commit39a1d36a67974dd9fc3c0d834d6a117cdfed8f33 (patch)
tree8a552754b8dcf9f2c3accf4ef49b7be6307cc085 /src/glsl/nir
parent1c6689bf03fe500cc1bc55d7c2039c0aa3ae095c (diff)
nir: Allow nir_lower_io() to only lower one type of variable.
We may want to use different type_size functions for (e.g.) inputs vs. uniforms. Passing in -1 for mode ignores this, handling all modes as before. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/glsl/nir')
-rw-r--r--src/glsl/nir/nir.h1
-rw-r--r--src/glsl/nir/nir_lower_io.c21
2 files changed, 18 insertions, 4 deletions
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index d0c7b04a49f..bf5d41d43a9 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1822,6 +1822,7 @@ void nir_assign_var_locations(struct exec_list *var_list,
int (*type_size)(const struct glsl_type *));
void nir_lower_io(nir_shader *shader,
+ nir_variable_mode mode,
int (*type_size)(const struct glsl_type *));
void nir_lower_vars_to_ssa(nir_shader *shader);
diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index 9f79c5606ca..f32c09d04a2 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -38,6 +38,7 @@ struct lower_io_state {
nir_builder builder;
void *mem_ctx;
int (*type_size)(const struct glsl_type *type);
+ nir_variable_mode mode;
};
void
@@ -154,9 +155,17 @@ nir_lower_io_block(nir_block *block, void *void_state)
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+ if (intrin->intrinsic != nir_intrinsic_load_var &&
+ intrin->intrinsic != nir_intrinsic_store_var)
+ continue;
+
+ nir_variable_mode mode = intrin->variables[0]->var->data.mode;
+
+ if (state->mode != -1 && state->mode != mode)
+ continue;
+
switch (intrin->intrinsic) {
case nir_intrinsic_load_var: {
- nir_variable_mode mode = intrin->variables[0]->var->data.mode;
if (mode != nir_var_shader_in && mode != nir_var_uniform)
continue;
@@ -239,12 +248,15 @@ nir_lower_io_block(nir_block *block, void *void_state)
}
static void
-nir_lower_io_impl(nir_function_impl *impl, int(*type_size)(const struct glsl_type *))
+nir_lower_io_impl(nir_function_impl *impl,
+ nir_variable_mode mode,
+ int (*type_size)(const struct glsl_type *))
{
struct lower_io_state state;
nir_builder_init(&state.builder, impl);
state.mem_ctx = ralloc_parent(impl);
+ state.mode = mode;
state.type_size = type_size;
nir_foreach_block(impl, nir_lower_io_block, &state);
@@ -254,10 +266,11 @@ nir_lower_io_impl(nir_function_impl *impl, int(*type_size)(const struct glsl_typ
}
void
-nir_lower_io(nir_shader *shader, int(*type_size)(const struct glsl_type *))
+nir_lower_io(nir_shader *shader, nir_variable_mode mode,
+ int (*type_size)(const struct glsl_type *))
{
nir_foreach_overload(shader, overload) {
if (overload->impl)
- nir_lower_io_impl(overload->impl, type_size);
+ nir_lower_io_impl(overload->impl, mode, type_size);
}
}