From 89d4b6b5c857e1efcff4d945fb83b4e77d26378d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 7 May 2020 10:04:16 +1000 Subject: 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 Tested-by: Erik Faye-Lund Reviewed-by: Roland Scheidegger Part-of: --- 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(-) (limited to 'src') 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) { -- cgit v1.2.3