From bd4f69a0fe495a2c584bf0e4040fc341c55d0e18 Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Tue, 27 Feb 2024 08:02:41 -0500 Subject: [PATCH] lavapipe: check drm modifier info during image create not doing anything except validation Co-authored-by: Mike Blumenkrantz Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/frontends/lavapipe/lvp_image.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/gallium/frontends/lavapipe/lvp_image.c b/src/gallium/frontends/lavapipe/lvp_image.c index 1d4cf165f3b..142573dd6ec 100644 --- a/src/gallium/frontends/lavapipe/lvp_image.c +++ b/src/gallium/frontends/lavapipe/lvp_image.c @@ -38,6 +38,28 @@ lvp_image_create(VkDevice _device, assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO); +#ifdef HAVE_LIBDRM + unsigned num_layouts = 1; + const VkSubresourceLayout *layouts = NULL; + enum pipe_format pipe_format = lvp_vk_format_to_pipe_format(pCreateInfo->format); + const VkImageDrmFormatModifierExplicitCreateInfoEXT *modinfo = (void*)vk_find_struct_const(pCreateInfo->pNext, + IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT); + + if (modinfo && pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { + assert(modinfo->drmFormatModifier == DRM_FORMAT_MOD_LINEAR); + assert(modinfo->drmFormatModifierPlaneCount == util_format_get_num_planes(pipe_format)); + num_layouts = modinfo->drmFormatModifierPlaneCount; + layouts = modinfo->pPlaneLayouts; + } + + /* planar not supported yet */ + assert(num_layouts == 1); + if (num_layouts > 1) { + mesa_loge("lavapipe: planar drm formats are not supported"); + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } +#endif + image = vk_image_create(&device->vk, pCreateInfo, alloc, sizeof(*image)); if (image == NULL) return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);