diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index beb8ed3228e..899e1cd3d6a 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 8e00da01446..18eeb917a89 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); + (iview->image->layout.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); + 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 34f43df32b3..943bbf7da94 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,