pan/texture: Allow uncompressed view of compressed image

Needed image copies in Vulkan, where we create RGBA views of
compressed images to do the copy.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29451>
This commit is contained in:
Boris Brezillon
2024-05-27 15:03:46 +02:00
committed by Marge Bot
parent 8eec3284e1
commit 1b16f9ec05

View File

@@ -678,7 +678,7 @@ GENX(panfrost_new_texture)(const struct pan_image_view *iview, void *out,
pan_image_view_get_plane(iview, 1) != NULL)
array_size *= 2;
unsigned width;
unsigned width, height, depth;
if (iview->buf.size) {
assert(iview->dim == MALI_TEXTURE_DIMENSION_1D);
@@ -688,17 +688,34 @@ GENX(panfrost_new_texture)(const struct pan_image_view *iview, void *out,
assert(layout->height == 1 && layout->depth == 1);
assert(iview->buf.offset + iview->buf.size <= layout->width);
width = iview->buf.size;
height = 1;
depth = 1;
} else {
width = u_minify(layout->width, iview->first_level);
height = u_minify(layout->height, iview->first_level);
depth = u_minify(layout->depth, iview->first_level);
if (util_format_is_compressed(layout->format) &&
!util_format_is_compressed(format)) {
width =
DIV_ROUND_UP(width, util_format_get_blockwidth(layout->format));
height =
DIV_ROUND_UP(height, util_format_get_blockheight(layout->format));
depth =
DIV_ROUND_UP(depth, util_format_get_blockdepth(layout->format));
assert(util_format_get_blockwidth(format) == 1);
assert(util_format_get_blockheight(format) == 1);
assert(util_format_get_blockheight(format) == 1);
assert(iview->last_level == iview->first_level);
}
}
pan_pack(out, TEXTURE, cfg) {
cfg.dimension = iview->dim;
cfg.format = mali_format;
cfg.width = width;
cfg.height = u_minify(layout->height, iview->first_level);
cfg.height = height;
if (iview->dim == MALI_TEXTURE_DIMENSION_3D)
cfg.depth = u_minify(layout->depth, iview->first_level);
cfg.depth = depth;
else
cfg.sample_count = layout->nr_samples;
cfg.swizzle = panfrost_translate_swizzle_4(swizzle);