radeonsi: add BOs after need_cs_space
authorMarek Olšák <marek.olsak@amd.com>
Wed, 24 Apr 2019 21:33:53 +0000 (17:33 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 25 Apr 2019 00:59:07 +0000 (20:59 -0400)
need_cs_space may clear the buffer list.

Fixes: 951d60f8cdc88 "radeonsi: delay adding BOs at the beginning of IBs until the first draw"
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_state_draw.c

index 2f444a3a1b887b74a52f2c404d877804f83528a0..541d7e6f11869d36960fd72a0ce2bdd1f2726338 100644 (file)
@@ -885,9 +885,6 @@ static void si_launch_grid(
                si_decompress_textures(sctx, 1 << PIPE_SHADER_COMPUTE);
        }
 
-       if (sctx->bo_list_add_all_compute_resources)
-               si_compute_resources_add_all_to_bo_list(sctx);
-
        /* Add buffer sizes for memory checking in need_cs_space. */
        si_context_add_resource_size(sctx, &program->shader.bo->b.b);
        /* TODO: add the scratch buffer */
@@ -905,6 +902,9 @@ static void si_launch_grid(
 
        si_need_gfx_cs_space(sctx);
 
+       if (sctx->bo_list_add_all_compute_resources)
+               si_compute_resources_add_all_to_bo_list(sctx);
+
        if (!sctx->cs_shader_state.initialized)
                si_initialize_compute(sctx);
 
index c220eaf24f84911a2c3fa3e9d9756422ea491f08..80e1bc4b47543f70bf5e4e3f05fff4c27df2f1c1 100644 (file)
@@ -1311,9 +1311,6 @@ static void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *i
 
        si_decompress_textures(sctx, u_bit_consecutive(0, SI_NUM_GRAPHICS_SHADERS));
 
-       if (sctx->bo_list_add_all_gfx_resources)
-               si_gfx_resources_add_all_to_bo_list(sctx);
-
        /* Set the rasterization primitive type.
         *
         * This must be done after si_decompress_textures, which can call
@@ -1455,6 +1452,9 @@ static void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *i
 
        si_need_gfx_cs_space(sctx);
 
+       if (sctx->bo_list_add_all_gfx_resources)
+               si_gfx_resources_add_all_to_bo_list(sctx);
+
        /* Since we've called si_context_add_resource_size for vertex buffers,
         * this must be called after si_need_cs_space, because we must let
         * need_cs_space flush before we add buffers to the buffer list.