From d7af85b18b58ae26cde85e62a147788d13499918 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 28 Apr 2021 13:12:10 +0200 Subject: [PATCH] panfrost: Make pan_preload_emit_*_textures() applicable to blits The texture descriptors will be emitted once and re-used in several DCDs when blitting more than one layer. Rename the functions and make them return a GPU pointer instead of filling the DCD directly. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig --- src/panfrost/lib/pan_blitter.c | 41 ++++++++++++++++------------------ 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/panfrost/lib/pan_blitter.c b/src/panfrost/lib/pan_blitter.c index 502d0d85e87..7ba559b2a41 100644 --- a/src/panfrost/lib/pan_blitter.c +++ b/src/panfrost/lib/pan_blitter.c @@ -787,43 +787,40 @@ pan_blitter_emit_midgard_sampler(struct pan_pool *pool, return sampler.gpu; } -static void -pan_preload_emit_bifrost_textures(struct pan_pool *pool, +static mali_ptr +pan_blitter_emit_bifrost_textures(struct pan_pool *pool, unsigned tex_count, - const struct pan_image_view **views, - struct MALI_DRAW *draw) + const struct pan_image_view **views) { struct panfrost_ptr textures = panfrost_pool_alloc_desc_array(pool, tex_count, BIFROST_TEXTURE); for (unsigned i = 0; i < tex_count; i++) { void *texture = textures.cpu + (MALI_BIFROST_TEXTURE_LENGTH * i); + size_t payload_size = + panfrost_estimate_texture_payload_size(pool->dev, views[i]); struct panfrost_ptr surfaces = - panfrost_pool_alloc_desc_array(pool, - views[i]->image->layout.nr_samples, - SURFACE_WITH_STRIDE); + panfrost_pool_alloc_aligned(pool, payload_size, + MALI_SURFACE_WITH_STRIDE_ALIGN); panfrost_new_texture(pool->dev, views[i], texture, &surfaces); } - draw->textures = textures.gpu; + return textures.gpu; } -static void -pan_preload_emit_midgard_textures(struct pan_pool *pool, +static mali_ptr +pan_blitter_emit_midgard_textures(struct pan_pool *pool, unsigned tex_count, - const struct pan_image_view **views, - struct MALI_DRAW *draw) + const struct pan_image_view **views) { mali_ptr textures[8] = { 0 }; for (unsigned i = 0; i < tex_count; i++) { - unsigned nr_samples = views[i]->image->layout.nr_samples; + size_t sz = MALI_MIDGARD_TEXTURE_LENGTH + + panfrost_estimate_texture_payload_size(pool->dev, views[i]); struct panfrost_ptr texture = - panfrost_pool_alloc_desc_aggregate(pool, - PAN_DESC(MIDGARD_TEXTURE), - PAN_DESC_ARRAY(nr_samples, - SURFACE_WITH_STRIDE)); + panfrost_pool_alloc_aligned(pool, sz, MALI_MIDGARD_TEXTURE_ALIGN); struct panfrost_ptr surfaces = { .cpu = texture.cpu + MALI_MIDGARD_TEXTURE_LENGTH, .gpu = texture.gpu + MALI_MIDGARD_TEXTURE_LENGTH, @@ -833,9 +830,9 @@ pan_preload_emit_midgard_textures(struct pan_pool *pool, textures[i] = texture.gpu; } - draw->textures = panfrost_pool_upload_aligned(pool, textures, - tex_count * sizeof(mali_ptr), - sizeof(mali_ptr)); + return panfrost_pool_upload_aligned(pool, textures, + tex_count * sizeof(mali_ptr), + sizeof(mali_ptr)); } static void @@ -877,9 +874,9 @@ pan_preload_emit_textures(struct pan_pool *pool, } if (pan_is_bifrost(pool->dev)) - pan_preload_emit_bifrost_textures(pool, tex_count, views, draw); + draw->textures = pan_blitter_emit_bifrost_textures(pool, tex_count, views); else - pan_preload_emit_midgard_textures(pool, tex_count, views, draw); + draw->textures = pan_blitter_emit_midgard_textures(pool, tex_count, views); } static void