llvmpipe/fs: add sample position type to the interp interface

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Mihai Preda <mhpreda@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18876>
This commit is contained in:
Dave Airlie 2022-09-29 08:17:35 +10:00 committed by Marge Bot
parent ff02d042aa
commit e28db68e53
3 changed files with 19 additions and 7 deletions

View file

@ -181,8 +181,10 @@ calc_centroid_offsets(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 = 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_array_get2(gallivm, bld->sample_pos_array_type,
bld->sample_pos_array, x_val_idx);
y_val_idx = lp_build_array_get2(gallivm, bld->sample_pos_array_type,
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);
@ -338,7 +340,8 @@ attribs_update_simple(struct lp_build_interp_soa_context *bld,
dadx = coeff_bld->one;
if (sample_id) {
LLVMValueRef x_val_idx = LLVMBuildMul(gallivm->builder, sample_id, lp_build_const_int32(gallivm, 2), "");
x_val_idx = lp_build_array_get(gallivm, bld->sample_pos_array, x_val_idx);
x_val_idx = lp_build_array_get2(gallivm, bld->sample_pos_array_type,
bld->sample_pos_array, x_val_idx);
a = lp_build_broadcast_scalar(coeff_bld, x_val_idx);
} else {
a = lp_build_const_vec(gallivm, coeff_bld->type, bld->pos_offset);
@ -349,7 +352,8 @@ attribs_update_simple(struct lp_build_interp_soa_context *bld,
if (sample_id) {
LLVMValueRef y_val_idx = LLVMBuildMul(gallivm->builder, sample_id, lp_build_const_int32(gallivm, 2), "");
y_val_idx = LLVMBuildAdd(gallivm->builder, y_val_idx, lp_build_const_int32(gallivm, 1), "");
y_val_idx = lp_build_array_get(gallivm, bld->sample_pos_array, y_val_idx);
y_val_idx = lp_build_array_get2(gallivm, bld->sample_pos_array_type,
bld->sample_pos_array, y_val_idx);
a = lp_build_broadcast_scalar(coeff_bld, y_val_idx);
} else {
a = lp_build_const_vec(gallivm, coeff_bld->type, bld->pos_offset);
@ -373,8 +377,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 = 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_array_get2(gallivm, bld->sample_pos_array_type,
bld->sample_pos_array, x_val_idx);
y_val_idx = lp_build_array_get2(gallivm, bld->sample_pos_array_type,
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) {
@ -678,6 +684,7 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
const struct lp_shader_input *inputs,
boolean pixel_center_integer,
unsigned coverage_samples,
LLVMTypeRef sample_pos_array_type,
LLVMValueRef sample_pos_array,
LLVMValueRef num_loop,
LLVMBuilderRef builder,
@ -750,6 +757,7 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
}
bld->coverage_samples = coverage_samples;
bld->num_loop = num_loop;
bld->sample_pos_array_type = sample_pos_array_type;
bld->sample_pos_array = sample_pos_array;
pos_init(bld, x0, y0);

View file

@ -90,6 +90,7 @@ struct lp_build_interp_soa_context
double pos_offset;
unsigned coverage_samples;
LLVMValueRef num_loop;
LLVMTypeRef sample_pos_array_type;
LLVMValueRef sample_pos_array;
LLVMValueRef x;
@ -124,6 +125,7 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
const struct lp_shader_input *inputs,
boolean pixel_center_integer,
unsigned coverage_samples,
LLVMTypeRef sample_pos_array_type,
LLVMValueRef sample_pos_array,
LLVMValueRef num_loop,
LLVMBuilderRef builder,

View file

@ -3319,7 +3319,9 @@ generate_fragment(struct llvmpipe_context *lp,
shader->info.base.num_inputs,
inputs,
pixel_center_integer,
key->coverage_samples, glob_sample_pos,
key->coverage_samples,
LLVMTypeOf(sample_pos_array),
glob_sample_pos,
num_loop,
builder, fs_type,
a0_ptr, dadx_ptr, dady_ptr,