diff options
author | Dave Airlie <[email protected]> | 2020-03-25 12:47:53 +1000 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-06 06:20:37 +0000 |
commit | 102558912be91fa7d0eb22666dc7784739ca208b (patch) | |
tree | d34eb0eb021c1a3ea3dd01b9c6fde2a78f4edc7c /src/gallium | |
parent | a0195240c44f55f35b2c3d2c07b64c9f97775759 (diff) |
llvmpipe: interpolate Z at sample points for early depth test.
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.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_bld_interp.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_fs.c | 11 |
3 files changed, 14 insertions, 7 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.c b/src/gallium/drivers/llvmpipe/lp_bld_interp.c index 745a6ca7c3b..bd6bce7be2d 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_interp.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.c @@ -313,7 +313,7 @@ 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_SAMPLE) { + if (loc == TGSI_INTERPOLATE_LOC_SAMPLE || (attrib == 0 && chan == 2 && sample_id)) { 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), ""); @@ -882,10 +882,11 @@ lp_build_interp_soa_update_inputs_dyn(struct lp_build_interp_soa_context *bld, void lp_build_interp_soa_update_pos_dyn(struct lp_build_interp_soa_context *bld, struct gallivm_state *gallivm, - LLVMValueRef quad_start_index) + LLVMValueRef quad_start_index, + LLVMValueRef sample_id) { if (bld->simple_interp) { - attribs_update_simple(bld, gallivm, quad_start_index, NULL, NULL, 0, 1); + attribs_update_simple(bld, gallivm, quad_start_index, NULL, sample_id, 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 11445ebfb4f..e679a17118f 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_interp.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.h @@ -144,6 +144,7 @@ lp_build_interp_soa_update_inputs_dyn(struct lp_build_interp_soa_context *bld, void lp_build_interp_soa_update_pos_dyn(struct lp_build_interp_soa_context *bld, struct gallivm_state *gallivm, - LLVMValueRef quad_start_index); + LLVMValueRef quad_start_index, + LLVMValueRef sample_id); #endif /* LP_BLD_INTERP_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index c89693ce3c5..d32bdeb301d 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -464,9 +464,6 @@ generate_fs_loop(struct gallivm_state *gallivm, if (!(depth_mode & EARLY_DEPTH_TEST) && !simple_shader) lp_build_mask_check(&mask); - lp_build_interp_soa_update_pos_dyn(interp, gallivm, loop_state.counter); - z = interp->pos[2]; - /* Create storage for recombining sample masks after early Z pass. */ LLVMValueRef s_mask_or = lp_build_alloca(gallivm, lp_build_int_vec_type(gallivm, type), "cov_mask_early_depth"); LLVMBuildStore(builder, LLVMConstNull(lp_build_int_vec_type(gallivm, type)), s_mask_or); @@ -512,6 +509,11 @@ generate_fs_loop(struct gallivm_state *gallivm, s_mask = LLVMBuildAnd(builder, s_mask, mask_val, ""); } + + /* for multisample Z needs to be interpolated at sample points for testing. */ + lp_build_interp_soa_update_pos_dyn(interp, gallivm, loop_state.counter, key->multisample ? sample_loop_state.counter : NULL); + z = interp->pos[2]; + depth_ptr = depth_base_ptr; if (key->multisample) { LLVMValueRef sample_offset = LLVMBuildMul(builder, sample_loop_state.counter, depth_sample_stride, ""); @@ -585,6 +587,9 @@ generate_fs_loop(struct gallivm_state *gallivm, /* recombined all the coverage masks in the shader exec mask. */ tmp_s_mask_or = LLVMBuildLoad(builder, s_mask_or, ""); lp_build_mask_update(&mask, tmp_s_mask_or); + + /* for multisample Z needs to be re interpolated at pixel center */ + lp_build_interp_soa_update_pos_dyn(interp, gallivm, loop_state.counter, NULL); } lp_build_interp_soa_update_inputs_dyn(interp, gallivm, loop_state.counter, NULL, NULL); |