diff options
-rw-r--r-- | src/intel/vulkan/anv_device.c | 31 | ||||
-rw-r--r-- | src/intel/vulkan/anv_extensions_gen.py | 33 | ||||
-rw-r--r-- | src/intel/vulkan/anv_private.h | 1 |
3 files changed, 34 insertions, 31 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 777abd87578..7835b8780b9 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -476,6 +476,24 @@ static const VkAllocationCallbacks default_alloc = { .pfnFree = default_free_func, }; +VkResult anv_EnumerateInstanceExtensionProperties( + const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties) +{ + VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount); + + for (int i = 0; i < ANV_INSTANCE_EXTENSION_COUNT; i++) { + if (anv_instance_extensions_supported.extensions[i]) { + vk_outarray_append(&out, prop) { + *prop = anv_instance_extensions[i]; + } + } + } + + return vk_outarray_status(&out); +} + VkResult anv_CreateInstance( const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, @@ -522,8 +540,17 @@ VkResult anv_CreateInstance( } for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { - const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i]; - if (!anv_instance_extension_supported(ext_name)) + int idx; + for (idx = 0; idx < ANV_INSTANCE_EXTENSION_COUNT; idx++) { + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], + anv_instance_extensions[idx].extensionName) == 0) + break; + } + + if (idx >= ANV_INSTANCE_EXTENSION_COUNT) + return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT); + + if (!anv_instance_extensions_supported.extensions[idx]) return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT); } diff --git a/src/intel/vulkan/anv_extensions_gen.py b/src/intel/vulkan/anv_extensions_gen.py index dadf20a687e..b86d76326a4 100644 --- a/src/intel/vulkan/anv_extensions_gen.py +++ b/src/intel/vulkan/anv_extensions_gen.py @@ -80,6 +80,8 @@ struct anv_instance_extension_table { }; }; +extern const struct anv_instance_extension_table anv_instance_extensions_supported; + #define ANV_DEVICE_EXTENSION_COUNT ${len(device_extensions)} @@ -132,36 +134,11 @@ const VkExtensionProperties anv_instance_extensions[ANV_INSTANCE_EXTENSION_COUNT %endfor }; -bool -anv_instance_extension_supported(const char *name) -{ -%for ext in instance_extensions: - if (strcmp(name, "${ext.name}") == 0) - return ${ext.enable}; -%endfor - return false; -} - -VkResult anv_EnumerateInstanceExtensionProperties( - const char* pLayerName, - uint32_t* pPropertyCount, - VkExtensionProperties* pProperties) -{ - VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount); - +const struct anv_instance_extension_table anv_instance_extensions_supported = { %for ext in instance_extensions: - if (${ext.enable}) { - vk_outarray_append(&out, prop) { - *prop = (VkExtensionProperties) { - .extensionName = "${ext.name}", - .specVersion = ${ext.ext_version}, - }; - } - } + .${ext.name[3:]} = ${ext.enable}, %endfor - - return vk_outarray_status(&out); -} +}; uint32_t anv_physical_device_api_version(struct anv_physical_device *dev) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index d3953f10420..55417faceaa 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -803,7 +803,6 @@ struct anv_instance { VkResult anv_init_wsi(struct anv_physical_device *physical_device); void anv_finish_wsi(struct anv_physical_device *physical_device); -bool anv_instance_extension_supported(const char *name); uint32_t anv_physical_device_api_version(struct anv_physical_device *dev); bool anv_physical_device_extension_supported(struct anv_physical_device *dev, const char *name); |