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);
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;
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
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 */
_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. */
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;
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);