Commit a7688b27 authored by Qiang Yu's avatar Qiang Yu

lima/gpir: support vector ssa load

Some vector sysval can't be lowered to scaler, so need to break
it to scaler in nir to gpir convertion.
Reviewed-by: Vasily Khoruzhick's avatarVasily Khoruzhick <anarsoul@gmail.com>
Reviewed-by: Erico Nunes's avatarErico Nunes <nunes.erico@gmail.com>
Signed-off-by: Qiang Yu's avatarQiang Yu <yuq825@gmail.com>
parent 4a74e281
......@@ -319,6 +319,8 @@ typedef struct {
struct lima_vs_shader_state;
#define GPIR_VECTOR_SSA_NUM 0
typedef struct gpir_compiler {
struct list_head block_list;
int cur_index;
......@@ -330,6 +332,12 @@ typedef struct gpir_compiler {
struct list_head reg_list;
int cur_reg;
/* lookup for vector ssa */
struct {
int ssa;
gpir_node *nodes[4];
} vector_ssa[GPIR_VECTOR_SSA_NUM];
struct lima_vs_shader_state *prog;
int constant_base;
} gpir_compiler;
......
......@@ -72,12 +72,22 @@ static void *gpir_node_create_dest(gpir_block *block, gpir_op op, nir_dest *dest
return gpir_node_create_reg(block, op, &dest->reg);
}
static gpir_node *gpir_node_find(gpir_block *block, gpir_node *succ, nir_src *src)
static gpir_node *gpir_node_find(gpir_block *block, gpir_node *succ, nir_src *src,
int channel)
{
gpir_node *pred;
gpir_node *pred = NULL;
if (src->is_ssa) {
pred = block->comp->var_nodes[src->ssa->index];
if (src->ssa->num_components > 1) {
for (int i = 0; i < GPIR_VECTOR_SSA_NUM; i++) {
if (block->comp->vector_ssa[i].ssa == src->ssa->index) {
pred = block->comp->vector_ssa[i].nodes[channel];
break;
}
}
} else
pred = block->comp->var_nodes[src->ssa->index];
assert(pred);
}
else {
......@@ -144,7 +154,7 @@ static bool gpir_emit_alu(gpir_block *block, nir_instr *ni)
nir_alu_src *src = instr->src + i;
node->children_negate[i] = src->negate;
gpir_node *child = gpir_node_find(block, &node->node, &src->src);
gpir_node *child = gpir_node_find(block, &node->node, &src->src, src->swizzle[0]);
node->children[i] = child;
gpir_node_add_dep(&node->node, child, GPIR_DEP_INPUT);
......@@ -165,6 +175,26 @@ static gpir_node *gpir_create_load(gpir_block *block, nir_dest *dest,
return &load->node;
}
static bool gpir_create_vector_load(gpir_block *block, nir_dest *dest, int index)
{
assert(dest->is_ssa);
assert(index < GPIR_VECTOR_SSA_NUM);
block->comp->vector_ssa[index].ssa = dest->ssa.index;
for (int i = 0; i < dest->ssa.num_components; i++) {
gpir_node *node = gpir_create_load(block, dest, gpir_op_load_uniform,
block->comp->constant_base + index, i);
if (!node)
return false;
block->comp->vector_ssa[index].nodes[i] = node;
snprintf(node->name, sizeof(node->name), "ssa%d.%c", dest->ssa.index, "xyzw"[i]);
}
return true;
}
static bool gpir_emit_intrinsic(gpir_block *block, nir_instr *ni)
{
nir_intrinsic_instr *instr = nir_instr_as_intrinsic(ni);
......@@ -194,7 +224,7 @@ static bool gpir_emit_intrinsic(gpir_block *block, nir_instr *ni)
store->index = nir_intrinsic_base(instr);
store->component = nir_intrinsic_component(instr);
gpir_node *child = gpir_node_find(block, &store->node, instr->src);
gpir_node *child = gpir_node_find(block, &store->node, instr->src, 0);
store->child = child;
gpir_node_add_dep(&store->node, child, GPIR_DEP_INPUT);
......@@ -348,6 +378,9 @@ static gpir_compiler *gpir_compiler_create(void *prog, unsigned num_reg, unsigne
for (int i = 0; i < num_reg; i++)
gpir_create_reg(comp);
for (int i = 0; i < GPIR_VECTOR_SSA_NUM; i++)
comp->vector_ssa[i].ssa = -1;
comp->var_nodes = rzalloc_array(comp, gpir_node *, num_ssa);
comp->prog = prog;
return comp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment