llvmpipe/images: handle undefined atomic without crashing

just return 0 for unbound atomic operations.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Dave Airlie 2019-10-24 11:42:23 +10:00
parent 71dd52e056
commit f52cdaa517

View file

@ -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);
}