Module: Mesa
Branch: master
Commit: f52cdaa517b0bea142a273acb5b48f359b73982b
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f52cdaa517b0bea142a273acb5b48f359b73982b

Author: Dave Airlie <[email protected]>
Date:   Thu Oct 24 11:42:23 2019 +1000

llvmpipe/images: handle undefined atomic without crashing

just return 0 for unbound atomic operations.

Reviewed-by: Marek Olšák <[email protected]>

---

 src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 9161e234c62..77dd08c1b10 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);
    }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to