From ca35023ed08a5ded8b218f8a731597df68bf77a3 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Sun, 5 May 2024 15:19:35 +0200 Subject: [PATCH] vkd3d: Only request properties and features when the corresponding extension is available. This fixes a number of validation errors. --- libs/vkd3d/device.c | 51 ++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 9fe4f08d..36d84339 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -869,29 +869,41 @@ static void vkd3d_physical_device_info_init(struct vkd3d_physical_device_info *i info->features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; conditional_rendering_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT; - vk_prepend_struct(&info->features2, conditional_rendering_features); + if (vulkan_info->EXT_conditional_rendering) + vk_prepend_struct(&info->features2, conditional_rendering_features); depth_clip_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT; - vk_prepend_struct(&info->features2, depth_clip_features); + if (vulkan_info->EXT_depth_clip_enable) + vk_prepend_struct(&info->features2, depth_clip_features); descriptor_indexing_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT; - vk_prepend_struct(&info->features2, descriptor_indexing_features); + if (vulkan_info->EXT_descriptor_indexing) + vk_prepend_struct(&info->features2, descriptor_indexing_features); fragment_shader_interlock_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT; - vk_prepend_struct(&info->features2, fragment_shader_interlock_features); + if (vulkan_info->EXT_fragment_shader_interlock) + vk_prepend_struct(&info->features2, fragment_shader_interlock_features); robustness2_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT; - vk_prepend_struct(&info->features2, robustness2_features); + if (vulkan_info->EXT_robustness2) + vk_prepend_struct(&info->features2, robustness2_features); demote_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT; - vk_prepend_struct(&info->features2, demote_features); + if (vulkan_info->EXT_shader_demote_to_helper_invocation) + vk_prepend_struct(&info->features2, demote_features); buffer_alignment_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT; - vk_prepend_struct(&info->features2, buffer_alignment_features); + if (vulkan_info->EXT_texel_buffer_alignment) + vk_prepend_struct(&info->features2, buffer_alignment_features); xfb_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT; - vk_prepend_struct(&info->features2, xfb_features); + if (vulkan_info->EXT_transform_feedback) + vk_prepend_struct(&info->features2, xfb_features); vertex_divisor_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT; - vk_prepend_struct(&info->features2, vertex_divisor_features); + if (vulkan_info->EXT_vertex_attribute_divisor) + vk_prepend_struct(&info->features2, vertex_divisor_features); timeline_semaphore_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR; - vk_prepend_struct(&info->features2, timeline_semaphore_features); + if (vulkan_info->KHR_timeline_semaphore) + vk_prepend_struct(&info->features2, timeline_semaphore_features); mutable_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT; - vk_prepend_struct(&info->features2, mutable_features); + if (vulkan_info->EXT_mutable_descriptor_type) + vk_prepend_struct(&info->features2, mutable_features); formats4444_features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT; - vk_prepend_struct(&info->features2, formats4444_features); + if (vulkan_info->EXT_4444_formats) + vk_prepend_struct(&info->features2, formats4444_features); if (vulkan_info->KHR_get_physical_device_properties2) VK_CALL(vkGetPhysicalDeviceFeatures2KHR(physical_device, &info->features2)); @@ -901,15 +913,20 @@ static void vkd3d_physical_device_info_init(struct vkd3d_physical_device_info *i info->properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; maintenance3_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES; - vk_prepend_struct(&info->properties2, maintenance3_properties); + if (vulkan_info->KHR_maintenance3) + vk_prepend_struct(&info->properties2, maintenance3_properties); descriptor_indexing_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT; - vk_prepend_struct(&info->properties2, descriptor_indexing_properties); + if (vulkan_info->EXT_descriptor_indexing) + vk_prepend_struct(&info->properties2, descriptor_indexing_properties); buffer_alignment_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT; - vk_prepend_struct(&info->properties2, buffer_alignment_properties); + if (vulkan_info->EXT_texel_buffer_alignment) + vk_prepend_struct(&info->properties2, buffer_alignment_properties); xfb_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT; - vk_prepend_struct(&info->properties2, xfb_properties); + if (vulkan_info->EXT_transform_feedback) + vk_prepend_struct(&info->properties2, xfb_properties); vertex_divisor_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT; - vk_prepend_struct(&info->properties2, vertex_divisor_properties); + if (vulkan_info->EXT_vertex_attribute_divisor) + vk_prepend_struct(&info->properties2, vertex_divisor_properties); subgroup_properties->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES; if (d3d12_device_environment_is_vulkan_min_1_1(device)) vk_prepend_struct(&info->properties2, subgroup_properties);