From cab13f91747dc2acbb257b2d9067679b93b1e057 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 10 Mar 2020 13:21:48 +1000 Subject: [PATCH] llvmpipe: pass incoming sample_mask into fragment shader context. This links up the api changing the sample mask to passing it into the fragment shader. Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/drivers/llvmpipe/lp_setup.c | 9 +++++++++ src/gallium/drivers/llvmpipe/lp_setup.h | 4 ++++ src/gallium/drivers/llvmpipe/lp_state.h | 1 + src/gallium/drivers/llvmpipe/lp_state_blend.c | 3 ++- src/gallium/drivers/llvmpipe/lp_state_derived.c | 6 +++++- src/gallium/drivers/llvmpipe/lp_surface.c | 2 +- 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index eaa759bdab9..67c714b02db 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -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, diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h index ccf67fe2b27..43da6c86589 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_setup.h @@ -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 ); diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index f695f006399..ccb5af2eb5e 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -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 diff --git a/src/gallium/drivers/llvmpipe/lp_state_blend.c b/src/gallium/drivers/llvmpipe/lp_state_blend.c index 3c898c38c24..10e5930851d 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_state_blend.c @@ -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; } diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index 9fe0ddf1fb2..5d51736964a 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -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); diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index 70c7911d1aa..e9d7e50020e 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -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], -- 2.30.2