From 7e1e0c6824cdbe1d735b2beefb7ef4717da3a800 Mon Sep 17 00:00:00 2001 From: "duncan.hopkins" Date: Fri, 27 Oct 2023 10:18:34 +0100 Subject: [PATCH] zink: stopped the use of VkFormatProperties3 if the reported API is less than 1.3 or VK_KHR_format_feature_flags2 not present. The MoltenVK (time of writing) only implements Vulkan 1.2 APIs and no `VK_KHR_format_feature_flags2` device extension. This means VkFormatProperties3 is not supported, and is left blank when used in `populate_format_props()`. If non-1.3 is detected then the same values are read from the `VkFormatProperties2` `props` location. Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/drivers/zink/zink_device_info.py | 3 +- src/gallium/drivers/zink/zink_screen.c | 29 ++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/zink/zink_device_info.py b/src/gallium/drivers/zink/zink_device_info.py index 17222001180..4e0372216ea 100644 --- a/src/gallium/drivers/zink/zink_device_info.py +++ b/src/gallium/drivers/zink/zink_device_info.py @@ -322,7 +322,8 @@ EXTENSIONS = [ features=True, conditions=["$feats.shaderDemoteToHelperInvocation"]), Extension("VK_KHR_shader_float_controls", - alias="float_controls") + alias="float_controls"), + Extension("VK_KHR_format_feature_flags2"), ] # constructor: Versions(device_version(major, minor, patch), struct_version(major, minor)) diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 5ccd5647b48..44c960b6e00 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -2229,15 +2229,28 @@ retry: props.pNext = &mod_props; } VkFormatProperties3 props3 = {0}; - props3.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3; - props3.pNext = props.pNext; - props.pNext = &props3; + if (screen->info.have_KHR_format_feature_flags2 || screen->info.have_vulkan13) { + props3.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3; + props3.pNext = props.pNext; + props.pNext = &props3; + } + VKSCR(GetPhysicalDeviceFormatProperties2)(screen->pdev, format, &props); - screen->format_props[i].linearTilingFeatures = props3.linearTilingFeatures; - screen->format_props[i].optimalTilingFeatures = props3.optimalTilingFeatures; - screen->format_props[i].bufferFeatures = props3.bufferFeatures; - if (props3.linearTilingFeatures & VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV) - screen->format_props[i].linearTilingFeatures |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; + + if (screen->info.have_KHR_format_feature_flags2 || screen->info.have_vulkan13) { + screen->format_props[i].linearTilingFeatures = props3.linearTilingFeatures; + screen->format_props[i].optimalTilingFeatures = props3.optimalTilingFeatures; + screen->format_props[i].bufferFeatures = props3.bufferFeatures; + + if (props3.linearTilingFeatures & VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV) + screen->format_props[i].linearTilingFeatures |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; + } else { + // MoltenVk is 1.2 API + screen->format_props[i].linearTilingFeatures = props.formatProperties.linearTilingFeatures; + screen->format_props[i].optimalTilingFeatures = props.formatProperties.optimalTilingFeatures; + screen->format_props[i].bufferFeatures = props.formatProperties.bufferFeatures; + } + if (screen->info.have_EXT_image_drm_format_modifier && mod_props.drmFormatModifierCount) { screen->modifier_props[i].drmFormatModifierCount = mod_props.drmFormatModifierCount; screen->modifier_props[i].pDrmFormatModifierProperties = ralloc_array(screen, VkDrmFormatModifierPropertiesEXT, mod_props.drmFormatModifierCount);