diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 51e9ca0103a..578dcee4d2a 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -3931,6 +3931,7 @@ init_polygon_list(struct panfrost_batch *batch) static int submit_batch(struct panfrost_batch *batch, struct pan_fb_info *fb) { + JOBX(prepare_tiler)(batch, fb); JOBX(preload_fb)(batch, fb); init_polygon_list(batch); diff --git a/src/gallium/drivers/panfrost/pan_csf.c b/src/gallium/drivers/panfrost/pan_csf.c index d9f0fa47d0c..cedd54d9e25 100644 --- a/src/gallium/drivers/panfrost/pan_csf.c +++ b/src/gallium/drivers/panfrost/pan_csf.c @@ -612,6 +612,64 @@ out_free_syncops: return ret; } +static mali_ptr +csf_get_tiler_desc(struct panfrost_batch *batch) +{ + if (batch->tiler_ctx.valhall.desc) + return batch->tiler_ctx.valhall.desc; + + struct panfrost_ptr t = + pan_pool_alloc_desc(&batch->pool.base, TILER_CONTEXT); + + batch->csf.pending_tiler_desc = t.cpu; + batch->tiler_ctx.valhall.desc = t.gpu; + return batch->tiler_ctx.valhall.desc; +} + +static void +csf_emit_tiler_desc(struct panfrost_batch *batch, const struct pan_fb_info *fb) +{ + struct panfrost_context *ctx = batch->ctx; + struct panfrost_device *dev = pan_device(ctx->base.screen); + + if (!batch->csf.pending_tiler_desc) + return; + + pan_pack(batch->csf.pending_tiler_desc, TILER_CONTEXT, tiler) { + unsigned max_levels = dev->tiler_features.max_levels; + assert(max_levels >= 2); + + /* TODO: Select hierarchy mask more effectively */ + tiler.hierarchy_mask = (max_levels >= 8) ? 0xFF : 0x28; + + /* For large framebuffers, disable the smallest bin size to + * avoid pathological tiler memory usage. Required to avoid OOM + * on dEQP-GLES31.functional.fbo.no_attachments.maximums.all on + * Mali-G57. + */ + if (MAX2(batch->key.width, batch->key.height) >= 4096) + tiler.hierarchy_mask &= ~1; + + tiler.fb_width = batch->key.width; + tiler.fb_height = batch->key.height; + tiler.heap = batch->ctx->csf.heap.desc_bo->ptr.gpu; + tiler.sample_pattern = + pan_sample_pattern(util_framebuffer_get_num_samples(&batch->key)); + tiler.first_provoking_vertex = + batch->first_provoking_vertex == U_TRISTATE_YES; + tiler.geometry_buffer = ctx->csf.tmp_geom_bo->ptr.gpu; + tiler.geometry_buffer_size = ctx->csf.tmp_geom_bo->kmod_bo->size; + } + + batch->csf.pending_tiler_desc = 0; +} + +void +GENX(csf_prepare_tiler)(struct panfrost_batch *batch, struct pan_fb_info *fb) +{ + csf_emit_tiler_desc(batch, fb); +} + void GENX(csf_preload_fb)(struct panfrost_batch *batch, struct pan_fb_info *fb) { @@ -929,47 +987,6 @@ GENX(csf_launch_xfb)(struct panfrost_batch *batch, cs_run_compute(b, 1, MALI_TASK_AXIS_Z, false, cs_shader_res_sel(0, 0, 0, 0)); } -static mali_ptr -csf_get_tiler_desc(struct panfrost_batch *batch) -{ - struct panfrost_context *ctx = batch->ctx; - struct panfrost_device *dev = pan_device(ctx->base.screen); - - if (batch->tiler_ctx.valhall.desc) - return batch->tiler_ctx.valhall.desc; - - struct panfrost_ptr t = - pan_pool_alloc_desc(&batch->pool.base, TILER_CONTEXT); - pan_pack(t.cpu, TILER_CONTEXT, tiler) { - unsigned max_levels = dev->tiler_features.max_levels; - assert(max_levels >= 2); - - /* TODO: Select hierarchy mask more effectively */ - tiler.hierarchy_mask = (max_levels >= 8) ? 0xFF : 0x28; - - /* For large framebuffers, disable the smallest bin size to - * avoid pathological tiler memory usage. Required to avoid OOM - * on dEQP-GLES31.functional.fbo.no_attachments.maximums.all on - * Mali-G57. - */ - if (MAX2(batch->key.width, batch->key.height) >= 4096) - tiler.hierarchy_mask &= ~1; - - tiler.fb_width = batch->key.width; - tiler.fb_height = batch->key.height; - tiler.heap = batch->ctx->csf.heap.desc_bo->ptr.gpu; - tiler.sample_pattern = - pan_sample_pattern(util_framebuffer_get_num_samples(&batch->key)); - tiler.first_provoking_vertex = - batch->first_provoking_vertex == U_TRISTATE_YES; - tiler.geometry_buffer = ctx->csf.tmp_geom_bo->ptr.gpu; - tiler.geometry_buffer_size = ctx->csf.tmp_geom_bo->kmod_bo->size; - } - - batch->tiler_ctx.valhall.desc = t.gpu; - return batch->tiler_ctx.valhall.desc; -} - static void emit_tiler_oom_context(struct cs_builder *b, struct panfrost_batch *batch) { diff --git a/src/gallium/drivers/panfrost/pan_csf.h b/src/gallium/drivers/panfrost/pan_csf.h index 04b7fa002c4..16ed6141942 100644 --- a/src/gallium/drivers/panfrost/pan_csf.h +++ b/src/gallium/drivers/panfrost/pan_csf.h @@ -74,6 +74,8 @@ struct panfrost_csf_batch { struct panfrost_pool cs_chunk_pool; struct panfrost_ptr tiler_oom_ctx; + + void *pending_tiler_desc; }; struct panfrost_csf_context { @@ -114,6 +116,8 @@ void GENX(csf_init_batch)(struct panfrost_batch *batch); void GENX(csf_cleanup_batch)(struct panfrost_batch *batch); int GENX(csf_submit_batch)(struct panfrost_batch *batch); +void GENX(csf_prepare_tiler)(struct panfrost_batch *batch, + struct pan_fb_info *fb); void GENX(csf_preload_fb)(struct panfrost_batch *batch, struct pan_fb_info *fb); void GENX(csf_emit_fbds)(struct panfrost_batch *batch, struct pan_fb_info *fb, struct pan_tls_info *tls); diff --git a/src/gallium/drivers/panfrost/pan_jm.h b/src/gallium/drivers/panfrost/pan_jm.h index f6cbb7b78be..275dfc86fb1 100644 --- a/src/gallium/drivers/panfrost/pan_jm.h +++ b/src/gallium/drivers/panfrost/pan_jm.h @@ -70,6 +70,11 @@ GENX(jm_cleanup_batch)(struct panfrost_batch *batch) int GENX(jm_submit_batch)(struct panfrost_batch *batch); +static inline void +GENX(jm_prepare_tiler)(struct panfrost_batch *batch, struct pan_fb_info *fb) +{ +} + void GENX(jm_preload_fb)(struct panfrost_batch *batch, struct pan_fb_info *fb); void GENX(jm_emit_fbds)(struct panfrost_batch *batch, struct pan_fb_info *fb, struct pan_tls_info *tls);