llvmpipe: pass incoming sample_mask into fragment shader context.
authorDave Airlie <airlied@redhat.com>
Tue, 10 Mar 2020 03:21:48 +0000 (13:21 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:37 +0000 (06:20 +0000)
This links up the api changing the sample mask to passing it into
the fragment shader.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>

src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup.h
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_blend.c
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_surface.c

index eaa759bdab95b4eecab828aca6c2d24d0fa275a3..67c714b02db732222f3d42771e8ec3667bae520f 100644 (file)
@@ -801,6 +801,15 @@ lp_setup_set_scissors( struct lp_setup_context *setup,
    setup->dirty |= LP_SETUP_NEW_SCISSOR;
 }
 
+void
+lp_setup_set_sample_mask(struct lp_setup_context *setup,
+                         uint32_t sample_mask)
+{
+   if (setup->fs.current.jit_context.sample_mask != sample_mask) {
+      setup->fs.current.jit_context.sample_mask = sample_mask;
+      setup->dirty |= LP_SETUP_NEW_FS;
+   }
+}
 
 void 
 lp_setup_set_flatshade_first(struct lp_setup_context *setup,
index ccf67fe2b272e9aab42d12b92d49044314b2e105..43da6c86589c17271617363c12ea3c22c35c6001 100644 (file)
@@ -149,6 +149,10 @@ unsigned
 lp_setup_is_resource_referenced( const struct lp_setup_context *setup,
                                 const struct pipe_resource *texture );
 
+void
+lp_setup_set_sample_mask(struct lp_setup_context *setup,
+                         uint32_t sample_mask);
+
 void
 lp_setup_set_flatshade_first( struct lp_setup_context *setup, 
                               boolean flatshade_first );
index f695f006399f5104cdcd96afb487d5dbd2b6f971..ccb5af2eb5e8537f24306df73ad2cbf6c3b60de3 100644 (file)
@@ -60,6 +60,7 @@
 #define LP_NEW_FS_IMAGES    0x100000
 #define LP_NEW_TCS          0x200000
 #define LP_NEW_TES          0x400000
+#define LP_NEW_SAMPLE_MASK  0x800000
 
 #define LP_CSNEW_CS 0x1
 #define LP_CSNEW_CONSTANTS 0x2
index 3c898c38c24e8ffdfa4a34db85e61a7bda16a462..10e5930851dd390196a3c1b1038f86cc2c16665e 100644 (file)
@@ -182,7 +182,7 @@ llvmpipe_set_sample_mask(struct pipe_context *pipe,
    if (sample_mask != llvmpipe->sample_mask) {
       llvmpipe->sample_mask = sample_mask;
 
-      llvmpipe->dirty |= LP_NEW_RASTERIZER;
+      llvmpipe->dirty |= LP_NEW_SAMPLE_MASK;
    }
 }
 
@@ -202,5 +202,6 @@ llvmpipe_init_blend_funcs(struct llvmpipe_context *llvmpipe)
    llvmpipe->pipe.set_stencil_ref = llvmpipe_set_stencil_ref;
    llvmpipe->pipe.set_sample_mask = llvmpipe_set_sample_mask;
 
+   llvmpipe->dirty |= LP_NEW_SAMPLE_MASK;
    llvmpipe->sample_mask = ~0;
 }
index 9fe0ddf1fb21af88e40289c3837b26fc43f629d8..5d51736964ab98a60ad2bf14e2cedbbb49a6cba5 100644 (file)
@@ -214,6 +214,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
    if (llvmpipe->dirty & (LP_NEW_FS |
                           LP_NEW_FRAMEBUFFER |
                           LP_NEW_RASTERIZER |
+                          LP_NEW_SAMPLE_MASK |
                           LP_NEW_DEPTH_STENCIL_ALPHA)) {
 
       /*
@@ -225,7 +226,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
       boolean null_fs = !llvmpipe->fs ||
                         llvmpipe->fs->info.base.num_instructions <= 1;
       boolean discard =
-         (llvmpipe->sample_mask & 1) == 0 ||
+         (llvmpipe->sample_mask) == 0 ||
          (llvmpipe->rasterizer ? llvmpipe->rasterizer->rasterizer_discard : FALSE) ||
          (null_fs &&
           !llvmpipe->depth_stencil->depth.enabled &&
@@ -238,6 +239,9 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
                           LP_NEW_RASTERIZER))
       llvmpipe_update_setup( llvmpipe );
 
+   if (llvmpipe->dirty & LP_NEW_SAMPLE_MASK)
+      lp_setup_set_sample_mask(llvmpipe->setup, llvmpipe->sample_mask);
+
    if (llvmpipe->dirty & LP_NEW_BLEND_COLOR)
       lp_setup_set_blend_color(llvmpipe->setup,
                                &llvmpipe->blend_color);
index 70c7911d1aafc9754f2bddb397f4d857d726d326..e9d7e50020e76253525b9e72cad23daf76dd8645 100644 (file)
@@ -106,7 +106,7 @@ static void lp_blit(struct pipe_context *pipe,
    util_blitter_save_tesseval_shader(lp->blitter, (void*)lp->tes);
    util_blitter_save_depth_stencil_alpha(lp->blitter, (void*)lp->depth_stencil);
    util_blitter_save_stencil_ref(lp->blitter, &lp->stencil_ref);
-   /*util_blitter_save_sample_mask(sp->blitter, lp->sample_mask);*/
+   util_blitter_save_sample_mask(lp->blitter, lp->sample_mask);
    util_blitter_save_framebuffer(lp->blitter, &lp->framebuffer);
    util_blitter_save_fragment_sampler_states(lp->blitter,
                      lp->num_samplers[PIPE_SHADER_FRAGMENT],