radeonsi: make sure that DSA 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_binning.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index ff4e9a721b365d1db5e2da26cec84a9a867d4ead..036c04fda9edfb95130a52065ac2b1d920f771da 100644 (file)
@@ -347,6 +347,13 @@ void *util_blitter_get_noop_blend_state(struct blitter_context *blitter)
    return ctx->blend[0][0];
 }
 
+void *util_blitter_get_noop_dsa_state(struct blitter_context *blitter)
+{
+   struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+
+   return ctx->dsa_keep_depth_stencil;
+}
+
 static void bind_vs_pos_only(struct blitter_context_priv *ctx,
                              unsigned num_so_channels)
 {
index 0db9c2a281639ec21f4abd572caec082c6e7514d..6d25ba57671daaed373d0483a1cbf7c6d0333c42 100644 (file)
@@ -155,6 +155,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);
 
 
 /**
index 98f15db8cad5654fa7b3f9f156283eda4d218960..ab5c9064d0a1c6a72a950ff17ed90a63b901c96d 100644 (file)
@@ -547,6 +547,9 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
                sctx->noop_blend = util_blitter_get_noop_blend_state(sctx->blitter);
                sctx->queued.named.blend = sctx->noop_blend;
 
+               sctx->noop_dsa = util_blitter_get_noop_dsa_state(sctx->blitter);
+               sctx->queued.named.dsa = sctx->noop_dsa;
+
                si_init_draw_functions(sctx);
                si_initialize_prim_discard_tunables(sctx);
        }
index 6060c579ceb98b6c4717806207530322d66726e7..2be5f338bb36e49c93a2442aa991848c535a446a 100644 (file)
@@ -887,6 +887,7 @@ struct si_context {
 
        struct blitter_context          *blitter;
        void                            *noop_blend;
+       void                            *noop_dsa;
        void                            *custom_dsa_flush;
        void                            *custom_blend_resolve;
        void                            *custom_blend_fmask_decompress;
index eb191b927c4dfb1a825147efebb3eca003dddd52..fad027a13f28dda850b7e273a0ea079feb426aec 100644 (file)
@@ -1303,8 +1303,8 @@ static void si_bind_dsa_state(struct pipe_context *ctx, void *state)
        struct si_state_dsa *old_dsa = sctx->queued.named.dsa;
         struct si_state_dsa *dsa = state;
 
-        if (!state)
-                return;
+        if (!dsa)
+                dsa = (struct si_state_dsa *)sctx->noop_dsa;
 
        si_pm4_bind_state(sctx, dsa, dsa);
 
@@ -1314,19 +1314,17 @@ static void si_bind_dsa_state(struct pipe_context *ctx, void *state)
                si_mark_atom_dirty(sctx, &sctx->atoms.s.stencil_ref);
        }
 
-       if (!old_dsa || old_dsa->alpha_func != dsa->alpha_func)
+       if (old_dsa->alpha_func != dsa->alpha_func)
                sctx->do_update_shaders = true;
 
        if (sctx->screen->dpbb_allowed &&
-           (!old_dsa ||
-            (old_dsa->depth_enabled != dsa->depth_enabled ||
+           ((old_dsa->depth_enabled != dsa->depth_enabled ||
              old_dsa->stencil_enabled != dsa->stencil_enabled ||
              old_dsa->db_can_write != dsa->db_can_write)))
                si_mark_atom_dirty(sctx, &sctx->atoms.s.dpbb_state);
 
        if (sctx->screen->has_out_of_order_rast &&
-           (!old_dsa ||
-            memcmp(old_dsa->order_invariance, dsa->order_invariance,
+           (memcmp(old_dsa->order_invariance, dsa->order_invariance,
                    sizeof(old_dsa->order_invariance))))
                si_mark_atom_dirty(sctx, &sctx->atoms.s.msaa_config);
 }
index ce87acab69ad4dcb1cfa6013844507144099de9c..ba599e055e209c6f283167e71741bc2f6ec8d6bd 100644 (file)
@@ -483,7 +483,7 @@ void si_emit_dpbb_state(struct si_context *sctx)
 
        assert(sctx->chip_class >= GFX9);
 
-       if (!sscreen->dpbb_allowed || !dsa || sctx->dpbb_force_off) {
+       if (!sscreen->dpbb_allowed || sctx->dpbb_force_off) {
                si_emit_dpbb_disable(sctx);
                return;
        }
index 81ba9410cdb704f1e7eae494fc47949d14a129c5..5371ac81039061a183c0557b1810e589d39be073 100644 (file)
@@ -1689,10 +1689,7 @@ static void si_shader_init_pm4_state(struct si_screen *sscreen,
 static unsigned si_get_alpha_test_func(struct si_context *sctx)
 {
        /* Alpha-test should be disabled if colorbuffer 0 is integer. */
-       if (sctx->queued.named.dsa)
-               return sctx->queued.named.dsa->alpha_func;
-
-       return PIPE_FUNC_ALWAYS;
+       return sctx->queued.named.dsa->alpha_func;
 }
 
 void si_shader_selector_key_vs(struct si_context *sctx,