radeonsi: add and use si_pm4_state_enabled_and_changed
authorMarek Olšák <marek.olsak@amd.com>
Fri, 4 Aug 2017 15:06:24 +0000 (17:06 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 7 Aug 2017 19:12:24 +0000 (21:12 +0200)
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_cp_dma.c
src/gallium/drivers/radeonsi/si_state.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index 9f0e506282b7bcd1ab04e41195daa5eb14201b3f..24fa6fd08706592084dbebe37c0c55ed77191bc9 100644 (file)
@@ -442,26 +442,24 @@ void cik_prefetch_TC_L2_async(struct si_context *sctx, struct pipe_resource *buf
 static void cik_prefetch_shader_async(struct si_context *sctx,
                                      struct si_pm4_state *state)
 {
-       if (state) {
-               struct pipe_resource *bo = &state->bo[0]->b.b;
-               assert(state->nbo == 1);
+       struct pipe_resource *bo = &state->bo[0]->b.b;
+       assert(state->nbo == 1);
 
-               cik_prefetch_TC_L2_async(sctx, bo, 0, bo->width0);
-       }
+       cik_prefetch_TC_L2_async(sctx, bo, 0, bo->width0);
 }
 
 void cik_emit_prefetch_L2(struct si_context *sctx)
 {
        /* Prefetch shaders and VBO descriptors to TC L2. */
-       if (si_pm4_state_changed(sctx, ls))
+       if (si_pm4_state_enabled_and_changed(sctx, ls))
                cik_prefetch_shader_async(sctx, sctx->queued.named.ls);
-       if (si_pm4_state_changed(sctx, hs))
+       if (si_pm4_state_enabled_and_changed(sctx, hs))
                cik_prefetch_shader_async(sctx, sctx->queued.named.hs);
-       if (si_pm4_state_changed(sctx, es))
+       if (si_pm4_state_enabled_and_changed(sctx, es))
                cik_prefetch_shader_async(sctx, sctx->queued.named.es);
-       if (si_pm4_state_changed(sctx, gs))
+       if (si_pm4_state_enabled_and_changed(sctx, gs))
                cik_prefetch_shader_async(sctx, sctx->queued.named.gs);
-       if (si_pm4_state_changed(sctx, vs))
+       if (si_pm4_state_enabled_and_changed(sctx, vs))
                cik_prefetch_shader_async(sctx, sctx->queued.named.vs);
 
        /* Vertex buffer descriptors are uploaded uncached, so prefetch
@@ -471,7 +469,7 @@ void cik_emit_prefetch_L2(struct si_context *sctx)
                                         sctx->vertex_buffers.buffer_offset,
                                         sctx->vertex_elements->desc_list_byte_size);
        }
-       if (si_pm4_state_changed(sctx, ps))
+       if (si_pm4_state_enabled_and_changed(sctx, ps))
                cik_prefetch_shader_async(sctx, sctx->queued.named.ps);
 
        sctx->prefetch_L2 = false;
index 9fbede702a7a5059fe706d4a9a416d1ebb06c962..48e88afe1b8d25023fdc7370004f6df60ccbc07d 100644 (file)
@@ -288,6 +288,9 @@ struct si_buffer_resources {
 #define si_pm4_state_changed(sctx, member) \
        ((sctx)->queued.named.member != (sctx)->emitted.named.member)
 
+#define si_pm4_state_enabled_and_changed(sctx, member) \
+       ((sctx)->queued.named.member && si_pm4_state_changed(sctx, member))
+
 #define si_pm4_bind_state(sctx, member, value) \
        do { \
                (sctx)->queued.named.member = (value); \
index 0dd64025d482de2a42c0b032600f22f74b905bf2..cb5a23e9c8025271b3c543936f4a079c9bdaf183 100644 (file)
@@ -3297,12 +3297,12 @@ bool si_update_shaders(struct si_context *sctx)
                }
        }
 
-       if (si_pm4_state_changed(sctx, ls) ||
-           si_pm4_state_changed(sctx, hs) ||
-           si_pm4_state_changed(sctx, es) ||
-           si_pm4_state_changed(sctx, gs) ||
-           si_pm4_state_changed(sctx, vs) ||
-           si_pm4_state_changed(sctx, ps)) {
+       if (si_pm4_state_enabled_and_changed(sctx, ls) ||
+           si_pm4_state_enabled_and_changed(sctx, hs) ||
+           si_pm4_state_enabled_and_changed(sctx, es) ||
+           si_pm4_state_enabled_and_changed(sctx, gs) ||
+           si_pm4_state_enabled_and_changed(sctx, vs) ||
+           si_pm4_state_enabled_and_changed(sctx, ps)) {
                if (!si_update_spi_tmpring_size(sctx))
                        return false;
        }