llvmpipe: Faithfully honour pipe_rasterizer_state::rasterizer_discard flag.
authorJose Fonseca <jfonseca@vmware.com>
Mon, 5 Dec 2022 10:29:28 +0000 (10:29 +0000)
committerMarge Bot <emma+marge@anholt.net>
Tue, 6 Dec 2022 11:44:11 +0000 (11:44 +0000)
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 <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20155>

src/gallium/drivers/llvmpipe/lp_state_derived.c

index 5c3e1bf..06ee4f4 100644 (file)
@@ -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);
    }