aboutsummaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2016-09-08 12:28:38 -0600
committerMark Young <marky@lunarg.com>2016-09-08 15:10:40 -0600
commit73bffc29ff1ad005d4125713014c826fca52739f (patch)
tree6fecfa552bf879cf60deadf929b69d7d6ce1e3aa /loader
parentdb4d533441e56f95e27cae5e5f9ae6260c8ae4b8 (diff)
downloadusermoji-73bffc29ff1ad005d4125713014c826fca52739f.tar.xz
loader: Add checks for usage of wsi extensions
The loader really should validate that the WSI extensions are enabled before being called. Additionally, I needed to add more checks for the KHR_display_swapchain extension in the parameter_validation and object_tracker layers. Change-Id: I3d07d46baf551be6f5f07e5374d6c683e3f52e7e
Diffstat (limited to 'loader')
-rw-r--r--loader/loader.c1
-rw-r--r--loader/loader.h1
-rw-r--r--loader/wsi.c42
-rw-r--r--loader/wsi.h2
4 files changed, 32 insertions, 14 deletions
diff --git a/loader/loader.c b/loader/loader.c
index ac8f4fc3..5a347db4 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -4324,6 +4324,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(
}
}
+ wsi_create_device(dev, pCreateInfo);
extensions_create_device(dev, pCreateInfo);
// TODO: Why does fpCreateDevice behave differently than
diff --git a/loader/loader.h b/loader/loader.h
index 9b57372d..651d5076 100644
--- a/loader/loader.h
+++ b/loader/loader.h
@@ -160,6 +160,7 @@ struct loader_dev_ext_dispatch_table {
union loader_device_extension_enables {
struct {
+ uint8_t khr_display_swapchain : 1;
uint8_t ext_debug_marker : 1;
uint8_t amd_draw_indirect_count : 1;
uint8_t nv_external_memory_win32 : 1;
diff --git a/loader/wsi.c b/loader/wsi.c
index 10c5260e..13d30047 100644
--- a/loader/wsi.c
+++ b/loader/wsi.c
@@ -158,6 +158,20 @@ void wsi_create_instance(struct loader_instance *ptr_instance,
}
}
+void wsi_create_device(struct loader_device *dev,
+ const VkDeviceCreateInfo *pCreateInfo) {
+ dev->loader_dispatch.enabled_known_extensions.khr_display_swapchain = 0;
+
+ for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
+ VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME) == 0) {
+ dev->loader_dispatch.enabled_known_extensions
+ .khr_display_swapchain = 1;
+ return;
+ }
+ }
+}
+
// Linux WSI surface extensions are not always compiled into the loader. (Assume
// for Windows the KHR_win32_surface is always compiled into loader). A given
// Linux build environment might not have the headers required for building one
@@ -403,9 +417,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
const VkLayerDispatchTable *disp;
disp = loader_get_dispatch(device);
- VkResult res =
- disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
- return res;
+ return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator,
+ pSwapchain);
}
// This is the trampoline entrypoint for DestroySwapchainKHR
@@ -424,9 +437,8 @@ vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain,
VkImage *pSwapchainImages) {
const VkLayerDispatchTable *disp;
disp = loader_get_dispatch(device);
- VkResult res = disp->GetSwapchainImagesKHR(
+ return disp->GetSwapchainImagesKHR(
device, swapchain, pSwapchainImageCount, pSwapchainImages);
- return res;
}
// This is the trampoline entrypoint for AcquireNextImageKHR
@@ -436,9 +448,8 @@ vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain,
uint32_t *pImageIndex) {
const VkLayerDispatchTable *disp;
disp = loader_get_dispatch(device);
- VkResult res = disp->AcquireNextImageKHR(device, swapchain, timeout,
- semaphore, fence, pImageIndex);
- return res;
+ return disp->AcquireNextImageKHR(device, swapchain, timeout,
+ semaphore, fence, pImageIndex);
}
// This is the trampoline entrypoint for QueuePresentKHR
@@ -446,8 +457,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
const VkLayerDispatchTable *disp;
disp = loader_get_dispatch(queue);
- VkResult res = disp->QueuePresentKHR(queue, pPresentInfo);
- return res;
+ return disp->QueuePresentKHR(queue, pPresentInfo);
}
#ifdef VK_USE_PLATFORM_WIN32_KHR
@@ -1268,10 +1278,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(
VkDevice device, uint32_t swapchainCount,
const VkSwapchainCreateInfoKHR *pCreateInfos,
const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) {
- const VkLayerDispatchTable *disp;
- disp = loader_get_dispatch(device);
- return disp->CreateSharedSwapchainsKHR(
- device, swapchainCount, pCreateInfos, pAllocator, pSwapchains);
+ struct loader_dev_dispatch_table *disp = loader_get_dev_dispatch(device);
+ if (0 == disp->enabled_known_extensions.khr_display_swapchain ||
+ NULL == disp->core_dispatch.CreateSharedSwapchainsKHR) {
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ } else {
+ return disp->core_dispatch.CreateSharedSwapchainsKHR(
+ device, swapchainCount, pCreateInfos, pAllocator, pSwapchains);
+ }
}
bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
diff --git a/loader/wsi.h b/loader/wsi.h
index fa600888..7409e7d7 100644
--- a/loader/wsi.h
+++ b/loader/wsi.h
@@ -27,6 +27,8 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
void wsi_create_instance(struct loader_instance *ptr_instance,
const VkInstanceCreateInfo *pCreateInfo);
+void wsi_create_device(struct loader_device *dev,
+ const VkDeviceCreateInfo *pCreateInfo);
bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop);
VKAPI_ATTR void VKAPI_CALL