From da5840f3857664848b58e193c5ba56dac355860c Mon Sep 17 00:00:00 2001 From: Jose Fonseca Date: Mon, 5 Dec 2022 10:29:28 +0000 Subject: [PATCH] llvmpipe: Faithfully honour pipe_rasterizer_state::rasterizer_discard flag. D3D10 established that rasterization should be discarded when a null PS was bound, and depth/stencil state was disabled, and llvmpipe followed those semantics. Nowadays all APIs have explicit rasterization discard flag, and so does Gallium, so it's better for llvmpipe to faithfully follow that flag, and trust the state tracker to follow the right semantics. Second guessing pipe_rasterizer_state::rasterizer_discard actually causes problems, specially when no depth-stencil surface is bound, as D3D10 mandates rasterization should still happen, yet among all the translation layers it often happens depth-stencil enablement is optimized away when no depth-stencil is bound, which in turn was causing llvmpipe to disable rasterization when it shouldn't. Reviewed-by: Brian Paul Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/drivers/llvmpipe/lp_state_derived.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index 5c3e1bfe8de..06ee4f4812a 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -293,21 +293,8 @@ llvmpipe_update_derived(struct llvmpipe_context *llvmpipe) LP_NEW_RASTERIZER | LP_NEW_SAMPLE_MASK | LP_NEW_DEPTH_STENCIL_ALPHA)) { - - /* - * Rasterization is disabled if there is no pixel shader and - * both depth and stencil testing are disabled: - * http://msdn.microsoft.com/en-us/library/windows/desktop/bb205125 - * FIXME: set rasterizer_discard in state tracker instead. - */ - boolean null_fs = !llvmpipe->fs || - llvmpipe->fs->info.base.num_instructions <= 1; boolean discard = - (llvmpipe->sample_mask) == 0 || - (llvmpipe->rasterizer ? llvmpipe->rasterizer->rasterizer_discard : FALSE) || - (null_fs && - !llvmpipe->depth_stencil->depth_enabled && - !llvmpipe->depth_stencil->stencil[0].enabled); + llvmpipe->rasterizer ? llvmpipe->rasterizer->rasterizer_discard : FALSE; lp_setup_set_rasterizer_discard(llvmpipe->setup, discard); }