diff options
author | Boris Brezillon <[email protected]> | 2019-09-14 17:57:06 +0200 |
---|---|---|
committer | Boris Brezillon <[email protected]> | 2019-09-18 10:37:31 +0200 |
commit | 5a4d095f9b58e127c2eae9aa64595afeb36b554d (patch) | |
tree | c71a889f161ffe35a94b721c4c00ad2fc19d9ac6 /src/gallium/drivers/panfrost | |
parent | 9af4aeaaf7c88c80718caf10041e63545b202e2b (diff) |
panfrost: Add the panfrost_batch_create_bo() helper
This helper automates the panfrost_bo_create()+panfrost_batch_add_bo()+
panfrost_bo_unreference() sequence that's done for all per-batch BOs.
Signed-off-by: Boris Brezillon <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_allocate.c | 9 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_blend_cso.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_job.c | 32 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_job.h | 4 |
4 files changed, 28 insertions, 25 deletions
diff --git a/src/gallium/drivers/panfrost/pan_allocate.c b/src/gallium/drivers/panfrost/pan_allocate.c index 7938196e3e4..3076c23ab1c 100644 --- a/src/gallium/drivers/panfrost/pan_allocate.c +++ b/src/gallium/drivers/panfrost/pan_allocate.c @@ -42,8 +42,6 @@ struct panfrost_transfer panfrost_allocate_transient(struct panfrost_batch *batch, size_t sz) { - struct panfrost_screen *screen = pan_screen(batch->ctx->base.screen); - /* Pad the size */ sz = ALIGN_POT(sz, ALIGNMENT); @@ -66,12 +64,7 @@ panfrost_allocate_transient(struct panfrost_batch *batch, size_t sz) TRANSIENT_SLAB_SIZE : ALIGN_POT(sz, 4096); /* We can't reuse the current BO, but we can create a new one. */ - bo = panfrost_bo_create(screen, bo_sz, 0); - panfrost_batch_add_bo(batch, bo); - - /* Creating a BO adds a reference, and then the job adds a - * second one. So we need to pop back one reference */ - panfrost_bo_unreference(bo); + bo = panfrost_batch_create_bo(batch, bo_sz, 0); if (sz < TRANSIENT_SLAB_SIZE) { batch->transient_bo = bo; diff --git a/src/gallium/drivers/panfrost/pan_blend_cso.c b/src/gallium/drivers/panfrost/pan_blend_cso.c index 90a1e2956a5..6bd6ff71cdc 100644 --- a/src/gallium/drivers/panfrost/pan_blend_cso.c +++ b/src/gallium/drivers/panfrost/pan_blend_cso.c @@ -227,7 +227,6 @@ panfrost_blend_constant(float *out, float *in, unsigned mask) struct panfrost_blend_final panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti) { - struct panfrost_screen *screen = pan_screen(ctx->base.screen); struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); /* Grab the format, falling back gracefully if called invalidly (which @@ -273,13 +272,10 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti) final.shader.first_tag = shader->first_tag; /* Upload the shader */ - final.shader.bo = panfrost_bo_create(screen, shader->size, PAN_BO_EXECUTE); + final.shader.bo = panfrost_batch_create_bo(batch, shader->size, + PAN_BO_EXECUTE); memcpy(final.shader.bo->cpu, shader->buffer, shader->size); - /* Pass BO ownership to job */ - panfrost_batch_add_bo(batch, final.shader.bo); - panfrost_bo_unreference(final.shader.bo); - if (shader->patch_index) { /* We have to specialize the blend shader to use constants, so * patch in the current constants */ diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index 4ffc990a533..cc0db3e440a 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -144,6 +144,25 @@ panfrost_batch_add_bo(struct panfrost_batch *batch, struct panfrost_bo *bo) _mesa_set_add(batch->bos, bo); } +struct panfrost_bo * +panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size, + uint32_t create_flags) +{ + struct panfrost_bo *bo; + + bo = panfrost_bo_create(pan_screen(batch->ctx->base.screen), size, + create_flags); + panfrost_batch_add_bo(batch, bo); + + /* panfrost_batch_add_bo() has retained a reference and + * panfrost_bo_create() initialize the refcnt to 1, so let's + * unreference the BO here so it gets released when the batch is + * destroyed (unless it's retained by someone else in the meantime). + */ + panfrost_bo_unreference(bo); + return bo; +} + /* Returns the polygon list's GPU address if available, or otherwise allocates * the polygon list. It's perfectly fast to use allocate/free BO directly, * since we'll hit the BO cache and this is one-per-batch anyway. */ @@ -154,19 +173,10 @@ panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size) if (batch->polygon_list) { assert(batch->polygon_list->size >= size); } else { - struct panfrost_screen *screen = pan_screen(batch->ctx->base.screen); - /* Create the BO as invisible, as there's no reason to map */ - batch->polygon_list = panfrost_bo_create(screen, size, - PAN_BO_INVISIBLE); - panfrost_batch_add_bo(batch, batch->polygon_list); - - /* A BO reference has been retained by panfrost_batch_add_bo(), - * so we need to unreference it here if we want the BO to be - * automatically released when the batch is destroyed. - */ - panfrost_bo_unreference(&screen->base, batch->polygon_list); + batch->polygon_list = panfrost_batch_create_bo(batch, size, + PAN_BO_INVISIBLE); } return batch->polygon_list->gpu; diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h index b0580ea2d47..b1351b902bd 100644 --- a/src/gallium/drivers/panfrost/pan_job.h +++ b/src/gallium/drivers/panfrost/pan_job.h @@ -124,6 +124,10 @@ panfrost_batch_init(struct panfrost_context *ctx); void panfrost_batch_add_bo(struct panfrost_batch *batch, struct panfrost_bo *bo); +struct panfrost_bo * +panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size, + uint32_t create_flags); + void panfrost_batch_submit(struct panfrost_batch *batch); |