llvmpipe/images: handle undefined atomic without crashing
authorDave Airlie <airlied@redhat.com>
Thu, 24 Oct 2019 01:42:23 +0000 (11:42 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 3 Dec 2019 05:29:04 +0000 (15:29 +1000)
just return 0 for unbound atomic operations.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c

index 9161e23..77dd08c 100644 (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);
    }