diff options
author | Roland Scheidegger <[email protected]> | 2017-10-17 21:55:03 +0200 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2017-10-18 18:16:44 +0200 |
commit | 3d0deed12ab3982cc183189f39c0df2793c2d94a (patch) | |
tree | 8590b205b7fded0202b2195e85878ec1addb6531 /src/gallium/drivers/llvmpipe | |
parent | c5124fbc74dca573fead4149d4287103a84ebae2 (diff) |
llvmpipe: handle shader sample mask output
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.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_fs.c | 26 |
1 files 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 05984b346e0..9223ce63e3a 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) && |