From e2b8f3d036df0a1a1a3414a87f0d13b979a64a59 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 28 Apr 2021 12:32:12 +0200 Subject: [PATCH] panfrost: Pass an image view to panfrost_estimate_texture_payload_size() Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_context.c | 35 +++++++++++++----------------- src/panfrost/lib/pan_texture.c | 23 ++++++++------------ src/panfrost/lib/pan_texture.h | 8 +------ 3 files changed, 25 insertions(+), 41 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index beb8ed3..899e1cd 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -1235,26 +1235,6 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so, assert(!first_layer && !last_layer); } - unsigned size = - (pan_is_bifrost(device) ? 0 : MALI_MIDGARD_TEXTURE_LENGTH) + - panfrost_estimate_texture_payload_size(device, - first_level, last_level, - first_layer, last_layer, - texture->nr_samples, - type, - prsrc->image.layout.modifier); - - so->bo = panfrost_bo_create(device, size, 0); - - struct panfrost_ptr payload = so->bo->ptr; - void *tex = pan_is_bifrost(device) ? - &so->bifrost_descriptor : so->bo->ptr.cpu; - - if (!pan_is_bifrost(device)) { - payload.cpu += MALI_MIDGARD_TEXTURE_LENGTH; - payload.gpu += MALI_MIDGARD_TEXTURE_LENGTH; - } - struct pan_image_view iview = { .format = format, .dim = type, @@ -1274,6 +1254,21 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so, .buf.size = buf_size, }; + unsigned size = + (pan_is_bifrost(device) ? 0 : MALI_MIDGARD_TEXTURE_LENGTH) + + panfrost_estimate_texture_payload_size(device, &iview); + + so->bo = panfrost_bo_create(device, size, 0); + + struct panfrost_ptr payload = so->bo->ptr; + void *tex = pan_is_bifrost(device) ? + &so->bifrost_descriptor : so->bo->ptr.cpu; + + if (!pan_is_bifrost(device)) { + payload.cpu += MALI_MIDGARD_TEXTURE_LENGTH; + payload.gpu += MALI_MIDGARD_TEXTURE_LENGTH; + } + panfrost_new_texture(device, &iview, tex, &payload); } diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c index 8e00da0..18eeb91 100644 --- a/src/panfrost/lib/pan_texture.c +++ b/src/panfrost/lib/pan_texture.c @@ -200,23 +200,18 @@ panfrost_texture_num_elements( unsigned panfrost_estimate_texture_payload_size(const struct panfrost_device *dev, - unsigned first_level, - unsigned last_level, - unsigned first_layer, - unsigned last_layer, - unsigned nr_samples, - enum mali_texture_dimension dim, - uint64_t modifier) + const struct pan_image_view *iview) { /* Assume worst case */ unsigned manual_stride = pan_is_bifrost(dev) || - (modifier == DRM_FORMAT_MOD_LINEAR); - - unsigned elements = panfrost_texture_num_elements( - first_level, last_level, - first_layer, last_layer, - nr_samples, - dim == MALI_TEXTURE_DIMENSION_CUBE, manual_stride); + (iview->image->layout.modifier == DRM_FORMAT_MOD_LINEAR); + + unsigned elements = + panfrost_texture_num_elements(iview->first_level, iview->last_level, + iview->first_layer, iview->last_layer, + iview->image->layout.nr_samples, + iview->dim == MALI_TEXTURE_DIMENSION_CUBE, + manual_stride); return sizeof(mali_ptr) * elements; } diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h index 34f43df..943bbf7 100644 --- a/src/panfrost/lib/pan_texture.h +++ b/src/panfrost/lib/pan_texture.h @@ -173,13 +173,7 @@ panfrost_block_dim(uint64_t modifier, bool width, unsigned plane); unsigned panfrost_estimate_texture_payload_size(const struct panfrost_device *dev, - unsigned first_level, - unsigned last_level, - unsigned first_layer, - unsigned last_layer, - unsigned nr_samples, - enum mali_texture_dimension dim, - uint64_t modifier); + const struct pan_image_view *iview); void panfrost_new_texture(const struct panfrost_device *dev, -- 2.7.4