diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-08-06 13:47:17 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-08-12 12:43:02 -0700 |
commit | 7229af794b824a3c117611319cc22054f47fbbe6 (patch) | |
tree | 6af01c51ccb6adb8ea38b9a89e3a2b90561e53fb /src | |
parent | 2b4e579585de82f76ef86387f52b666b9de846e7 (diff) |
pan/midgard: Implement some compute builtins
We implement gl_WorkGroupID and gl_LocalInvocationID, which map to
ld_compute_id with special sources.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/panfrost/midgard/midgard_compile.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 6a4230ea59e..ab9ea664cb7 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -189,6 +189,7 @@ M_LOAD(ld_color_buffer_8); //M_STORE(st_vary_16); M_STORE(st_vary_32); M_LOAD(st_cubemap_coords); +M_LOAD(ld_compute_id); static midgard_instruction v_alu_br_compact_cond(midgard_jmp_writeout_op op, unsigned tag, signed offset, unsigned cond) @@ -1326,6 +1327,28 @@ emit_sysval_read(compiler_context *ctx, nir_instr *instr, signed dest_override, ins->mask = mask_of(nr_components); } +static unsigned +compute_builtin_arg(nir_op op) +{ + switch (op) { + case nir_intrinsic_load_work_group_id: + return 0x14; + case nir_intrinsic_load_local_invocation_id: + return 0x10; + default: + unreachable("Invalid compute paramater loaded"); + } +} + +static void +emit_compute_builtin(compiler_context *ctx, nir_intrinsic_instr *instr) +{ + unsigned reg = nir_dest_index(ctx, &instr->dest); + midgard_instruction ins = m_ld_compute_id(reg, 0); + ins.mask = mask_of(3); + ins.load_store.arg_1 = compute_builtin_arg(instr->intrinsic); + emit_mir_instruction(ctx, ins); +} static void emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr) { @@ -1555,6 +1578,11 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr) emit_sysval_read(ctx, &instr->instr, -1, 3); break; + case nir_intrinsic_load_work_group_id: + case nir_intrinsic_load_local_invocation_id: + emit_compute_builtin(ctx, instr); + break; + default: printf ("Unhandled intrinsic\n"); assert(0); |