llvmpipe: add per-sample interpolation.
authorDave Airlie <airlied@redhat.com>
Thu, 19 Mar 2020 05:40:31 +0000 (15:40 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:37 +0000 (06:20 +0000)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>

src/gallium/drivers/llvmpipe/lp_bld_interp.c
src/gallium/drivers/llvmpipe/lp_bld_interp.h
src/gallium/drivers/llvmpipe/lp_state_fs.c

index 6ca163f5a189c7d5c70e6ec1194d1d78e8042c26..745a6ca7c3bfba9cc5cb6031b4ef568272a1d0fe 100644 (file)
@@ -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);
index d2efdef1f45b92eff6658dc9ad5e9e4353f1b60d..11445ebfb4f726a80e72df2a9c167d257f22b977 100644 (file)
@@ -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,
index aace89507ae71ac519b152b154326a2ff9c5df0c..1b5ee26f275eed8dd4950247ea2e3ecf89801433 100644 (file)
@@ -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));