From: Qiang Yu Date: Sun, 9 Feb 2020 01:37:53 +0000 (+0800) Subject: lima: add lima_submit_create_stream_bo X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e90d8b6e4d135d58e9346220a652b4835c843d07;p=mesa.git lima: add lima_submit_create_stream_bo For creating stream buffer which is used in single submit and freed after the submit is passed to kernel driver. Reviewed-by: Vasily Khoruzhick Signed-off-by: Qiang Yu Part-of: --- diff --git a/src/gallium/drivers/lima/lima_submit.c b/src/gallium/drivers/lima/lima_submit.c index 43dac226d98..af51ab70b17 100644 --- a/src/gallium/drivers/lima/lima_submit.c +++ b/src/gallium/drivers/lima/lima_submit.c @@ -170,6 +170,27 @@ bool lima_submit_has_bo(struct lima_submit *submit, struct lima_bo *bo, bool all return false; } +void * +lima_submit_create_stream_bo(struct lima_submit *submit, int pipe, + unsigned size, uint32_t *va) +{ + struct lima_context *ctx = submit->ctx; + + void *cpu; + unsigned offset; + struct pipe_resource *pres = NULL; + u_upload_alloc(ctx->uploader, 0, size, 0x40, &offset, &pres, &cpu); + + struct lima_resource *res = lima_resource(pres); + *va = res->bo->va + offset; + + lima_submit_add_bo(submit, pipe, res->bo, LIMA_SUBMIT_BO_READ); + + pipe_resource_reference(&pres, NULL); + + return cpu; +} + static inline bool lima_submit_dirty(struct lima_submit *submit) { @@ -228,14 +249,9 @@ lima_pack_reload_plbu_cmd(struct lima_submit *submit) struct lima_context *ctx = submit->ctx; - void *cpu; - unsigned offset; - struct pipe_resource *pres = NULL; - u_upload_alloc(ctx->uploader, 0, lima_reload_buffer_size, - 0x40, &offset, &pres, &cpu); - - struct lima_resource *res = lima_resource(pres); - uint32_t va = res->bo->va + offset; + uint32_t va; + void *cpu = lima_submit_create_stream_bo( + submit, LIMA_PIPE_PP, lima_reload_buffer_size, &va); struct lima_screen *screen = lima_screen(ctx->base.screen); @@ -289,9 +305,6 @@ lima_pack_reload_plbu_cmd(struct lima_submit *submit) memcpy(cpu + lima_reload_varying_offset, reload_varying, sizeof(reload_varying)); - lima_submit_add_bo(submit, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_READ); - pipe_resource_reference(&pres, NULL); - PLBU_CMD_BEGIN(&ctx->plbu_cmd_head, 20); PLBU_CMD_VIEWPORT_LEFT(0); diff --git a/src/gallium/drivers/lima/lima_submit.h b/src/gallium/drivers/lima/lima_submit.h index 25cd5e31eb8..47203107120 100644 --- a/src/gallium/drivers/lima/lima_submit.h +++ b/src/gallium/drivers/lima/lima_submit.h @@ -34,6 +34,8 @@ struct lima_bo; bool lima_submit_add_bo(struct lima_submit *submit, int pipe, struct lima_bo *bo, uint32_t flags); bool lima_submit_has_bo(struct lima_submit *submit, struct lima_bo *bo, bool all); +void *lima_submit_create_stream_bo(struct lima_submit *submit, int pipe, + unsigned size, uint32_t *va); bool lima_submit_init(struct lima_context *ctx); void lima_submit_fini(struct lima_context *ctx);