diff options
author | Qiang Yu <[email protected]> | 2019-05-15 10:52:39 +0800 |
---|---|---|
committer | Qiang Yu <[email protected]> | 2019-05-20 10:57:11 +0800 |
commit | a1d419603f757e8a8533f2fbf1dd136420acbd28 (patch) | |
tree | 532ff82a03c118a595c8695c6ac90b25ff39df89 /src | |
parent | a7688b27137f60db987c9626ab296028e9a5f752 (diff) |
lima/gpir: switch to use nir_lower_viewport_transform
Reviewed-by: Vasily Khoruzhick <[email protected]>
Reviewed-by: Erico Nunes <[email protected]>
Signed-off-by: Qiang Yu <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/lima/ir/gp/gpir.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/lima/ir/gp/lower.c | 100 | ||||
-rw-r--r-- | src/gallium/drivers/lima/ir/gp/nir.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_program.c | 1 |
4 files changed, 11 insertions, 101 deletions
diff --git a/src/gallium/drivers/lima/ir/gp/gpir.h b/src/gallium/drivers/lima/ir/gp/gpir.h index cbdf74d3a2e..e7f199033cd 100644 --- a/src/gallium/drivers/lima/ir/gp/gpir.h +++ b/src/gallium/drivers/lima/ir/gp/gpir.h @@ -319,7 +319,9 @@ typedef struct { struct lima_vs_shader_state; -#define GPIR_VECTOR_SSA_NUM 0 +#define GPIR_VECTOR_SSA_VIEWPORT_SCALE 0 +#define GPIR_VECTOR_SSA_VIEWPORT_OFFSET 1 +#define GPIR_VECTOR_SSA_NUM 2 typedef struct gpir_compiler { struct list_head block_list; diff --git a/src/gallium/drivers/lima/ir/gp/lower.c b/src/gallium/drivers/lima/ir/gp/lower.c index b52cb38347b..38c24851c2e 100644 --- a/src/gallium/drivers/lima/ir/gp/lower.c +++ b/src/gallium/drivers/lima/ir/gp/lower.c @@ -27,103 +27,6 @@ #include "gpir.h" #include "lima_context.h" -static gpir_node * -gpir_lower_create_insert_node(gpir_node *parent, gpir_node *child, - gpir_node *child2, gpir_op op) -{ - gpir_node *node = gpir_node_create(parent->block, op); - if (!node) - return NULL; - - gpir_alu_node *alu = gpir_node_to_alu(node); - alu->children[0] = child; - alu->children[1] = child2; - alu->num_child = 2; - gpir_node_insert_child(parent, child, node); - gpir_node_add_dep(node, child2, GPIR_DEP_INPUT); - list_addtail(&node->list, &parent->list); - return node; -} - -static bool gpir_lower_viewport_transform(gpir_compiler *comp) -{ - gpir_node *rcpw = NULL; - - /* rcpw = 1 / w */ - list_for_each_entry(gpir_block, block, &comp->block_list, list) { - list_for_each_entry(gpir_node, node, &block->node_list, list) { - if (node->op == gpir_op_store_varying) { - gpir_store_node *store = gpir_node_to_store(node); - if (store->index == 0 && store->component == 3) { - gpir_node *w = store->child; - - rcpw = gpir_node_create(block, gpir_op_rcp); - if (!rcpw) - return false; - list_addtail(&rcpw->list, &node->list); - - gpir_alu_node *alu = gpir_node_to_alu(rcpw); - alu->children[0] = w; - alu->num_child = 1; - store->child = rcpw; - - gpir_node_insert_child(node, w, rcpw); - goto found; - } - } - } - } - -found: - assert(rcpw); - - /* xyz = xyz * rcpw * scale + transition */ - list_for_each_entry(gpir_block, block, &comp->block_list, list) { - list_for_each_entry(gpir_node, node, &block->node_list, list) { - if (node->op == gpir_op_store_varying) { - gpir_store_node *store = gpir_node_to_store(node); - if (store->index == 0 && store->component < 3) { - gpir_node *xyz = store->child; - - gpir_node *mul1 = - gpir_lower_create_insert_node(node, xyz, rcpw, gpir_op_mul); - if (!mul1) - return false; - - gpir_load_node *scale = gpir_node_create(block, gpir_op_load_uniform); - if (!scale) - return false; - scale->index = comp->constant_base; - scale->component = store->component; - list_addtail(&scale->node.list, &node->list); - - gpir_node *mul2 = - gpir_lower_create_insert_node(node, mul1, &scale->node, gpir_op_mul); - if (!mul2) - return false; - - gpir_load_node *translate = gpir_node_create(block, gpir_op_load_uniform); - if (!translate) - return false; - translate->index = comp->constant_base + 1; - translate->component = store->component; - list_addtail(&translate->node.list, &node->list); - - gpir_node *add = - gpir_lower_create_insert_node(node, mul2, &translate->node, gpir_op_add); - if (!add) - return false; - - store->child = add; - } - } - } - } - - comp->constant_base += 2; - return true; -} - static bool gpir_lower_const(gpir_compiler *comp) { int num_constant = 0; @@ -488,9 +391,6 @@ static bool (*gpir_post_rsched_lower_funcs[gpir_op_num])(gpir_block *, gpir_node bool gpir_pre_rsched_lower_prog(gpir_compiler *comp) { - if (!gpir_lower_viewport_transform(comp)) - return false; - list_for_each_entry(gpir_block, block, &comp->block_list, list) { list_for_each_entry_safe(gpir_node, node, &block->node_list, list) { if (gpir_pre_rsched_lower_funcs[node->op] && diff --git a/src/gallium/drivers/lima/ir/gp/nir.c b/src/gallium/drivers/lima/ir/gp/nir.c index 655ea1a9b63..dcfbc450091 100644 --- a/src/gallium/drivers/lima/ir/gp/nir.c +++ b/src/gallium/drivers/lima/ir/gp/nir.c @@ -214,6 +214,10 @@ static bool gpir_emit_intrinsic(gpir_block *block, nir_instr *ni) gpir_op_load_uniform, offset / 4, offset % 4) != NULL; } + case nir_intrinsic_load_viewport_scale: + return gpir_create_vector_load(block, &instr->dest, GPIR_VECTOR_SSA_VIEWPORT_SCALE); + case nir_intrinsic_load_viewport_offset: + return gpir_create_vector_load(block, &instr->dest, GPIR_VECTOR_SSA_VIEWPORT_OFFSET); case nir_intrinsic_store_output: { gpir_store_node *store = gpir_node_create(block, gpir_op_store_varying); @@ -409,6 +413,9 @@ bool gpir_compile_nir(struct lima_vs_shader_state *prog, struct nir_shader *nir) gpir_node_print_prog_seq(comp); gpir_node_print_prog_dep(comp); + /* increase for viewport uniforms */ + comp->constant_base += GPIR_VECTOR_SSA_NUM; + if (!gpir_pre_rsched_lower_prog(comp)) goto err_out0; diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c index 08bedb1dd32..a2d687ec8b0 100644 --- a/src/gallium/drivers/lima/lima_program.c +++ b/src/gallium/drivers/lima/lima_program.c @@ -85,6 +85,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s) { bool progress; + NIR_PASS_V(s, nir_lower_viewport_transform); NIR_PASS_V(s, nir_lower_io, nir_var_all, type_size, 0); NIR_PASS_V(s, nir_lower_regs_to_ssa); NIR_PASS_V(s, nir_lower_load_const_to_scalar); |