[Mesa-dev] [PATCH] llvmpipe: handle shader sample mask output
Brian Paul
brianp at vmware.com
Wed Oct 18 00:29:23 UTC 2017
LGTM. Reviewed-by: Brian Paul <brianp at vmware.com>
On 10/17/2017 01:58 PM, sroland at vmware.com wrote:
> From: Roland Scheidegger <sroland at vmware.com>
>
> This probably isn't all that useful for GL, but there are apis where
> sample_mask is a valid output even without msaa.
> Just discard the pixel if the sample_mask doesn't include the bit for
> sample 0.
> ---
> src/gallium/drivers/llvmpipe/lp_state_fs.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
> index 05984b3..9223ce6 100644
> --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
> +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
> @@ -84,6 +84,7 @@
> #include "gallivm/lp_bld_flow.h"
> #include "gallivm/lp_bld_debug.h"
> #include "gallivm/lp_bld_arit.h"
> +#include "gallivm/lp_bld_bitarit.h"
> #include "gallivm/lp_bld_pack.h"
> #include "gallivm/lp_bld_format.h"
> #include "gallivm/lp_bld_quad.h"
> @@ -347,7 +348,8 @@ generate_fs_loop(struct gallivm_state *gallivm,
> if (!shader->info.base.writes_z && !shader->info.base.writes_stencil) {
> if (key->alpha.enabled ||
> key->blend.alpha_to_coverage ||
> - shader->info.base.uses_kill) {
> + shader->info.base.uses_kill ||
> + shader->info.base.writes_samplemask) {
> /* With alpha test and kill, can do the depth test early
> * and hopefully eliminate some quads. But need to do a
> * special deferred depth write once the final mask value
> @@ -516,6 +518,25 @@ generate_fs_loop(struct gallivm_state *gallivm,
> }
> }
>
> + if (shader->info.base.writes_samplemask) {
> + int smaski = find_output_by_semantic(&shader->info.base,
> + TGSI_SEMANTIC_SAMPLEMASK,
> + 0);
> + LLVMValueRef smask;
> + struct lp_build_context smask_bld;
> + lp_build_context_init(&smask_bld, gallivm, int_type);
> +
> + assert(smaski >= 0);
> + smask = LLVMBuildLoad(builder, outputs[smaski][0], "smask");
> + /*
> + * Pixel is alive according to the first sample in the mask.
> + */
> + smask = LLVMBuildBitCast(builder, smask, smask_bld.vec_type, "");
> + smask = lp_build_and(&smask_bld, smask, smask_bld.one);
> + smask = lp_build_cmp(&smask_bld, PIPE_FUNC_NOTEQUAL, smask, smask_bld.zero);
> + lp_build_mask_update(&mask, smask);
> + }
> +
> /* Late Z test */
> if (depth_mode & LATE_DEPTH_TEST) {
> int pos0 = find_output_by_semantic(&shader->info.base,
> @@ -2818,7 +2839,8 @@ generate_variant(struct llvmpipe_context *lp,
> !key->alpha.enabled &&
> !key->blend.alpha_to_coverage &&
> !key->depth.enabled &&
> - !shader->info.base.uses_kill
> + !shader->info.base.uses_kill &&
> + !shader->info.base.writes_samplemask
> ? TRUE : FALSE;
>
> if ((shader->info.base.num_tokens <= 1) &&
>
More information about the mesa-dev
mailing list