summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-08-12 10:57:31 -0700
committerKenneth Graunke <[email protected]>2015-08-19 19:29:22 -0700
commited2afec3fc2210ee737216981a41df8a396b11f6 (patch)
tree3a34efa54b429ab31fe88d5536da094370524c51 /src/glsl
parentffe6c6ad5f719dedd1b6b95e8590e3f20b23d340 (diff)
nir: Pull nir_lower_io's load_op selection into a helper function.
Makes the function a bit smaller. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/nir/nir_lower_io.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index 71bfd347c1a..f3d11d4a553 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -299,6 +299,25 @@ get_io_offset(nir_deref_var *deref, nir_instr *instr, nir_src *indirect,
return base_offset;
}
+static nir_intrinsic_op
+load_op(nir_variable_mode mode, bool has_indirect)
+{
+ nir_intrinsic_op op;
+ switch (mode) {
+ case nir_var_shader_in:
+ op = has_indirect ? nir_intrinsic_load_input_indirect :
+ nir_intrinsic_load_input;
+ break;
+ case nir_var_uniform:
+ op = has_indirect ? nir_intrinsic_load_uniform_indirect :
+ nir_intrinsic_load_uniform;
+ break;
+ default:
+ unreachable("Unknown variable mode");
+ }
+ return op;
+}
+
static bool
nir_lower_io_block(nir_block *block, void *void_state)
{
@@ -318,23 +337,9 @@ nir_lower_io_block(nir_block *block, void *void_state)
bool has_indirect = deref_has_indirect(intrin->variables[0]);
- /* Figure out the opcode */
- nir_intrinsic_op load_op;
- switch (mode) {
- case nir_var_shader_in:
- load_op = has_indirect ? nir_intrinsic_load_input_indirect :
- nir_intrinsic_load_input;
- break;
- case nir_var_uniform:
- load_op = has_indirect ? nir_intrinsic_load_uniform_indirect :
- nir_intrinsic_load_uniform;
- break;
- default:
- unreachable("Unknown variable mode");
- }
-
- nir_intrinsic_instr *load = nir_intrinsic_instr_create(state->mem_ctx,
- load_op);
+ nir_intrinsic_instr *load =
+ nir_intrinsic_instr_create(state->mem_ctx,
+ load_op(mode, has_indirect));
load->num_components = intrin->num_components;
nir_src indirect;