[Mesa-dev] [PATCH v2 2/5] panfrost: Make the sysval logic more generic
Boris Brezillon
boris.brezillon at collabora.com
Tue Jun 18 07:38:47 UTC 2019
We are about to add support for nir_texop_txs which requires adding a
sysval/uniform containing the texture size. Let's change the
emit_sysval_read() prototype to take a nir_instr object instead of
a nir_intrinsic_instr one so we can re-use this function when emitting
a sysval for a txs instruction.
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
---
Changes in v2:
* Add Alyssa's R-b
---
.../panfrost/midgard/midgard_compile.c | 65 ++++++++++++-------
1 file changed, 41 insertions(+), 24 deletions(-)
diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
index 1374c1ee6475..492ec69c85ba 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
@@ -272,16 +272,46 @@ midgard_nir_sysval_for_intrinsic(nir_intrinsic_instr *instr)
}
}
+static unsigned
+nir_dest_index(compiler_context *ctx, nir_dest *dst)
+{
+ if (dst->is_ssa)
+ return dst->ssa.index;
+ else {
+ assert(!dst->reg.indirect);
+ return ctx->func->impl->ssa_alloc + dst->reg.reg->index;
+ }
+}
+
+static int sysval_for_instr(compiler_context *ctx, nir_instr *instr,
+ unsigned *dest)
+{
+ nir_intrinsic_instr *intr;
+ nir_dest *dst = NULL;
+ int sysval = -1;
+
+ switch (instr->type) {
+ case nir_instr_type_intrinsic:
+ intr = nir_instr_as_intrinsic(instr);
+ sysval = midgard_nir_sysval_for_intrinsic(intr);
+ dst = &intr->dest;
+ break;
+ default:
+ break;
+ }
+
+ if (dest && dst)
+ *dest = nir_dest_index(ctx, dst);
+
+ return sysval;
+}
+
static void
midgard_nir_assign_sysval_body(compiler_context *ctx, nir_instr *instr)
{
- int sysval = -1;
-
- if (instr->type == nir_instr_type_intrinsic) {
- nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
- sysval = midgard_nir_sysval_for_intrinsic(intr);
- }
+ int sysval;
+ sysval = sysval_for_instr(ctx, instr, NULL);
if (sysval < 0)
return;
@@ -489,17 +519,6 @@ nir_src_index(compiler_context *ctx, nir_src *src)
}
}
-static unsigned
-nir_dest_index(compiler_context *ctx, nir_dest *dst)
-{
- if (dst->is_ssa)
- return dst->ssa.index;
- else {
- assert(!dst->reg.indirect);
- return ctx->func->impl->ssa_alloc + dst->reg.reg->index;
- }
-}
-
static unsigned
nir_alu_src_index(compiler_context *ctx, nir_alu_src *src)
{
@@ -1047,13 +1066,11 @@ emit_varying_read(
}
static void
-emit_sysval_read(compiler_context *ctx, nir_intrinsic_instr *instr)
+emit_sysval_read(compiler_context *ctx, nir_instr *instr)
{
- /* First, pull out the destination */
- unsigned dest = nir_dest_index(ctx, &instr->dest);
-
- /* Now, figure out which uniform this is */
- int sysval = midgard_nir_sysval_for_intrinsic(instr);
+ unsigned dest;
+ /* Figure out which uniform this is */
+ int sysval = sysval_for_instr(ctx, instr, &dest);
void *val = _mesa_hash_table_u64_search(ctx->sysval_to_id, sysval);
/* Sysvals are prefix uniforms */
@@ -1282,7 +1299,7 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
case nir_intrinsic_load_viewport_scale:
case nir_intrinsic_load_viewport_offset:
- emit_sysval_read(ctx, instr);
+ emit_sysval_read(ctx, &instr->instr);
break;
default:
--
2.20.1
More information about the mesa-dev
mailing list