aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2020-03-19 15:40:31 +1000
committerMarge Bot <[email protected]>2020-05-06 06:20:37 +0000
commit18fd62a26e1baa59b650968d798227c922c0352d (patch)
treeaf40021b9a3f14dd08723867c7d53aeabb323b7a /src/gallium
parent8154bdf25ba2f78dc905759e50adf840471e334a (diff)
llvmpipe: add per-sample interpolation.
Reviewed-by: Roland Scheidegger <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_interp.c18
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_interp.h3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c2
3 files changed, 17 insertions, 6 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.c b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
index 6ca163f5a18..745a6ca7c3b 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_interp.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
@@ -241,6 +241,7 @@ attribs_update_simple(struct lp_build_interp_soa_context *bld,
struct gallivm_state *gallivm,
LLVMValueRef loop_iter,
LLVMValueRef mask_store,
+ LLVMValueRef sample_id,
int start,
int end)
{
@@ -312,7 +313,15 @@ attribs_update_simple(struct lp_build_interp_soa_context *bld,
if (bld->coverage_samples > 1) {
LLVMValueRef xoffset = lp_build_const_vec(gallivm, coeff_bld->type, bld->pos_offset);
LLVMValueRef yoffset = lp_build_const_vec(gallivm, coeff_bld->type, bld->pos_offset);
- if (loc == TGSI_INTERPOLATE_LOC_CENTROID) {
+ if (loc == TGSI_INTERPOLATE_LOC_SAMPLE) {
+ 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, ""));
+ } 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);
@@ -859,10 +868,11 @@ void
lp_build_interp_soa_update_inputs_dyn(struct lp_build_interp_soa_context *bld,
struct gallivm_state *gallivm,
LLVMValueRef quad_start_index,
- LLVMValueRef mask_store)
+ LLVMValueRef mask_store,
+ LLVMValueRef sample_id)
{
if (bld->simple_interp) {
- attribs_update_simple(bld, gallivm, quad_start_index, mask_store, 1, bld->num_attribs);
+ attribs_update_simple(bld, gallivm, quad_start_index, mask_store, sample_id, 1, bld->num_attribs);
}
else {
attribs_update(bld, gallivm, quad_start_index, 1, bld->num_attribs);
@@ -875,7 +885,7 @@ lp_build_interp_soa_update_pos_dyn(struct lp_build_interp_soa_context *bld,
LLVMValueRef quad_start_index)
{
if (bld->simple_interp) {
- attribs_update_simple(bld, gallivm, quad_start_index, NULL, 0, 1);
+ attribs_update_simple(bld, gallivm, quad_start_index, NULL, NULL, 0, 1);
}
else {
attribs_update(bld, gallivm, quad_start_index, 0, 1);
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.h b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
index d2efdef1f45..11445ebfb4f 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_interp.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
@@ -138,7 +138,8 @@ void
lp_build_interp_soa_update_inputs_dyn(struct lp_build_interp_soa_context *bld,
struct gallivm_state *gallivm,
LLVMValueRef quad_start_index,
- LLVMValueRef mask_store);
+ LLVMValueRef mask_store,
+ LLVMValueRef sample_id);
void
lp_build_interp_soa_update_pos_dyn(struct lp_build_interp_soa_context *bld,
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index aace89507ae..1b5ee26f275 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -492,7 +492,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
lp_build_mask_check(&mask);
}
- lp_build_interp_soa_update_inputs_dyn(interp, gallivm, loop_state.counter, NULL);
+ lp_build_interp_soa_update_inputs_dyn(interp, gallivm, loop_state.counter, NULL, NULL);
struct lp_build_tgsi_params params;
memset(&params, 0, sizeof(params));