mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
lima/ppir: rework tex lowering
Move steps from lowering to emit, since they can be done earlier in a single place, rather than in two-steps. Signed-off-by: Erico Nunes <nunes.erico@gmail.com> Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4975>
This commit is contained in:
parent
92611e21c1
commit
a4b7699d84
3 changed files with 67 additions and 64 deletions
|
|
@ -160,42 +160,7 @@ static bool ppir_lower_ddxy(ppir_block *block, ppir_node *node)
|
|||
|
||||
static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
|
||||
{
|
||||
ppir_load_texture_node *load_tex = ppir_node_to_load_texture(node);
|
||||
ppir_dest *dest = ppir_node_get_dest(node);
|
||||
ppir_node *src_coords = ppir_node_get_src(node, 0)->node;
|
||||
ppir_load_node *load = NULL;
|
||||
|
||||
if (src_coords && ppir_node_has_single_src_succ(src_coords) &&
|
||||
(src_coords->op == ppir_op_load_coords))
|
||||
load = ppir_node_to_load(src_coords);
|
||||
else {
|
||||
/* Create load_coords node */
|
||||
load = ppir_node_create(block, ppir_op_load_coords_reg, -1, 0);
|
||||
if (!load)
|
||||
return false;
|
||||
list_addtail(&load->node.list, &node->list);
|
||||
|
||||
load->src = load_tex->src[0];
|
||||
load->num_src = 1;
|
||||
if (load_tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE)
|
||||
load->num_components = 3;
|
||||
else
|
||||
load->num_components = 2;
|
||||
|
||||
ppir_debug("%s create load_coords node %d for %d\n",
|
||||
__FUNCTION__, load->node.index, node->index);
|
||||
|
||||
ppir_node_foreach_pred_safe(node, dep) {
|
||||
ppir_node *pred = dep->pred;
|
||||
ppir_node_remove_dep(dep);
|
||||
ppir_node_add_dep(&load->node, pred, ppir_dep_src);
|
||||
}
|
||||
ppir_node_add_dep(node, &load->node, ppir_dep_src);
|
||||
}
|
||||
|
||||
assert(load);
|
||||
load_tex->src[0].type = load->dest.type = ppir_target_pipeline;
|
||||
load_tex->src[0].pipeline = load->dest.pipeline = ppir_pipeline_reg_discard;
|
||||
|
||||
/* Always create move node since there can be successors in other blocks */
|
||||
ppir_node *move = ppir_node_insert_mov(node);
|
||||
|
|
|
|||
|
|
@ -99,20 +99,6 @@ static void ppir_node_add_src(ppir_compiler *comp, ppir_node *node,
|
|||
|
||||
if (ns->is_ssa) {
|
||||
child = comp->var_nodes[ns->ssa->index];
|
||||
switch (child->op) {
|
||||
case ppir_op_load_varying:
|
||||
/* If at least one successor is load_texture, promote it to
|
||||
* load_coords to ensure that is has exactly one successor */
|
||||
if (node->op == ppir_op_load_texture) {
|
||||
nir_tex_src *nts = (nir_tex_src *)ns;
|
||||
if (nts->src_type == nir_tex_src_coord)
|
||||
child->op = ppir_op_load_coords;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (child->op != ppir_op_undef)
|
||||
ppir_node_add_dep(node, child, ppir_dep_src);
|
||||
}
|
||||
|
|
@ -459,6 +445,19 @@ static bool ppir_emit_tex(ppir_block *block, nir_instr *ni)
|
|||
return false;
|
||||
}
|
||||
|
||||
switch (instr->sampler_dim) {
|
||||
case GLSL_SAMPLER_DIM_2D:
|
||||
case GLSL_SAMPLER_DIM_CUBE:
|
||||
case GLSL_SAMPLER_DIM_RECT:
|
||||
case GLSL_SAMPLER_DIM_EXTERNAL:
|
||||
break;
|
||||
default:
|
||||
ppir_error("unsupported sampler dim: %d\n", instr->sampler_dim);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* emit ld_tex node */
|
||||
|
||||
unsigned mask = 0;
|
||||
if (!instr->dest.is_ssa)
|
||||
mask = u_bit_consecutive(0, nir_tex_instr_dest_size(instr));
|
||||
|
|
@ -468,18 +467,6 @@ static bool ppir_emit_tex(ppir_block *block, nir_instr *ni)
|
|||
return false;
|
||||
|
||||
node->sampler = instr->texture_index;
|
||||
|
||||
switch (instr->sampler_dim) {
|
||||
case GLSL_SAMPLER_DIM_2D:
|
||||
case GLSL_SAMPLER_DIM_CUBE:
|
||||
case GLSL_SAMPLER_DIM_RECT:
|
||||
case GLSL_SAMPLER_DIM_EXTERNAL:
|
||||
break;
|
||||
default:
|
||||
ppir_error("unsupported sampler dim: %d\n", instr->sampler_dim);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->sampler_dim = instr->sampler_dim;
|
||||
|
||||
for (int i = 0; i < instr->coord_components; i++)
|
||||
|
|
@ -487,11 +474,25 @@ static bool ppir_emit_tex(ppir_block *block, nir_instr *ni)
|
|||
|
||||
for (int i = 0; i < instr->num_srcs; i++) {
|
||||
switch (instr->src[i].src_type) {
|
||||
case nir_tex_src_coord:
|
||||
case nir_tex_src_coord: {
|
||||
nir_src *ns = &instr->src[i].src;
|
||||
if (ns->is_ssa) {
|
||||
ppir_node *child = block->comp->var_nodes[ns->ssa->index];
|
||||
if (child->op == ppir_op_load_varying) {
|
||||
/* If the successor is load_texture, promote it to load_coords */
|
||||
nir_tex_src *nts = (nir_tex_src *)ns;
|
||||
if (nts->src_type == nir_tex_src_coord)
|
||||
child->op = ppir_op_load_coords;
|
||||
}
|
||||
}
|
||||
|
||||
/* src[0] is not used by the ld_tex instruction but ensures
|
||||
* correct scheduling due to the pipeline dependency */
|
||||
ppir_node_add_src(block->comp, &node->node, &node->src[0], &instr->src[i].src,
|
||||
u_bit_consecutive(0, instr->coord_components));
|
||||
node->num_src++;
|
||||
break;
|
||||
}
|
||||
case nir_tex_src_bias:
|
||||
case nir_tex_src_lod:
|
||||
node->lod_bias_en = true;
|
||||
|
|
@ -506,6 +507,44 @@ static bool ppir_emit_tex(ppir_block *block, nir_instr *ni)
|
|||
}
|
||||
|
||||
list_addtail(&node->node.list, &block->node_list);
|
||||
|
||||
/* validate load coords node */
|
||||
|
||||
ppir_node *src_coords = ppir_node_get_src(&node->node, 0)->node;
|
||||
ppir_load_node *load = NULL;
|
||||
|
||||
if (src_coords && ppir_node_has_single_src_succ(src_coords) &&
|
||||
(src_coords->op == ppir_op_load_coords))
|
||||
load = ppir_node_to_load(src_coords);
|
||||
else {
|
||||
/* Create load_coords node */
|
||||
load = ppir_node_create(block, ppir_op_load_coords_reg, -1, 0);
|
||||
if (!load)
|
||||
return false;
|
||||
list_addtail(&load->node.list, &block->node_list);
|
||||
|
||||
load->src = node->src[0];
|
||||
load->num_src = 1;
|
||||
if (node->sampler_dim == GLSL_SAMPLER_DIM_CUBE)
|
||||
load->num_components = 3;
|
||||
else
|
||||
load->num_components = 2;
|
||||
|
||||
ppir_debug("%s create load_coords node %d for %d\n",
|
||||
__FUNCTION__, load->index, node->node.index);
|
||||
|
||||
ppir_node_foreach_pred_safe((&node->node), dep) {
|
||||
ppir_node *pred = dep->pred;
|
||||
ppir_node_remove_dep(dep);
|
||||
ppir_node_add_dep(&load->node, pred, ppir_dep_src);
|
||||
}
|
||||
ppir_node_add_dep(&node->node, &load->node, ppir_dep_src);
|
||||
}
|
||||
|
||||
assert(load);
|
||||
node->src[0].type = load->dest.type = ppir_target_pipeline;
|
||||
node->src[0].pipeline = load->dest.pipeline = ppir_pipeline_reg_discard;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -270,8 +270,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
ppir_node node;
|
||||
ppir_dest dest;
|
||||
ppir_src src[2]; /* src[0] temporarily stores src_coords,
|
||||
not to be used after lowering */
|
||||
ppir_src src[2];
|
||||
int num_src;
|
||||
int sampler;
|
||||
int sampler_dim;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue