From fa68740187cfd6938bd5a64f295efe19915856b6 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 2 Aug 2019 11:06:21 -0700 Subject: [PATCH] pan/midgard: Allow sysval destination override Sometimes a sysval is used to facilitate an instruction but is not the instruction itself. Signed-off-by: Alyssa Rosenzweig --- src/panfrost/midgard/compiler.h | 3 +++ src/panfrost/midgard/midgard_compile.c | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index da9e17f29c3..c466ad6a3ab 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -534,6 +534,9 @@ emit_ubo_read( nir_src *indirect_offset, unsigned index); +void +emit_sysval_read(compiler_context *ctx, nir_instr *instr, signed dest_override); + void midgard_emit_derivatives(compiler_context *ctx, nir_alu_instr *instr); diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index c3752784b6b..c0eedb8e1f0 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -1218,8 +1218,8 @@ emit_varying_read( emit_mir_instruction(ctx, ins); } -static void -emit_sysval_read(compiler_context *ctx, nir_instr *instr) +void +emit_sysval_read(compiler_context *ctx, nir_instr *instr, signed dest_override) { unsigned dest = 0; @@ -1227,6 +1227,9 @@ emit_sysval_read(compiler_context *ctx, nir_instr *instr) int sysval = sysval_for_instr(ctx, instr, &dest); void *val = _mesa_hash_table_u64_search(ctx->sysval_to_id, sysval); + if (dest_override >= 0) + dest = dest_override; + /* Sysvals are prefix uniforms */ unsigned uniform = ((uintptr_t) val) - 1; @@ -1437,7 +1440,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->instr); + emit_sysval_read(ctx, &instr->instr, -1); break; default: @@ -1664,7 +1667,7 @@ emit_tex(compiler_context *ctx, nir_tex_instr *instr) emit_texop_native(ctx, instr, TEXTURE_OP_TEXEL_FETCH); break; case nir_texop_txs: - emit_sysval_read(ctx, &instr->instr); + emit_sysval_read(ctx, &instr->instr, -1); break; default: unreachable("Unhanlded texture op"); -- 2.30.2