From: Dave Airlie Date: Thu, 24 Oct 2019 01:42:23 +0000 (+1000) Subject: llvmpipe/images: handle undefined atomic without crashing X-Git-Tag: upstream/20.1.8~5503 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f52cdaa517b0bea142a273acb5b48f359b73982b;p=platform%2Fupstream%2Fmesa.git llvmpipe/images: handle undefined atomic without crashing just return 0 for unbound atomic operations. Reviewed-by: Marek Olšák --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 9161e23..77dd08c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -3982,8 +3982,10 @@ lp_build_do_atomic_soa(struct gallivm_state *gallivm, { enum pipe_format format = format_desc->format; - if (format != PIPE_FORMAT_R32_UINT && format != PIPE_FORMAT_R32_SINT && format != PIPE_FORMAT_R32_FLOAT) + if (format != PIPE_FORMAT_R32_UINT && format != PIPE_FORMAT_R32_SINT && format != PIPE_FORMAT_R32_FLOAT) { + atomic_result[0] = lp_build_zero(gallivm, type); return; + } LLVMValueRef atom_res = lp_build_alloca(gallivm, LLVMVectorType(LLVMInt32TypeInContext(gallivm->context), type.length), ""); @@ -4141,8 +4143,14 @@ lp_build_img_op_soa(const struct lp_static_texture_state *static_texture_state, lp_build_store_rgba_soa(gallivm, format_desc, params->type, params->exec_mask, base_ptr, offset, out_of_bounds, params->indata); } else { - if (static_texture_state->format == PIPE_FORMAT_NONE) + if (static_texture_state->format == PIPE_FORMAT_NONE) { + /* + * For atomic operation just return 0 in the unbound case to avoid a crash. + */ + LLVMValueRef zero = lp_build_zero(gallivm, params->type); + params->outdata[0] = zero; return; + } lp_build_do_atomic_soa(gallivm, format_desc, params->type, params->exec_mask, base_ptr, offset, out_of_bounds, params->img_op, params->op, params->indata, params->indata2, params->outdata); }