lima: track write submits of context (v3)
[mesa.git] / src / gallium / drivers / lima / lima_context.c
index e191ab0aa85fb658d48b42a8864dbc70cb33b5c1..817e0295a5a8dfab5809bd42d38c6f4b2304994d 100644 (file)
 int lima_ctx_num_plb = LIMA_CTX_PLB_DEF_NUM;
 
 uint32_t
-lima_ctx_buff_va(struct lima_context *ctx, enum lima_ctx_buff buff, unsigned submit)
+lima_ctx_buff_va(struct lima_context *ctx, enum lima_ctx_buff buff)
 {
+   struct lima_submit *submit = lima_submit_get(ctx);
    struct lima_ctx_buff_state *cbs = ctx->buffer_state + buff;
    struct lima_resource *res = lima_resource(cbs->res);
+   int pipe = buff < lima_ctx_buff_num_gp ? LIMA_PIPE_GP : LIMA_PIPE_PP;
 
-   if (submit & LIMA_CTX_BUFF_SUBMIT_GP)
-      lima_submit_add_bo(ctx->gp_submit, res->bo, LIMA_SUBMIT_BO_READ);
-   if (submit & LIMA_CTX_BUFF_SUBMIT_PP)
-      lima_submit_add_bo(ctx->pp_submit, res->bo, LIMA_SUBMIT_BO_READ);
+   lima_submit_add_bo(submit, pipe, res->bo, LIMA_SUBMIT_BO_READ);
 
    return res->bo->va + cbs->offset;
 }
@@ -123,10 +122,7 @@ lima_context_destroy(struct pipe_context *pctx)
    struct lima_context *ctx = lima_context(pctx);
    struct lima_screen *screen = lima_screen(pctx->screen);
 
-   if (ctx->pp_submit)
-      lima_submit_free(ctx->pp_submit);
-   if (ctx->gp_submit)
-      lima_submit_free(ctx->gp_submit);
+   lima_submit_fini(ctx);
 
    for (int i = 0; i < lima_ctx_buff_num; i++)
       pipe_resource_reference(&ctx->buffer_state[i].res, NULL);
@@ -231,6 +227,7 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 
    util_dynarray_init(&ctx->vs_cmd_array, ctx);
    util_dynarray_init(&ctx->plbu_cmd_array, ctx);
+   util_dynarray_init(&ctx->plbu_cmd_head, ctx);
 
    ctx->plb_size = screen->plb_max_blk * LIMA_CTX_PLB_BLK_SIZE;
    ctx->plb_gp_size = screen->plb_max_blk * 4;
@@ -280,12 +277,7 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
          goto err_out;
    }
 
-   ctx->gp_submit = lima_submit_create(ctx, LIMA_PIPE_GP);
-   if (!ctx->gp_submit)
-      goto err_out;
-
-   ctx->pp_submit = lima_submit_create(ctx, LIMA_PIPE_PP);
-   if (!ctx->pp_submit)
+   if (!lima_submit_init(ctx))
       goto err_out;
 
    return &ctx->base;
@@ -294,10 +286,3 @@ err_out:
    lima_context_destroy(&ctx->base);
    return NULL;
 }
-
-bool
-lima_need_flush(struct lima_context *ctx, struct lima_bo *bo, bool write)
-{
-   return lima_submit_has_bo(ctx->gp_submit, bo, write) ||
-      lima_submit_has_bo(ctx->pp_submit, bo, write);
-}