mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
panvk: Pass an image to panvk_plane_count()
We're going to support Z24S8 planar images, but only on v9+. Let's pass an image to panvk_plane_index() so we can extract the stencil plane index from the number of planes instead of basing it only on the format. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Eric R. Smith <eric.smith@collabora.com> Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37158>
This commit is contained in:
parent
7ac76d4e91
commit
2cd851a55f
5 changed files with 21 additions and 22 deletions
|
|
@ -83,7 +83,7 @@ panvk_copy_image_to_from_memory(struct image_params img,
|
|||
*/
|
||||
assert(util_bitcount(img.subres.aspectMask) == 1);
|
||||
unsigned plane_idx =
|
||||
panvk_plane_index(img.img->vk.format, img.subres.aspectMask);
|
||||
panvk_plane_index(img.img, img.subres.aspectMask);
|
||||
assert(plane_idx < PANVK_MAX_PLANES);
|
||||
struct panvk_image_plane *plane = &img.img->planes[plane_idx];
|
||||
const struct pan_image_layout *plane_layout = &plane->plane.layout;
|
||||
|
|
@ -260,8 +260,8 @@ panvk_CopyMemoryToImage(VkDevice device, const VkCopyMemoryToImageInfo *info)
|
|||
VkResult result = VK_SUCCESS;
|
||||
|
||||
for (unsigned i = 0; i < info->regionCount; i++) {
|
||||
uint8_t p = panvk_plane_index(
|
||||
dst->vk.format, info->pRegions[i].imageSubresource.aspectMask);
|
||||
uint8_t p =
|
||||
panvk_plane_index(dst, info->pRegions[i].imageSubresource.aspectMask);
|
||||
|
||||
result = mmap_plane(dst, p, PROT_WRITE, dst_cpu);
|
||||
if (result != VK_SUCCESS)
|
||||
|
|
@ -304,8 +304,8 @@ panvk_CopyImageToMemory(VkDevice device, const VkCopyImageToMemoryInfo *info)
|
|||
VkResult result = VK_SUCCESS;
|
||||
|
||||
for (unsigned i = 0; i < info->regionCount; i++) {
|
||||
uint8_t p = panvk_plane_index(
|
||||
src->vk.format, info->pRegions[i].imageSubresource.aspectMask);
|
||||
uint8_t p =
|
||||
panvk_plane_index(src, info->pRegions[i].imageSubresource.aspectMask);
|
||||
|
||||
result = mmap_plane(src, p, PROT_READ, src_cpu);
|
||||
if (result != VK_SUCCESS)
|
||||
|
|
@ -337,10 +337,8 @@ panvk_copy_image_to_image(struct panvk_image *dst, void *dst_cpu,
|
|||
VkImageSubresourceLayers src_subres = region->srcSubresource;
|
||||
VkImageSubresourceLayers dst_subres = region->dstSubresource;
|
||||
|
||||
unsigned src_plane_idx =
|
||||
panvk_plane_index(src->vk.format, src_subres.aspectMask);
|
||||
unsigned dst_plane_idx =
|
||||
panvk_plane_index(dst->vk.format, dst_subres.aspectMask);
|
||||
unsigned src_plane_idx = panvk_plane_index(src, src_subres.aspectMask);
|
||||
unsigned dst_plane_idx = panvk_plane_index(dst, dst_subres.aspectMask);
|
||||
assert(src_plane_idx < PANVK_MAX_PLANES);
|
||||
assert(dst_plane_idx < PANVK_MAX_PLANES);
|
||||
struct panvk_image_plane *src_plane = &src->planes[src_plane_idx];
|
||||
|
|
@ -482,10 +480,10 @@ panvk_CopyImageToImage(VkDevice device, const VkCopyImageToImageInfo *info)
|
|||
void *dst_cpu[PANVK_MAX_PLANES] = {NULL};
|
||||
|
||||
for (unsigned i = 0; i < info->regionCount; i++) {
|
||||
uint8_t src_p = panvk_plane_index(
|
||||
src->vk.format, info->pRegions[i].srcSubresource.aspectMask);
|
||||
uint8_t dst_p = panvk_plane_index(
|
||||
dst->vk.format, info->pRegions[i].dstSubresource.aspectMask);
|
||||
uint8_t src_p =
|
||||
panvk_plane_index(src, info->pRegions[i].srcSubresource.aspectMask);
|
||||
uint8_t dst_p =
|
||||
panvk_plane_index(dst, info->pRegions[i].dstSubresource.aspectMask);
|
||||
|
||||
result = mmap_plane(dst, dst_p, PROT_WRITE, dst_cpu);
|
||||
if (result != VK_SUCCESS)
|
||||
|
|
|
|||
|
|
@ -574,7 +574,7 @@ get_image_subresource_layout(const struct panvk_image *image,
|
|||
{
|
||||
const VkImageSubresource *subres = &subres2->imageSubresource;
|
||||
VkSubresourceLayout *layout = &layout2->subresourceLayout;
|
||||
unsigned plane = panvk_plane_index(image->vk.format, subres->aspectMask);
|
||||
unsigned plane = panvk_plane_index(image, subres->aspectMask);
|
||||
assert(plane < PANVK_MAX_PLANES);
|
||||
|
||||
const struct pan_image_slice_layout *slice_layout =
|
||||
|
|
@ -658,7 +658,7 @@ panvk_GetImageMemoryRequirements2(VkDevice device,
|
|||
const bool disjoint = is_disjoint(image);
|
||||
const VkImageAspectFlags aspects =
|
||||
plane_info ? plane_info->planeAspect : image->vk.aspects;
|
||||
uint8_t plane = panvk_plane_index(image->vk.format, aspects);
|
||||
uint8_t plane = panvk_plane_index(image, aspects);
|
||||
const uint64_t size =
|
||||
disjoint ? image->planes[plane].plane.layout.data_size_B :
|
||||
panvk_image_get_total_size(image);
|
||||
|
|
@ -754,7 +754,7 @@ panvk_image_bind(struct panvk_device *dev,
|
|||
const VkBindImagePlaneMemoryInfo *plane_info =
|
||||
vk_find_struct_const(bind_info->pNext, BIND_IMAGE_PLANE_MEMORY_INFO);
|
||||
const uint8_t plane =
|
||||
panvk_plane_index(image->vk.format, plane_info->planeAspect);
|
||||
panvk_plane_index(image, plane_info->planeAspect);
|
||||
panvk_image_plane_bind(dev, &image->planes[plane], mem, offset);
|
||||
} else {
|
||||
for (unsigned plane = 0; plane < image->plane_count; plane++)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ bool panvk_image_can_use_afbc(
|
|||
VkImageCreateFlags flags);
|
||||
|
||||
static inline unsigned
|
||||
panvk_plane_index(VkFormat format, VkImageAspectFlags aspect_mask)
|
||||
panvk_plane_index(const struct panvk_image *image,
|
||||
VkImageAspectFlags aspect_mask)
|
||||
{
|
||||
switch (aspect_mask) {
|
||||
default:
|
||||
|
|
@ -58,7 +59,8 @@ panvk_plane_index(VkFormat format, VkImageAspectFlags aspect_mask)
|
|||
case VK_IMAGE_ASPECT_PLANE_2_BIT:
|
||||
return 2;
|
||||
case VK_IMAGE_ASPECT_STENCIL_BIT:
|
||||
return format == VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
assert(image->plane_count > 0);
|
||||
return image->plane_count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -586,7 +586,7 @@ panvk_image_has_afbc(struct panvk_image *img, VkImageSubresourceRange range)
|
|||
VkImageAspectFlags aspect_mask =
|
||||
vk_image_expand_aspect_mask(&img->vk, range.aspectMask);
|
||||
u_foreach_bit(aspect, aspect_mask) {
|
||||
unsigned plane_index = panvk_plane_index(img->vk.format, 1u << aspect);
|
||||
unsigned plane_index = panvk_plane_index(img, 1u << aspect);
|
||||
struct panvk_image_plane *plane = &img->planes[plane_index];
|
||||
|
||||
if (drm_is_afbc(plane->image.props.modifier))
|
||||
|
|
@ -613,7 +613,7 @@ cmd_clear_afbc_metadata(VkCommandBuffer _cmdbuf,
|
|||
panvk_per_arch(cmd_meta_compute_start)(cmdbuf, &save);
|
||||
|
||||
u_foreach_bit(aspect, aspect_mask) {
|
||||
unsigned plane_index = panvk_plane_index(img->vk.format, 1u << aspect);
|
||||
unsigned plane_index = panvk_plane_index(img, 1u << aspect);
|
||||
struct panvk_image_plane *plane = &img->planes[plane_index];
|
||||
|
||||
if (!drm_is_afbc(plane->image.props.modifier))
|
||||
|
|
|
|||
|
|
@ -329,8 +329,7 @@ panvk_per_arch(CreateImageView)(VkDevice _device,
|
|||
panvk_convert_swizzle(&view->vk.swizzle, view->pview.swizzle);
|
||||
|
||||
u_foreach_bit(aspect_bit, view->vk.aspects) {
|
||||
uint8_t image_plane =
|
||||
panvk_plane_index(image->vk.format, 1u << aspect_bit);
|
||||
uint8_t image_plane = panvk_plane_index(image, 1u << aspect_bit);
|
||||
|
||||
/* Place the view plane at index 0 for single-plane views of multiplane
|
||||
* formats. Does not apply to YCbCr views of multiplane images since
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue