From: Marek Olšák Date: Tue, 30 Jul 2019 21:43:41 +0000 (-0400) Subject: radeonsi: make sure that rasterizer state != NULL and remove all NULL checking X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8d90157d49a609ec87cf1c833248bc0cfc606f89;p=mesa.git radeonsi: make sure that rasterizer state != NULL and remove all NULL checking Reviewed-by: Pierre-Eric Pelloux-Prayer --- diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 036c04fda9e..5976d72937b 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -354,6 +354,13 @@ void *util_blitter_get_noop_dsa_state(struct blitter_context *blitter) return ctx->dsa_keep_depth_stencil; } +void *util_blitter_get_discard_rasterizer_state(struct blitter_context *blitter) +{ + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; + + return ctx->rs_discard_state; +} + static void bind_vs_pos_only(struct blitter_context_priv *ctx, unsigned num_so_channels) { diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 6d25ba57671..72130adb422 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -156,6 +156,7 @@ void util_blitter_destroy(struct blitter_context *blitter); void util_blitter_cache_all_shaders(struct blitter_context *blitter); void *util_blitter_get_noop_blend_state(struct blitter_context *blitter); void *util_blitter_get_noop_dsa_state(struct blitter_context *blitter); +void *util_blitter_get_discard_rasterizer_state(struct blitter_context *blitter); /** diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index ab5c9064d0a..28f23b26be6 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -550,6 +550,10 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, sctx->noop_dsa = util_blitter_get_noop_dsa_state(sctx->blitter); sctx->queued.named.dsa = sctx->noop_dsa; + sctx->discard_rasterizer_state = + util_blitter_get_discard_rasterizer_state(sctx->blitter); + sctx->queued.named.rasterizer = sctx->discard_rasterizer_state; + si_init_draw_functions(sctx); si_initialize_prim_discard_tunables(sctx); } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 2be5f338bb3..5b09bb2b90f 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -888,6 +888,7 @@ struct si_context { struct blitter_context *blitter; void *noop_blend; void *noop_dsa; + void *discard_rasterizer_state; void *custom_dsa_flush; void *custom_blend_resolve; void *custom_blend_fmask_decompress; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index fad027a13f2..93fc272a476 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -824,7 +824,7 @@ static void si_update_poly_offset_state(struct si_context *sctx) { struct si_state_rasterizer *rs = sctx->queued.named.rasterizer; - if (!rs || !rs->uses_poly_offset || !sctx->framebuffer.state.zsbuf) { + if (!rs->uses_poly_offset || !sctx->framebuffer.state.zsbuf) { si_pm4_bind_state(sctx, poly_offset, NULL); return; } @@ -1027,10 +1027,10 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) (struct si_state_rasterizer*)sctx->queued.named.rasterizer; struct si_state_rasterizer *rs = (struct si_state_rasterizer *)state; - if (!state) - return; + if (!rs) + rs = (struct si_state_rasterizer *)sctx->discard_rasterizer_state; - if (!old_rs || old_rs->multisample_enable != rs->multisample_enable) { + if (old_rs->multisample_enable != rs->multisample_enable) { si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state); /* Update the small primitive filter workaround if necessary. */ @@ -1045,30 +1045,25 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) si_pm4_bind_state(sctx, rasterizer, rs); si_update_poly_offset_state(sctx); - if (!old_rs || - old_rs->scissor_enable != rs->scissor_enable) + if (old_rs->scissor_enable != rs->scissor_enable) si_mark_atom_dirty(sctx, &sctx->atoms.s.scissors); - if (!old_rs || - old_rs->line_width != rs->line_width || + if (old_rs->line_width != rs->line_width || old_rs->max_point_size != rs->max_point_size || old_rs->half_pixel_center != rs->half_pixel_center) si_mark_atom_dirty(sctx, &sctx->atoms.s.guardband); - if (!old_rs || - old_rs->clip_halfz != rs->clip_halfz) + if (old_rs->clip_halfz != rs->clip_halfz) si_mark_atom_dirty(sctx, &sctx->atoms.s.viewports); - if (!old_rs || - old_rs->clip_plane_enable != rs->clip_plane_enable || + if (old_rs->clip_plane_enable != rs->clip_plane_enable || old_rs->pa_cl_clip_cntl != rs->pa_cl_clip_cntl) si_mark_atom_dirty(sctx, &sctx->atoms.s.clip_regs); sctx->ia_multi_vgt_param_key.u.line_stipple_enabled = rs->line_stipple_enable; - if (!old_rs || - old_rs->clip_plane_enable != rs->clip_plane_enable || + if (old_rs->clip_plane_enable != rs->clip_plane_enable || old_rs->rasterizer_discard != rs->rasterizer_discard || old_rs->sprite_coord_enable != rs->sprite_coord_enable || old_rs->flatshade != rs->flatshade || diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index 529b11c364a..522a5c43470 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -1768,7 +1768,6 @@ static void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *i } if (unlikely(!sctx->vs_shader.cso || - !rs || (!sctx->ps_shader.cso && !rs->rasterizer_discard) || (!!sctx->tes_shader.cso != (prim == PIPE_PRIM_PATCHES)))) { assert(0); diff --git a/src/gallium/drivers/radeonsi/si_state_viewport.c b/src/gallium/drivers/radeonsi/si_state_viewport.c index 55bdb037082..2d2ab5ffa08 100644 --- a/src/gallium/drivers/radeonsi/si_state_viewport.c +++ b/src/gallium/drivers/radeonsi/si_state_viewport.c @@ -39,8 +39,7 @@ static void si_set_scissor_states(struct pipe_context *pctx, for (i = 0; i < num_scissors; i++) ctx->scissors[start_slot + i] = state[i]; - if (!ctx->queued.named.rasterizer || - !ctx->queued.named.rasterizer->scissor_enable) + if (!ctx->queued.named.rasterizer->scissor_enable) return; si_mark_atom_dirty(ctx, &ctx->atoms.s.scissors);