summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/lima
diff options
context:
space:
mode:
authorQiang Yu <[email protected]>2019-05-15 10:39:57 +0800
committerQiang Yu <[email protected]>2019-05-20 10:57:11 +0800
commita7688b27137f60db987c9626ab296028e9a5f752 (patch)
tree5b872a3ba62b201853bd23befc90c60bc0ace7fb /src/gallium/drivers/lima
parent4a74e2813018aaa4ee7993c9fded481f80c0f0a9 (diff)
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 <[email protected]> Reviewed-by: Erico Nunes <[email protected]> Signed-off-by: Qiang Yu <[email protected]>
Diffstat (limited to 'src/gallium/drivers/lima')
-rw-r--r--src/gallium/drivers/lima/ir/gp/gpir.h8
-rw-r--r--src/gallium/drivers/lima/ir/gp/nir.c43
2 files changed, 46 insertions, 5 deletions
diff --git a/src/gallium/drivers/lima/ir/gp/gpir.h b/src/gallium/drivers/lima/ir/gp/gpir.h
index 43d2adf2366..cbdf74d3a2e 100644
--- a/src/gallium/drivers/lima/ir/gp/gpir.h
+++ b/src/gallium/drivers/lima/ir/gp/gpir.h
@@ -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;
diff --git a/src/gallium/drivers/lima/ir/gp/nir.c b/src/gallium/drivers/lima/ir/gp/nir.c
index f38e2309619..655ea1a9b63 100644
--- a/src/gallium/drivers/lima/ir/gp/nir.c
+++ b/src/gallium/drivers/lima/ir/gp/nir.c
@@ -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;