From da9a1cb8a684cf4a30e6c292a80e7cab4c89482d Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Mon, 15 May 2017 16:42:15 -0400 Subject: [PATCH] freedreno/ir3: fix crash with atomics Atomics can have a result value. And sometimes it is even used. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index dfebb62b16b..a6908033ab3 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -1248,7 +1248,7 @@ emit_intrinsic_store_ssbo(struct ir3_compile *ctx, nir_intrinsic_instr *intr) array_insert(b, b->keeps, stgb); } -static void +static struct ir3_instruction * emit_intrinsic_atomic(struct ir3_compile *ctx, nir_intrinsic_instr *intr) { struct ir3_block *b = ctx->block; @@ -1324,6 +1324,8 @@ emit_intrinsic_atomic(struct ir3_compile *ctx, nir_intrinsic_instr *intr) /* even if nothing consume the result, we can't DCE the instruction: */ array_insert(b, b->keeps, atomic); + + return atomic; } static void add_sysval_input_compmask(struct ir3_compile *ctx, @@ -1438,7 +1440,12 @@ emit_intrinsic(struct ir3_compile *ctx, nir_intrinsic_instr *intr) case nir_intrinsic_ssbo_atomic_xor: case nir_intrinsic_ssbo_atomic_exchange: case nir_intrinsic_ssbo_atomic_comp_swap: - emit_intrinsic_atomic(ctx, intr); + if (info->has_dest) { + compile_assert(ctx, intr->num_components == 1); + dst[0] = emit_intrinsic_atomic(ctx, intr); + } else { + emit_intrinsic_atomic(ctx, intr); + } break; case nir_intrinsic_store_output: idx = nir_intrinsic_base(intr); -- 2.30.2