lima: always add texture bo to submit
authorQiang Yu <yuq825@gmail.com>
Tue, 11 Feb 2020 02:32:38 +0000 (10:32 +0800)
committerMarge Bot <eric+marge@anholt.net>
Mon, 17 Feb 2020 02:54:15 +0000 (02:54 +0000)
No matter texture desc change, we need to add texture to submit.
Otherwise texture may be freed before submit finish.

Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3755>

src/gallium/drivers/lima/lima_draw.c
src/gallium/drivers/lima/lima_texture.c

index 2309cc6d33426f79cc07524c82bb6d6dff2f1a6e..cd2bbd312a71a6118eb0c8b02e05ea03573414f5 100644 (file)
@@ -1535,8 +1535,7 @@ lima_draw_vbo_update(struct pipe_context *pctx,
       ctx->const_buffer[PIPE_SHADER_FRAGMENT].dirty = false;
    }
 
-   if (ctx->dirty & LIMA_CONTEXT_DIRTY_TEXTURES)
-      lima_update_textures(ctx);
+   lima_update_textures(ctx);
 
    lima_pack_render_state(ctx, info);
    lima_pack_plbu_cmd(ctx, info);
index 7f2f81266b667ba0003c7aff9e0651a353904ec2..793b8f31b8fb301fb3795fe75fd6394a7e5effe0 100644 (file)
@@ -95,8 +95,6 @@ lima_texture_desc_set_res(struct lima_context *ctx, lima_tex_desc *desc,
       layout = 0;
    }
 
-   lima_submit_add_bo(ctx->pp_submit, lima_res->bo, LIMA_SUBMIT_BO_READ);
-
    uint32_t base_va = lima_res->bo->va;
 
    /* attach first level */
@@ -263,6 +261,17 @@ lima_update_textures(struct lima_context *ctx)
    if (!lima_tex->num_samplers || !lima_tex->num_textures)
       return;
 
+   /* we always need to add texture bo to submit */
+   for (int i = 0; i < lima_tex->num_samplers; i++) {
+      struct lima_sampler_view *texture = lima_sampler_view(lima_tex->textures[i]);
+      struct lima_resource *rsc = lima_resource(texture->base.texture);
+      lima_submit_add_bo(ctx->pp_submit, rsc->bo, LIMA_SUBMIT_BO_READ);
+   }
+
+   /* do not regenerate texture desc if no change */
+   if (!(ctx->dirty & LIMA_CONTEXT_DIRTY_TEXTURES))
+      return;
+
    unsigned size = lima_tex_list_size;
    for (int i = 0; i < lima_tex->num_samplers; i++) {
       struct lima_sampler_view *texture = lima_sampler_view(lima_tex->textures[i]);