diff options
author | Qiang Yu <[email protected]> | 2019-04-21 09:54:46 +0800 |
---|---|---|
committer | Qiang Yu <[email protected]> | 2019-05-20 10:57:11 +0800 |
commit | 4a74e2813018aaa4ee7993c9fded481f80c0f0a9 (patch) | |
tree | 017b90e1849a58f435ad5c8c08b1d78a5e18cb2e /src/gallium/drivers/lima/ir | |
parent | ac779ff2b7ae2eff3021ab3a513a7913e0d31e39 (diff) |
lima/gpir: add helper function for emit load node
Reviewed-by: Vasily Khoruzhick <[email protected]>
Reviewed-by: Erico Nunes <[email protected]>
Signed-off-by: Qiang Yu <[email protected]>
Diffstat (limited to 'src/gallium/drivers/lima/ir')
-rw-r--r-- | src/gallium/drivers/lima/ir/gp/nir.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/gallium/drivers/lima/ir/gp/nir.c b/src/gallium/drivers/lima/ir/gp/nir.c index b12d93ff9e4..f38e2309619 100644 --- a/src/gallium/drivers/lima/ir/gp/nir.c +++ b/src/gallium/drivers/lima/ir/gp/nir.c @@ -153,37 +153,36 @@ static bool gpir_emit_alu(gpir_block *block, nir_instr *ni) return true; } +static gpir_node *gpir_create_load(gpir_block *block, nir_dest *dest, + int op, int index, int component) +{ + gpir_load_node *load = gpir_node_create_dest(block, op, dest); + if (unlikely(!load)) + return NULL; + + load->index = index; + load->component = component; + return &load->node; +} + static bool gpir_emit_intrinsic(gpir_block *block, nir_instr *ni) { nir_intrinsic_instr *instr = nir_instr_as_intrinsic(ni); switch (instr->intrinsic) { case nir_intrinsic_load_input: - { - gpir_load_node *load = - gpir_node_create_dest(block, gpir_op_load_attribute, &instr->dest); - if (unlikely(!load)) - return false; - - load->index = nir_intrinsic_base(instr); - load->component = nir_intrinsic_component(instr); - - return true; - } + return gpir_create_load(block, &instr->dest, + gpir_op_load_attribute, + nir_intrinsic_base(instr), + nir_intrinsic_component(instr)) != NULL; case nir_intrinsic_load_uniform: { - gpir_load_node *load = - gpir_node_create_dest(block, gpir_op_load_uniform, &instr->dest); - if (unlikely(!load)) - return false; - int offset = nir_intrinsic_base(instr); offset += (int)nir_src_as_float(instr->src[0]); - load->index = offset / 4; - load->component = offset % 4; - - return true; + return gpir_create_load(block, &instr->dest, + gpir_op_load_uniform, + offset / 4, offset % 4) != NULL; } case nir_intrinsic_store_output: { |