From: Qiang Yu Date: Tue, 11 Feb 2020 02:32:38 +0000 (+0800) Subject: lima: always add texture bo to submit X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9f924c795b9520c49572b54bfab07731d4f54e6e;p=mesa.git lima: always add texture bo to submit No matter texture desc change, we need to add texture to submit. Otherwise texture may be freed before submit finish. Reviewed-by: Vasily Khoruzhick Signed-off-by: Qiang Yu Part-of: --- diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c index 2309cc6d334..cd2bbd312a7 100644 --- a/src/gallium/drivers/lima/lima_draw.c +++ b/src/gallium/drivers/lima/lima_draw.c @@ -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); diff --git a/src/gallium/drivers/lima/lima_texture.c b/src/gallium/drivers/lima/lima_texture.c index 7f2f81266b6..793b8f31b8f 100644 --- a/src/gallium/drivers/lima/lima_texture.c +++ b/src/gallium/drivers/lima/lima_texture.c @@ -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]);