radeonsi: make sure that rasterizer state != NULL and remove all NULL checking
authorMarek Olšák <marek.olsak@amd.com>
Tue, 30 Jul 2019 21:43:41 +0000 (17:43 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 6 Aug 2019 21:08:39 +0000 (17:08 -0400)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state_draw.c
src/gallium/drivers/radeonsi/si_state_viewport.c

index 036c04fda9edfb95130a52065ac2b1d920f771da..5976d72937b24b969b0324fc9bcee5a8dd64a6ef 100644 (file)
@@ -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)
 {
index 6d25ba57671daaed373d0483a1cbf7c6d0333c42..72130adb4227a712bab3980bc79d9c47de2aba53 100644 (file)
@@ -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);
 
 
 /**
index ab5c9064d0a1c6a72a950ff17ed90a63b901c96d..28f23b26be64aeb77c5948c89dd5b6446221f2fb 100644 (file)
@@ -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);
        }
index 2be5f338bb36e49c93a2442aa991848c535a446a..5b09bb2b90f3339872e802ec9f9b81323df28593 100644 (file)
@@ -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;
index fad027a13f28dda850b7e273a0ea079feb426aec..93fc272a476c35048289535f92e0220dbe8bfbda 100644 (file)
@@ -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 ||
index 529b11c364a113c93938b16c93cf6a831a9cd4f1..522a5c43470f57d9ddb936fcf3b2f1786c525a57 100644 (file)
@@ -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);
index 55bdb037082d393203f5dff29671990bd804743e..2d2ab5ffa08e8081786f5f250468e484015f3a05 100644 (file)
@@ -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);