radeonsi: compile clear and copy buffer compute shaders on demand
authorMarek Olšák <marek.olsak@amd.com>
Fri, 11 Jan 2019 23:06:59 +0000 (18:06 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 22 Jan 2019 16:59:27 +0000 (11:59 -0500)
same as all other shaders

src/gallium/drivers/radeonsi/si_compute_blit.c
src/gallium/drivers/radeonsi/si_pipe.c

index 11da04bed852d68f45f156c2f7b96b4768c8170c..dfa77a98804cef92ca8985cac43afa959348713a 100644 (file)
@@ -111,12 +111,20 @@ static void si_compute_do_clear_or_copy(struct si_context *sctx,
        sb[0].buffer_offset = dst_offset;
        sb[0].buffer_size = size;
 
+       bool shader_dst_stream_policy = SI_COMPUTE_DST_CACHE_POLICY != L2_LRU;
+
        if (src) {
                sb[1].buffer = src;
                sb[1].buffer_offset = src_offset;
                sb[1].buffer_size = size;
 
                ctx->set_shader_buffers(ctx, PIPE_SHADER_COMPUTE, 0, 2, sb);
+
+               if (!sctx->cs_copy_buffer) {
+                       sctx->cs_copy_buffer = si_create_dma_compute_shader(&sctx->b,
+                                                            SI_COMPUTE_COPY_DW_PER_THREAD,
+                                                            shader_dst_stream_policy, true);
+               }
                ctx->bind_compute_state(ctx, sctx->cs_copy_buffer);
        } else {
                assert(clear_value_size >= 4 &&
@@ -127,6 +135,12 @@ static void si_compute_do_clear_or_copy(struct si_context *sctx,
                        sctx->cs_user_data[i] = clear_value[i % (clear_value_size / 4)];
 
                ctx->set_shader_buffers(ctx, PIPE_SHADER_COMPUTE, 0, 1, sb);
+
+               if (!sctx->cs_clear_buffer) {
+                       sctx->cs_clear_buffer = si_create_dma_compute_shader(&sctx->b,
+                                                            SI_COMPUTE_CLEAR_DW_PER_THREAD,
+                                                            shader_dst_stream_policy, false);
+               }
                ctx->bind_compute_state(ctx, sctx->cs_clear_buffer);
        }
 
index 92ce1e0699c67bc224a2a4161f8c5ad98b8eb0be..6b89a1192d9edea775320b1e8bdbd14665b0ecbc 100644 (file)
@@ -510,14 +510,6 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
        if (sscreen->debug_flags & DBG(FORCE_DMA))
                sctx->b.resource_copy_region = sctx->dma_copy;
 
-       bool dst_stream_policy = SI_COMPUTE_DST_CACHE_POLICY != L2_LRU;
-       sctx->cs_clear_buffer = si_create_dma_compute_shader(&sctx->b,
-                                            SI_COMPUTE_CLEAR_DW_PER_THREAD,
-                                            dst_stream_policy, false);
-       sctx->cs_copy_buffer = si_create_dma_compute_shader(&sctx->b,
-                                            SI_COMPUTE_COPY_DW_PER_THREAD,
-                                            dst_stream_policy, true);
-
        sctx->blitter = util_blitter_create(&sctx->b);
        if (sctx->blitter == NULL)
                goto fail;