vkCreateInfo: support VkImageDrmFormatModifierListCreateInfoEXT
If the host supports it, forward. Otherwise, emulate DRM_FORMAT_MOD_LINEAR if requested. Tested by running vkcube-wayland against kumquat (https://crosvm.dev/book/appendix/rutabaga_gfx.html#kumquat-media-server), on: - Intel(R) UHD Graphics (CML GT2) - AMD Radeon Pro W6400 (RADV NAVI24) cd $(crosvm_dir)/rutabaga_gfx/kumquat/server/ && ./target/debug/kumquat export MESA_LOADER_DRIVER_OVERRIDE=zink export VK_ICD_FILENAMES=$(gfxstream_dir)/guest-build/guest/vulkan/gfxstream_vk_devenv_icd.x86_64.json vkcube-wayland Result: https://screenshot.googleplex.com/7X5DNPPou5XtWet Reviewed-by: Aaron Ruby <aruby@blackberry.com> Acked-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
committed by
Marge Bot
parent
e137086383
commit
ebee8b8279
@@ -4233,6 +4233,7 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
||||
#if defined(LINUX_GUEST_BUILD)
|
||||
bool isDmaBufImage = false;
|
||||
VkImageDrmFormatModifierExplicitCreateInfoEXT localDrmFormatModifierInfo;
|
||||
VkImageDrmFormatModifierListCreateInfoEXT localDrmFormatModifierList;
|
||||
|
||||
if (extImgCiPtr &&
|
||||
(extImgCiPtr->handleTypes & VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT)) {
|
||||
@@ -4249,15 +4250,29 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
||||
|
||||
const VkImageDrmFormatModifierExplicitCreateInfoEXT* drmFmtMod =
|
||||
vk_find_struct<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo);
|
||||
if (drmFmtMod) {
|
||||
const VkImageDrmFormatModifierListCreateInfoEXT* drmFmtModList =
|
||||
vk_find_struct<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo);
|
||||
if (drmFmtMod || drmFmtModList) {
|
||||
if (getHostDeviceExtensionIndex(VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) !=
|
||||
-1) {
|
||||
// host supports DRM format modifiers => forward the struct
|
||||
localDrmFormatModifierInfo = vk_make_orphan_copy(*drmFmtMod);
|
||||
vk_append_struct(&structChainIter, &localDrmFormatModifierInfo);
|
||||
if (drmFmtMod) {
|
||||
localDrmFormatModifierInfo = vk_make_orphan_copy(*drmFmtMod);
|
||||
vk_append_struct(&structChainIter, &localDrmFormatModifierInfo);
|
||||
}
|
||||
if (drmFmtModList) {
|
||||
localDrmFormatModifierList = vk_make_orphan_copy(*drmFmtModList);
|
||||
vk_append_struct(&structChainIter, &localDrmFormatModifierList);
|
||||
}
|
||||
} else {
|
||||
bool canUseLinearModifier =
|
||||
(drmFmtMod && drmFmtMod->drmFormatModifier == DRM_FORMAT_MOD_LINEAR) ||
|
||||
std::any_of(
|
||||
drmFmtModList->pDrmFormatModifiers,
|
||||
drmFmtModList->pDrmFormatModifiers + drmFmtModList->drmFormatModifierCount,
|
||||
[](const uint64_t mod) { return mod == DRM_FORMAT_MOD_LINEAR; });
|
||||
// host doesn't support DRM format modifiers, try emulating
|
||||
if (drmFmtMod->drmFormatModifier == DRM_FORMAT_MOD_LINEAR) {
|
||||
if (canUseLinearModifier) {
|
||||
mesa_logd("emulating DRM_FORMAT_MOD_LINEAR with VK_IMAGE_TILING_LINEAR");
|
||||
localCreateInfo.tiling = VK_IMAGE_TILING_LINEAR;
|
||||
} else {
|
||||
|
||||
@@ -142,6 +142,8 @@ REGISTER_VK_STRUCT_ID(VkPhysicalDeviceImageDrmFormatModifierInfoEXT,
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkDrmFormatModifierPropertiesListEXT,
|
||||
VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkImageDrmFormatModifierListCreateInfoEXT,
|
||||
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
|
||||
|
||||
#undef REGISTER_VK_STRUCT_ID
|
||||
|
||||
|
||||
Reference in New Issue
Block a user