summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-09-17 11:19:16 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2015-09-17 17:44:20 -0700
commitb5f6889648488d735e920a630917ffa17ff3691f (patch)
tree491c35414b459e7b9a98bec5d066fd438d249892
parentdcf424c98cf32597e83cbc87eb5d62909a5bf481 (diff)
vk/device: Don't allow device or instance creation with invalid extensions
-rw-r--r--src/vulkan/anv_device.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c
index cf93cd1a6eb..a1c12e0dd17 100644
--- a/src/vulkan/anv_device.c
+++ b/src/vulkan/anv_device.c
@@ -110,6 +110,21 @@ static const VkAllocCallbacks default_alloc_callbacks = {
.pfnFree = default_free
};
+static const VkExtensionProperties global_extensions[] = {
+ {
+ .extName = "VK_WSI_swapchain",
+ .specVersion = 12
+ },
+};
+
+static const VkExtensionProperties device_extensions[] = {
+ {
+ .extName = "VK_WSI_device_swapchain",
+ .specVersion = 12
+ },
+};
+
+
VkResult anv_CreateInstance(
const VkInstanceCreateInfo* pCreateInfo,
VkInstance* pInstance)
@@ -120,6 +135,19 @@ VkResult anv_CreateInstance(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
+ for (uint32_t i = 0; i < pCreateInfo->extensionCount; i++) {
+ bool found = false;
+ for (uint32_t j = 0; j < ARRAY_SIZE(global_extensions); j++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
+ global_extensions[j].extName) == 0) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ return vk_error(VK_ERROR_INVALID_EXTENSION);
+ }
+
if (pCreateInfo->pAllocCb) {
alloc_callbacks = pCreateInfo->pAllocCb;
user_data = pCreateInfo->pAllocCb->pUserData;
@@ -546,6 +574,19 @@ VkResult anv_CreateDevice(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
+ for (uint32_t i = 0; i < pCreateInfo->extensionCount; i++) {
+ bool found = false;
+ for (uint32_t j = 0; j < ARRAY_SIZE(device_extensions); j++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
+ device_extensions[j].extName) == 0) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ return vk_error(VK_ERROR_INVALID_EXTENSION);
+ }
+
anv_set_dispatch_gen(physical_device->info->gen);
device = anv_instance_alloc(instance, sizeof(*device), 8,
@@ -636,13 +677,6 @@ VkResult anv_DestroyDevice(
return VK_SUCCESS;
}
-static const VkExtensionProperties global_extensions[] = {
- {
- .extName = "VK_WSI_swapchain",
- .specVersion = 12
- },
-};
-
VkResult anv_GetGlobalExtensionProperties(
const char* pLayerName,
uint32_t* pCount,
@@ -661,13 +695,6 @@ VkResult anv_GetGlobalExtensionProperties(
return VK_SUCCESS;
}
-static const VkExtensionProperties device_extensions[] = {
- {
- .extName = "VK_WSI_device_swapchain",
- .specVersion = 12
- },
-};
-
VkResult anv_GetPhysicalDeviceExtensionProperties(
VkPhysicalDevice physicalDevice,
const char* pLayerName,