llvmpipe: interpolate Z at sample points for early depth test.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>
This commit is contained in:
Dave Airlie
2020-03-25 12:47:53 +10:00
committed by Marge Bot
parent a0195240c4
commit 102558912b
3 changed files with 14 additions and 7 deletions
+4 -3
View File
@@ -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);
+2 -1
View File
@@ -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 */
+8 -3
View File
@@ -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);