From 6899cd2b6e5bb30cff7bbf09053f73eb035d9b72 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 4 May 2022 22:55:26 -0500 Subject: [PATCH] vulkan: Start collecting enabled features in vk_device We're not trying to make this 100% complete. For now, all we care about is robustBufferAccess. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/vulkan/runtime/vk_device.c | 27 +++++++++++++++++++++++++++ src/vulkan/runtime/vk_device.h | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/src/vulkan/runtime/vk_device.c b/src/vulkan/runtime/vk_device.c index a9c19154533..a74c4c3ee48 100644 --- a/src/vulkan/runtime/vk_device.c +++ b/src/vulkan/runtime/vk_device.c @@ -75,6 +75,31 @@ get_timeline_mode(struct vk_physical_device *physical_device) return VK_DEVICE_TIMELINE_MODE_ASSISTED; } +static void +collect_enabled_features(struct vk_device *device, + const VkDeviceCreateInfo *pCreateInfo) +{ + if (pCreateInfo->pEnabledFeatures) { + if (pCreateInfo->pEnabledFeatures->robustBufferAccess) + device->enabled_features.robustBufferAccess = true; + } + + vk_foreach_struct_const(ext, pCreateInfo->pNext) { + switch (ext->sType) { + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2: { + const VkPhysicalDeviceFeatures2 *features = (const void *)ext; + if (features->features.robustBufferAccess) + device->enabled_features.robustBufferAccess = true; + break; + } + + default: + /* Don't warn */ + break; + } + } +} + VkResult vk_device_init(struct vk_device *device, struct vk_physical_device *physical_device, @@ -131,6 +156,8 @@ vk_device_init(struct vk_device *device, if (result != VK_SUCCESS) return result; + collect_enabled_features(device, pCreateInfo); + p_atomic_set(&device->private_data_next_index, 0); list_inithead(&device->queues); diff --git a/src/vulkan/runtime/vk_device.h b/src/vulkan/runtime/vk_device.h index b45501c2ad8..97b286fc413 100644 --- a/src/vulkan/runtime/vk_device.h +++ b/src/vulkan/runtime/vk_device.h @@ -103,6 +103,10 @@ struct vk_device { /** Table of enabled extensions */ struct vk_device_extension_table enabled_extensions; + struct { + bool robustBufferAccess; + } enabled_features; + /** Device-level dispatch table */ struct vk_device_dispatch_table dispatch_table;