llvmpipe: add per-sample depth/stencil test

The current depth stencil test code has some optimisations using
the mask when there is only one depth value, multisample requires
per-sample zstencil testing, and for that case just pass in the
mask that needs updating.

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-19 15:54:08 +10:00 committed by Marge Bot
parent d297f2ecf1
commit 5e949b16c1
3 changed files with 22 additions and 6 deletions

View File

@ -810,6 +810,7 @@ lp_build_depth_stencil_write_swizzled(struct gallivm_state *gallivm,
* \param type the data type of the fragment depth/stencil values
* \param format_desc description of the depth/stencil surface
* \param mask the alive/dead pixel mask for the quad (vector)
* \param cov_mask coverage mask
* \param stencil_refs the front/back stencil ref values (scalar)
* \param z_src the incoming depth/stencil values (n 2x2 quad values, float32)
* \param zs_dst the depth/stencil values in framebuffer
@ -822,6 +823,7 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
struct lp_type z_src_type,
const struct util_format_description *format_desc,
struct lp_build_mask_context *mask,
LLVMValueRef *cov_mask,
LLVMValueRef stencil_refs[2],
LLVMValueRef z_src,
LLVMValueRef z_fb,
@ -841,7 +843,7 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
LLVMValueRef stencil_vals = NULL;
LLVMValueRef z_bitmask = NULL, stencil_shift = NULL;
LLVMValueRef z_pass = NULL, s_pass_mask = NULL;
LLVMValueRef current_mask = lp_build_mask_value(mask);
LLVMValueRef current_mask = mask ? lp_build_mask_value(mask) : *cov_mask;
LLVMValueRef front_facing = NULL;
boolean have_z, have_s;
@ -1070,7 +1072,7 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
current_mask = LLVMBuildAnd(builder, current_mask, s_pass_mask, "");
}
if (!stencil[0].enabled) {
if (!stencil[0].enabled && mask) {
/* We can potentially skip all remaining operations here, but only
* if stencil is disabled because we still need to update the stencil
* buffer values. Don't need to update Z buffer values.
@ -1145,10 +1147,21 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
*s_value = stencil_vals;
}
if (s_pass_mask)
lp_build_mask_update(mask, s_pass_mask);
if (mask) {
if (s_pass_mask)
lp_build_mask_update(mask, s_pass_mask);
if (depth->enabled && stencil[0].enabled)
lp_build_mask_update(mask, z_pass);
if (depth->enabled && stencil[0].enabled)
lp_build_mask_update(mask, z_pass);
} else {
LLVMValueRef tmp_mask = *cov_mask;
if (s_pass_mask)
tmp_mask = LLVMBuildAnd(builder, tmp_mask, s_pass_mask, "");
/* for multisample we don't do the stencil optimisation so update always */
if (depth->enabled)
tmp_mask = LLVMBuildAnd(builder, tmp_mask, z_pass, "");
*cov_mask = tmp_mask;
}
}

View File

@ -61,6 +61,7 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
struct lp_type z_src_type,
const struct util_format_description *format_desc,
struct lp_build_mask_context *mask,
LLVMValueRef *cov_mask,
LLVMValueRef stencil_refs[2],
LLVMValueRef z_src,
LLVMValueRef z_fb,

View File

@ -470,6 +470,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
type,
zs_format_desc,
&mask,
NULL,
stencil_refs,
z, z_fb, s_fb,
facing,
@ -614,6 +615,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
type,
zs_format_desc,
&mask,
NULL,
stencil_refs,
z, z_fb, s_fb,
facing,