lima/ppir: refactor texture code to simplify scheduler
The 'varying fetch' pp instruction deals only with coordinates, and 'texture fetch' deals only with the sampler index. Previously it was not possible to clearly map ppir_op_load_coords and ppir_op_load_texture to pp instructions as the source coordinates were kept in the ppir_op_load_texture node, making this harder to maintain. The refactor is made with the attempt to clearly map ppir_op_load_coords to the 'varying fetch' and ppir_op_load_texture to the 'texture fetch'. The coordinates are still temporarily kept in the ppir_op_load_texture node as nir has both sampler and coordinates in a single instruction and it is only possible to output one ppir node during emit. But now after lowering, the sources are transferred to the (always) created ppir_op_load_coords node, and it should be possible to directly map them to their pp instructions from there onwards. Signed-off-by: Erico Nunes <nunes.erico@gmail.com> Reviewed-by: Qiang Yu <yuq825@gmail.com>
This commit is contained in:
parent
d2901de09e
commit
7f8ff686b7
|
@ -242,20 +242,7 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
|
|||
{
|
||||
ppir_load_texture_node *load_tex = ppir_node_to_load_texture(node);
|
||||
|
||||
if (ppir_node_has_single_pred(node)) {
|
||||
ppir_node *pred = ppir_node_first_pred(node);
|
||||
if (pred->op == ppir_op_load_varying) {
|
||||
/* If ldtex is the only successor of load_varying node
|
||||
* we're good. Just change load_varying op type to load_coords.
|
||||
*/
|
||||
if (ppir_node_has_single_succ(pred)) {
|
||||
pred->op = ppir_op_load_coords;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise we need to create load_coords node */
|
||||
/* Create load_coords node */
|
||||
ppir_load_node *load = ppir_node_create(block, ppir_op_load_coords, -1, 0);
|
||||
if (!load)
|
||||
return false;
|
||||
|
@ -264,19 +251,11 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
|
|||
ppir_debug("%s create load_coords node %d for %d\n",
|
||||
__FUNCTION__, load->node.index, node->index);
|
||||
|
||||
ppir_dest *dest = &load->dest;
|
||||
dest->type = ppir_target_ssa;
|
||||
dest->ssa.num_components = load_tex->src_coords.ssa->num_components;
|
||||
dest->ssa.live_in = INT_MAX;
|
||||
dest->ssa.live_out = 0;
|
||||
dest->write_mask = u_bit_consecutive(0, dest->ssa.num_components);
|
||||
load->dest.type = ppir_target_pipeline;
|
||||
load->dest.pipeline = ppir_pipeline_reg_discard;
|
||||
|
||||
load->src = load_tex->src_coords;
|
||||
|
||||
ppir_src *src = &load_tex->src_coords;
|
||||
src->type = ppir_target_ssa;
|
||||
src->ssa = &dest->ssa;
|
||||
|
||||
ppir_node_foreach_pred_safe(node, dep) {
|
||||
ppir_node *pred = dep->pred;
|
||||
ppir_node_remove_dep(dep);
|
||||
|
|
|
@ -382,7 +382,7 @@ static ppir_node *ppir_emit_tex(ppir_block *block, nir_instr *ni)
|
|||
case GLSL_SAMPLER_DIM_EXTERNAL:
|
||||
break;
|
||||
default:
|
||||
ppir_debug("unsupported sampler dim: %d\n", instr->sampler_dim);
|
||||
ppir_error("unsupported sampler dim: %d\n", instr->sampler_dim);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,6 @@ static ppir_node *ppir_emit_tex(ppir_block *block, nir_instr *ni)
|
|||
for (int i = 0; i < instr->coord_components; i++)
|
||||
node->src_coords.swizzle[i] = i;
|
||||
|
||||
assert(instr->num_srcs == 1);
|
||||
for (int i = 0; i < instr->num_srcs; i++) {
|
||||
switch (instr->src[i].src_type) {
|
||||
case nir_tex_src_coord:
|
||||
|
@ -399,7 +398,8 @@ static ppir_node *ppir_emit_tex(ppir_block *block, nir_instr *ni)
|
|||
u_bit_consecutive(0, instr->coord_components));
|
||||
break;
|
||||
default:
|
||||
ppir_debug("unknown texture source");
|
||||
ppir_error("unsupported texture source type\n");
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,14 +42,6 @@ static bool insert_to_load_tex(ppir_block *block, ppir_node *load_coords, ppir_n
|
|||
ppir_dest *dest = ppir_node_get_dest(ldtex);
|
||||
ppir_node *move = NULL;
|
||||
|
||||
ppir_load_node *load = ppir_node_to_load(load_coords);
|
||||
load->dest.type = ppir_target_pipeline;
|
||||
load->dest.pipeline = ppir_pipeline_reg_discard;
|
||||
|
||||
ppir_load_texture_node *load_texture = ppir_node_to_load_texture(ldtex);
|
||||
load_texture->src_coords.type = ppir_target_pipeline;
|
||||
load_texture->src_coords.pipeline = ppir_pipeline_reg_discard;
|
||||
|
||||
/* Insert load_coords to ldtex instruction */
|
||||
if (!ppir_instr_insert_node(ldtex->instr, load_coords))
|
||||
return false;
|
||||
|
|
|
@ -258,7 +258,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
ppir_node node;
|
||||
ppir_dest dest;
|
||||
ppir_src src_coords;
|
||||
ppir_src src_coords; /* not to be used after lowering */
|
||||
int sampler;
|
||||
int sampler_dim;
|
||||
} ppir_load_texture_node;
|
||||
|
|
|
@ -231,14 +231,6 @@ static ppir_reg *ppir_regalloc_build_liveness_info(ppir_compiler *comp)
|
|||
reg->live_out = node->instr->seq;
|
||||
break;
|
||||
}
|
||||
case ppir_node_type_load_texture:
|
||||
{
|
||||
ppir_load_texture_node *load_tex = ppir_node_to_load_texture(node);
|
||||
ppir_reg *reg = get_src_reg(&load_tex->src_coords);
|
||||
if (reg && node->instr->seq > reg->live_out)
|
||||
reg->live_out = node->instr->seq;
|
||||
break;
|
||||
}
|
||||
case ppir_node_type_branch:
|
||||
{
|
||||
ppir_branch_node *branch = ppir_node_to_branch(node);
|
||||
|
@ -319,12 +311,6 @@ static void ppir_regalloc_print_result(ppir_compiler *comp)
|
|||
printf("%d", ppir_target_get_src_reg_index(&load->src));
|
||||
break;
|
||||
}
|
||||
case ppir_node_type_load_texture:
|
||||
{
|
||||
ppir_load_texture_node *load_tex = ppir_node_to_load_texture(node);
|
||||
printf("%d", ppir_target_get_src_reg_index(&load_tex->src_coords));
|
||||
break;
|
||||
}
|
||||
case ppir_node_type_branch:
|
||||
{
|
||||
ppir_branch_node *branch = ppir_node_to_branch(node);
|
||||
|
@ -621,16 +607,6 @@ static bool ppir_regalloc_spill_reg(ppir_compiler *comp, ppir_reg *chosen)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case ppir_node_type_load_texture:
|
||||
{
|
||||
ppir_load_texture_node *load_tex = ppir_node_to_load_texture(node);
|
||||
reg = get_src_reg(&load_tex->src_coords);
|
||||
if (reg == chosen) {
|
||||
ppir_update_spilled_src(comp, block, node, &load_tex->src_coords,
|
||||
NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ppir_node_type_branch:
|
||||
{
|
||||
ppir_branch_node *branch = ppir_node_to_branch(node);
|
||||
|
|
Loading…
Reference in New Issue