nvk: Allow VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24795>
This commit is contained in:
Faith Ekstrand
2024-02-13 22:39:35 -06:00
committed by Marge Bot
parent 6063f96c61
commit 8cce121da4
2 changed files with 27 additions and 3 deletions

View File

@@ -800,7 +800,7 @@ nvk_get_image_memory_requirements(struct nvk_device *dev,
uint64_t size_B = 0;
uint32_t align_B = 0;
if (image->disjoint) {
uint8_t plane = nvk_image_aspects_to_plane(image, aspects);
uint8_t plane = nvk_image_memory_aspects_to_plane(image, aspects);
nvk_image_plane_add_req(&image->planes[plane], &size_B, &align_B);
} else {
for (unsigned plane = 0; plane < image->plane_count; plane++)
@@ -986,7 +986,7 @@ nvk_get_image_subresource_layout(UNUSED struct nvk_device *dev,
{
const VkImageSubresource *isr = &pSubresource->imageSubresource;
const uint8_t p = nvk_image_aspects_to_plane(image, isr->aspectMask);
const uint8_t p = nvk_image_memory_aspects_to_plane(image, isr->aspectMask);
const struct nvk_image_plane *plane = &image->planes[p];
uint64_t offset_B = 0;
@@ -1096,7 +1096,7 @@ nvk_BindImageMemory2(VkDevice device,
if (image->disjoint) {
const VkBindImagePlaneMemoryInfo *plane_info =
vk_find_struct_const(pBindInfos[i].pNext, BIND_IMAGE_PLANE_MEMORY_INFO);
uint8_t plane = nvk_image_aspects_to_plane(image, plane_info->planeAspect);
uint8_t plane = nvk_image_memory_aspects_to_plane(image, plane_info->planeAspect);
nvk_image_plane_bind(dev, &image->planes[plane], mem, &offset_B);
} else {
for (unsigned plane = 0; plane < image->plane_count; plane++) {

View File

@@ -96,6 +96,12 @@ static inline uint8_t
nvk_image_aspects_to_plane(ASSERTED const struct nvk_image *image,
VkImageAspectFlags aspectMask)
{
/* Memory planes are only allowed for memory operations */
assert(!(aspectMask & (VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT |
VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT |
VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT |
VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXT)));
/* Verify that the aspects are actually in the image */
assert(!(aspectMask & ~image->vk.aspects));
@@ -111,4 +117,22 @@ nvk_image_aspects_to_plane(ASSERTED const struct nvk_image *image,
}
}
static inline uint8_t
nvk_image_memory_aspects_to_plane(ASSERTED const struct nvk_image *image,
VkImageAspectFlags aspectMask)
{
if (aspectMask & (VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT |
VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT |
VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT |
VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXT)) {
/* We don't support DRM format modifiers on anything but single-plane
* color at the moment.
*/
assert(aspectMask == VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT);
return 0;
} else {
return nvk_image_aspects_to_plane(image, aspectMask);
}
}
#endif