static struct midgard_tiler_descriptor
panfrost_emit_midg_tiler(struct panfrost_batch *batch, unsigned vertex_count)
{
- struct panfrost_context *ctx = batch->ctx;
struct midgard_tiler_descriptor t = {};
unsigned height = batch->key.height;
unsigned width = batch->key.width;
/* Sanity check */
if (t.hierarchy_mask) {
+ struct panfrost_bo *tiler_heap;
+
+ tiler_heap = panfrost_batch_get_tiler_heap(batch);
t.polygon_list = panfrost_batch_get_polygon_list(batch,
header_size +
t.polygon_list_size);
/* Allow the entire tiler heap */
- t.heap_start = ctx->tiler_heap->gpu;
- t.heap_end = ctx->tiler_heap->gpu + ctx->tiler_heap->size;
+ t.heap_start = tiler_heap->gpu;
+ t.heap_end = tiler_heap->gpu + tiler_heap->size;
} else {
+ struct panfrost_bo *tiler_dummy;
+
+ tiler_dummy = panfrost_batch_get_tiler_dummy(batch);
+
/* The tiler is disabled, so don't allow the tiler heap */
- t.heap_start = ctx->tiler_heap->gpu;
+ t.heap_start = tiler_dummy->gpu;
t.heap_end = t.heap_start;
/* Use a dummy polygon list */
- t.polygon_list = ctx->tiler_dummy->gpu;
+ t.polygon_list = tiler_dummy->gpu;
/* Disable the tiler */
t.hierarchy_mask |= MALI_TILER_DISABLED;
struct mali_single_framebuffer
panfrost_emit_sfbd(struct panfrost_batch *batch, unsigned vertex_count)
{
- struct panfrost_context *ctx = batch->ctx;
unsigned width = batch->key.width;
unsigned height = batch->key.height;
.unknown2 = 0x1f,
.format = 0x30000000,
.clear_flags = 0x1000,
- .unknown_address_0 = ctx->scratchpad->gpu,
+ .unknown_address_0 = panfrost_batch_get_scratchpad(batch)->gpu,
.tiler = panfrost_emit_midg_tiler(batch, vertex_count),
};
struct bifrost_framebuffer
panfrost_emit_mfbd(struct panfrost_batch *batch, unsigned vertex_count)
{
- struct panfrost_context *ctx = batch->ctx;
unsigned width = batch->key.width;
unsigned height = batch->key.height;
.unknown2 = 0x1f,
- .scratchpad = ctx->scratchpad->gpu,
+ .scratchpad = panfrost_batch_get_scratchpad(batch)->gpu,
.tiler = panfrost_emit_midg_tiler(batch, vertex_count)
};
if (panfrost->blitter_wallpaper)
util_blitter_destroy(panfrost->blitter_wallpaper);
- panfrost_bo_unreference(panfrost->scratchpad);
- panfrost_bo_unreference(panfrost->tiler_heap);
- panfrost_bo_unreference(panfrost->tiler_dummy);
-
ralloc_free(pipe);
}
so->num_targets = num_targets;
}
-static void
-panfrost_setup_hardware(struct panfrost_context *ctx)
-{
- struct pipe_context *gallium = (struct pipe_context *) ctx;
- struct panfrost_screen *screen = pan_screen(gallium->screen);
-
- ctx->scratchpad = panfrost_bo_create(screen, 64 * 4 * 4096, 0);
- ctx->tiler_heap = panfrost_bo_create(screen, 4096 * 4096,
- PAN_BO_INVISIBLE |
- PAN_BO_GROWABLE);
- ctx->tiler_dummy = panfrost_bo_create(screen, 4096,
- PAN_BO_INVISIBLE);
- assert(ctx->scratchpad && ctx->tiler_heap && ctx->tiler_dummy);
-}
-
-/* New context creation, which also does hardware initialisation since I don't
- * know the better way to structure this :smirk: */
-
struct pipe_context *
panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
{
&ctx->out_sync);
assert(!ret);
- panfrost_setup_hardware(ctx);
-
/* XXX: leaks */
gallium->stream_uploader = u_upload_create_default(gallium);
gallium->const_uploader = gallium->stream_uploader;
return batch->polygon_list->gpu;
}
+struct panfrost_bo *
+panfrost_batch_get_scratchpad(struct panfrost_batch *batch)
+{
+ if (batch->scratchpad)
+ return batch->scratchpad;
+
+ batch->scratchpad = panfrost_batch_create_bo(batch, 64 * 4 * 4096,
+ PAN_BO_INVISIBLE);
+ assert(batch->scratchpad);
+ return batch->scratchpad;
+}
+
+struct panfrost_bo *
+panfrost_batch_get_tiler_heap(struct panfrost_batch *batch)
+{
+ if (batch->tiler_heap)
+ return batch->tiler_heap;
+
+ batch->tiler_heap = panfrost_batch_create_bo(batch, 4096 * 4096,
+ PAN_BO_INVISIBLE |
+ PAN_BO_GROWABLE);
+ assert(batch->tiler_heap);
+ return batch->tiler_heap;
+}
+
+struct panfrost_bo *
+panfrost_batch_get_tiler_dummy(struct panfrost_batch *batch)
+{
+ if (batch->tiler_dummy)
+ return batch->tiler_dummy;
+
+ batch->tiler_dummy = panfrost_batch_create_bo(batch, 4096,
+ PAN_BO_INVISIBLE);
+ assert(batch->tiler_dummy);
+ return batch->tiler_dummy;
+}
+
static void
panfrost_batch_draw_wallpaper(struct panfrost_batch *batch)
{
static int
panfrost_batch_submit_jobs(struct panfrost_batch *batch)
{
- struct panfrost_context *ctx = batch->ctx;
bool has_draws = batch->first_job.gpu;
int ret = 0;
- panfrost_batch_add_bo(batch, ctx->scratchpad);
- panfrost_batch_add_bo(batch, ctx->tiler_heap);
-
if (has_draws) {
ret = panfrost_batch_submit_ioctl(batch, batch->first_job.gpu, 0);
assert(!ret);
/* Polygon list bound to the batch, or NULL if none bound yet */
struct panfrost_bo *polygon_list;
+ /* Scratchpath BO bound to the batch, or NULL if none bound yet */
+ struct panfrost_bo *scratchpad;
+
+ /* Tiler heap BO bound to the batch, or NULL if none bound yet */
+ struct panfrost_bo *tiler_heap;
+
+ /* Dummy tiler BO bound to the batch, or NULL if none bound yet */
+ struct panfrost_bo *tiler_dummy;
+
/* Framebuffer descriptor. */
mali_ptr framebuffer;
};
mali_ptr
panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size);
+struct panfrost_bo *
+panfrost_batch_get_scratchpad(struct panfrost_batch *batch);
+
+struct panfrost_bo *
+panfrost_batch_get_tiler_heap(struct panfrost_batch *batch);
+
+struct panfrost_bo *
+panfrost_batch_get_tiler_dummy(struct panfrost_batch *batch);
+
void
panfrost_batch_clear(struct panfrost_batch *batch,
unsigned buffers,