Mesa (master): llvmpipe: make sample position a global array.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 7 19:09:48 UTC 2020


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Thu May  7 10:04:16 2020 +1000

llvmpipe: make sample position a global array.

I messed this up and LLVM asserts on it.

Use the gallivm struct wrappers to make it clearer.

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2913

Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Tested-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4933>

---

 src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c |  4 ++--
 src/gallium/drivers/llvmpipe/lp_bld_interp.c   | 17 +++++++++--------
 src/gallium/drivers/llvmpipe/lp_state_fs.c     |  2 +-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
index 3ae332369ac..0196b34bc91 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
@@ -1382,8 +1382,8 @@ static void emit_sysval_intrin(struct lp_build_nir_context *bld_base,
       for (unsigned i = 0; i < 2; i++) {
          LLVMValueRef idx = LLVMBuildMul(gallivm->builder, bld->system_values.sample_id, lp_build_const_int32(gallivm, 2), "");
          idx = LLVMBuildAdd(gallivm->builder, idx, lp_build_const_int32(gallivm, i), "");
-         LLVMValueRef val = LLVMBuildGEP(gallivm->builder, bld->system_values.sample_pos, &idx, 1, "");
-         result[i] = lp_build_broadcast_scalar(&bld_base->base, LLVMBuildLoad(gallivm->builder, val, ""));
+         LLVMValueRef val = lp_build_array_get(gallivm, bld->system_values.sample_pos, idx);
+         result[i] = lp_build_broadcast_scalar(&bld_base->base, val);
       }
       break;
    }
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.c b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
index bd6bce7be2d..6f40d854297 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_interp.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
@@ -317,10 +317,10 @@ attribs_update_simple(struct lp_build_interp_soa_context *bld,
                         LLVMValueRef x_val_idx = LLVMBuildMul(gallivm->builder, sample_id, lp_build_const_int32(gallivm, 2), "");
                         LLVMValueRef y_val_idx = LLVMBuildAdd(gallivm->builder, x_val_idx, lp_build_const_int32(gallivm, 1), "");
 
-                        x_val_idx = LLVMBuildGEP(builder, bld->sample_pos_array, &x_val_idx, 1, "");
-                        y_val_idx = LLVMBuildGEP(builder, bld->sample_pos_array, &y_val_idx, 1, "");
-                        xoffset = lp_build_broadcast_scalar(coeff_bld, LLVMBuildLoad(builder, x_val_idx, ""));
-                        yoffset = lp_build_broadcast_scalar(coeff_bld, LLVMBuildLoad(builder, y_val_idx, ""));
+                        x_val_idx = lp_build_array_get(gallivm, bld->sample_pos_array, x_val_idx);
+                        y_val_idx = lp_build_array_get(gallivm, bld->sample_pos_array, y_val_idx);
+                        xoffset = lp_build_broadcast_scalar(coeff_bld, x_val_idx);
+                        yoffset = lp_build_broadcast_scalar(coeff_bld, y_val_idx);
                      } else if (loc == TGSI_INTERPOLATE_LOC_CENTROID) {
                         LLVMValueRef centroid_x_offset = lp_build_const_vec(gallivm, coeff_bld->type, bld->pos_offset);
                         LLVMValueRef centroid_y_offset = lp_build_const_vec(gallivm, coeff_bld->type, bld->pos_offset);
@@ -342,10 +342,11 @@ attribs_update_simple(struct lp_build_interp_soa_context *bld,
                            LLVMValueRef x_val_idx = lp_build_const_int32(gallivm, s * 2);
                            LLVMValueRef y_val_idx = lp_build_const_int32(gallivm, s * 2 + 1);
 
-                           x_val_idx = LLVMBuildGEP(builder, bld->sample_pos_array, &x_val_idx, 1, "");
-                           y_val_idx = LLVMBuildGEP(builder, bld->sample_pos_array, &y_val_idx, 1, "");
-                           x_val_idx = lp_build_broadcast_scalar(coeff_bld, LLVMBuildLoad(builder, x_val_idx, ""));
-                           y_val_idx = lp_build_broadcast_scalar(coeff_bld, LLVMBuildLoad(builder, y_val_idx, ""));
+                           x_val_idx = lp_build_array_get(gallivm, bld->sample_pos_array, x_val_idx);
+                           y_val_idx = lp_build_array_get(gallivm, bld->sample_pos_array, y_val_idx);
+
+                           x_val_idx = lp_build_broadcast_scalar(coeff_bld, x_val_idx);
+                           y_val_idx = lp_build_broadcast_scalar(coeff_bld, y_val_idx);
                            centroid_x_offset = lp_build_select(coeff_bld, sample_cov, x_val_idx, centroid_x_offset);
                            centroid_y_offset = lp_build_select(coeff_bld, sample_cov, y_val_idx, centroid_y_offset);
                         }
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index f4959fb8b5a..c60faece9be 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -2889,7 +2889,7 @@ generate_fragment(struct llvmpipe_context *lp,
                                                       num_loop_samp, "mask_store");
 
       LLVMTypeRef flt_type = LLVMFloatTypeInContext(gallivm->context);
-      LLVMValueRef glob_sample_pos = LLVMAddGlobal(gallivm->module, flt_type, "");
+      LLVMValueRef glob_sample_pos = LLVMAddGlobal(gallivm->module, LLVMArrayType(flt_type, key->coverage_samples * 2), "");
       LLVMValueRef sample_pos_array;
 
       if (key->multisample && key->coverage_samples == 4) {



More information about the mesa-commit mailing list