aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Elliott <ian@lunarg.com>2015-07-06 14:36:13 -0600
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-07-17 10:05:22 -0600
commitc0bb127c15882098b791a4d69dca51cd1cfba21c (patch)
treec2e96aef873d9c790f35d6b05350da959c27f75d
parent4723fe81628c65f0a216614cc1feff1bc7f1849a (diff)
downloadusermoji-c0bb127c15882098b791a4d69dca51cd1cfba21c.tar.xz
loader: Changes to use new WSI swapchain extensions.
Use device extension list, not global. When validating the PhysicalDevice extensions really need to use the device extension list not the loader's global list. Fix include to find aligned_alloc
-rw-r--r--loader/CMakeLists.txt5
-rw-r--r--loader/gpa_helper.h4
-rw-r--r--loader/loader.c20
-rw-r--r--loader/loader.h5
-rw-r--r--loader/table_ops.h2
-rw-r--r--loader/trampoline.c2
-rw-r--r--loader/wsi_swapchain.c127
-rw-r--r--loader/wsi_swapchain.h49
8 files changed, 198 insertions, 16 deletions
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index f9ae4bc0..c06d04b2 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -18,8 +18,8 @@ set(LOADER_SRCS
loader.h
vk_loader_platform.h
trampoline.c
- wsi_lunarg.c
- wsi_lunarg.h
+ wsi_swapchain.c
+ wsi_swapchain.h
debug_report.c
debug_report.h
table_ops.h
@@ -28,6 +28,7 @@ set(LOADER_SRCS
cJSON.h
)
+
if (WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVK_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS")
diff --git a/loader/gpa_helper.h b/loader/gpa_helper.h
index 43432d0a..5373603e 100644
--- a/loader/gpa_helper.h
+++ b/loader/gpa_helper.h
@@ -23,7 +23,7 @@
*/
#include <string.h>
-#include "wsi_lunarg.h"
+#include "wsi_swapchain.h"
static inline void* globalGetProcAddr(const char *name)
{
@@ -373,8 +373,6 @@ static inline void *loader_non_passthrough_gpa(const char *name)
return (void*) vkGetDeviceQueue;
if (!strcmp(name, "CreateCommandBuffer"))
return (void*) vkCreateCommandBuffer;
- if (!strcmp(name, "CreateSwapChainWSI"))
- return (void*) wsi_lunarg_CreateSwapChainWSI;
return NULL;
}
diff --git a/loader/loader.c b/loader/loader.c
index bb1ba994..f89db4a8 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -42,7 +42,6 @@
#endif // WIN32
#include "vk_loader_platform.h"
#include "loader.h"
-#include "wsi_lunarg.h"
#include "gpa_helper.h"
#include "table_ops.h"
#include "debug_report.h"
@@ -83,6 +82,9 @@ uint32_t g_loader_log_msgs = 0;
// additionally CreateDevice and DestroyDevice needs to be locked
loader_platform_thread_mutex loader_lock;
+// This table contains the loader's instance dispatch table, which contains
+// default functions if no instance layers are activated. This contains
+// pointers to "terminator functions".
const VkLayerInstanceDispatchTable instance_disp = {
.GetInstanceProcAddr = loader_GetInstanceProcAddr,
.CreateInstance = loader_CreateInstance,
@@ -98,6 +100,7 @@ const VkLayerInstanceDispatchTable instance_disp = {
.GetPhysicalDeviceExtensionProperties = loader_GetPhysicalDeviceExtensionProperties,
.GetPhysicalDeviceLayerProperties = loader_GetPhysicalDeviceLayerProperties,
.GetPhysicalDeviceSparseImageFormatProperties = loader_GetPhysicalDeviceSparseImageFormatProperties,
+ .GetPhysicalDeviceSurfaceSupportWSI = loader_GetPhysicalDeviceSurfaceSupportWSI,
.DbgCreateMsgCallback = loader_DbgCreateMsgCallback,
.DbgDestroyMsgCallback = loader_DbgDestroyMsgCallback,
};
@@ -822,6 +825,7 @@ void loader_coalesce_extensions(void)
};
// Traverse loader's extensions, adding non-duplicate extensions to the list
+ wsi_swapchain_add_instance_extensions(&loader.global_extensions);
debug_report_add_instance_extensions(&loader.global_extensions);
}
@@ -1083,6 +1087,10 @@ static void loader_icd_init_entrys(struct loader_icd *icd,
LOOKUP(DbgDestroyMsgCallback);
#undef LOOKUP
+ icd->GetPhysicalDeviceSurfaceSupportWSI =
+ (PFN_vkGetPhysicalDeviceSurfaceSupportWSI) loader_platform_get_proc_address(scanned_icds->handle,
+ "vkGetPhysicalDeviceSurfaceSupportWSI");
+
return;
}
@@ -2843,8 +2851,7 @@ static PFN_vkVoidFunction VKAPI loader_GetInstanceProcAddr(VkInstance instance,
return addr;
}
- /* TODO Remove this once WSI has no loader special code */
- addr = wsi_lunarg_GetInstanceProcAddr(instance, pName);
+ addr = wsi_swapchain_GetInstanceProcAddr(ptr_instance, pName);
if (addr) {
return addr;
}
@@ -2881,13 +2888,6 @@ static PFN_vkVoidFunction VKAPI loader_GetDeviceProcAddr(VkDevice device, const
return addr;
}
- /* return any extension device entrypoints the loader knows about */
- /* TODO once WSI has no loader special code remove this */
- addr = wsi_lunarg_GetDeviceProcAddr(device, pName);
- if (addr) {
- return addr;
- }
-
/* return the dispatch table entrypoint for the fastest case */
const VkLayerDispatchTable *disp_table = * (VkLayerDispatchTable **) device;
if (disp_table == NULL)
diff --git a/loader/loader.h b/loader/loader.h
index 1714106f..2bd6b3ea 100644
--- a/loader/loader.h
+++ b/loader/loader.h
@@ -30,7 +30,7 @@
#include <vulkan.h>
#include <vk_debug_report_lunarg.h>
-#include <vk_wsi_lunarg.h>
+#include <vk_wsi_swapchain.h>
#include <vk_layer.h>
#include <vk_icd.h>
#include <assert.h>
@@ -154,6 +154,7 @@ struct loader_icd {
PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties;
PFN_vkGetPhysicalDeviceLayerProperties GetPhysicalDeviceLayerProperties;
PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
+ PFN_vkGetPhysicalDeviceSurfaceSupportWSI GetPhysicalDeviceSurfaceSupportWSI;
PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
@@ -252,6 +253,8 @@ struct loader_instance {
VkLayerDbgFunctionNode *DbgFunctionHead;
VkAllocCallbacks alloc_callbacks;
+
+ bool wsi_swapchain_enabled;
};
struct loader_struct {
diff --git a/loader/table_ops.h b/loader/table_ops.h
index bbb83e07..de75eb2a 100644
--- a/loader/table_ops.h
+++ b/loader/table_ops.h
@@ -523,6 +523,8 @@ static inline void *loader_lookup_instance_dispatch_table(
return (void *) table->GetPhysicalDeviceExtensionProperties;
if (!strcmp(name, "GetPhysicalDeviceLayerProperties"))
return (void *) table->GetPhysicalDeviceLayerProperties;
+ if (!strcmp(name, "GetPhysicalDeviceSurfaceSupportWSI"))
+ return (void *) table->GetPhysicalDeviceSurfaceSupportWSI;
if (!strcmp(name, "DbgCreateMsgCallback"))
return (void *) table->DbgCreateMsgCallback;
if (!strcmp(name, "DbgDestroyMsgCallback"))
diff --git a/loader/trampoline.c b/loader/trampoline.c
index 66978c1b..5e4a8bf1 100644
--- a/loader/trampoline.c
+++ b/loader/trampoline.c
@@ -28,6 +28,7 @@
#include "vk_loader_platform.h"
#include "loader.h"
#include "debug_report.h"
+#include "wsi_swapchain.h"
#if defined(WIN32)
// On Windows need to disable global optimization for function entrypoints or
@@ -111,6 +112,7 @@ LOADER_EXPORT VkResult VKAPI vkCreateInstance(
return res;
}
+ wsi_swapchain_create_instance(ptr_instance, pCreateInfo);
debug_report_create_instance(ptr_instance, pCreateInfo);
/* enable any layers on instance chain */
diff --git a/loader/wsi_swapchain.c b/loader/wsi_swapchain.c
new file mode 100644
index 00000000..c41841d0
--- /dev/null
+++ b/loader/wsi_swapchain.c
@@ -0,0 +1,127 @@
+/*
+ * Vulkan
+ *
+ * Copyright (C) 2015 LunarG, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Jon Ashburn <jon@lunarg.com>
+ * Courtney Goeltzenleuchter <courtney@lunarg.com>
+ * Ian Elliott <ian@lunarg.com>
+ */
+
+#define _ISOC11_SOURCE /* for aligned_alloc() */
+#include <stdlib.h>
+#include <string.h>
+#include "vk_loader_platform.h"
+#include "loader.h"
+#include "wsi_swapchain.h"
+
+static const struct loader_extension_property wsi_swapchain_extension_info = {
+ .info = {
+ .extName = VK_WSI_SWAPCHAIN_EXTENSION_NAME,
+ .specVersion = VK_WSI_SWAPCHAIN_REVISION,
+ },
+ .origin = VK_EXTENSION_ORIGIN_LOADER,
+};
+
+void wsi_swapchain_add_instance_extensions(
+ struct loader_extension_list *ext_list)
+{
+ loader_add_to_ext_list(ext_list, 1, &wsi_swapchain_extension_info);
+}
+
+void wsi_swapchain_create_instance(
+ struct loader_instance *ptr_instance,
+ const VkInstanceCreateInfo *pCreateInfo)
+{
+ ptr_instance->wsi_swapchain_enabled = false;
+
+ for (uint32_t i = 0; i < pCreateInfo->extensionCount; i++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_WSI_SWAPCHAIN_EXTENSION_NAME) == 0) {
+ ptr_instance->wsi_swapchain_enabled = true;
+ return;
+ }
+ }
+}
+
+/*
+ * This is the trampoline entrypoint
+ * for GetPhysicalDeviceSurfaceSupportWSI
+ */
+VkResult wsi_swapchain_GetPhysicalDeviceSurfaceSupportWSI(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueNodeIndex,
+ const VkSurfaceDescriptionWSI* pSurfaceDescription,
+ VkBool32* pSupported)
+{
+ const VkLayerInstanceDispatchTable *disp;
+// TBD/TODO: DO WE NEED TO DO LOCKING FOR THIS FUNCTION?
+ disp = loader_get_instance_dispatch(physicalDevice);
+ loader_platform_thread_lock_mutex(&loader_lock);
+ VkResult res = disp->GetPhysicalDeviceSurfaceSupportWSI(
+ physicalDevice,
+ queueNodeIndex,
+ pSurfaceDescription,
+ pSupported);
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ return res;
+}
+
+/*
+ * This is the instance chain terminator function
+ * for GetPhysicalDeviceSurfaceSupportWSI
+ */
+VkResult loader_GetPhysicalDeviceSurfaceSupportWSI(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueNodeIndex,
+ const VkSurfaceDescriptionWSI* pSurfaceDescription,
+ VkBool32* pSupported)
+{
+ uint32_t gpu_index;
+ struct loader_icd *icd = loader_get_icd(physicalDevice, &gpu_index);
+ VkResult res = VK_ERROR_UNAVAILABLE;
+ *pSupported = false;
+
+ if (icd->GetPhysicalDeviceSurfaceSupportWSI) {
+ res = icd->GetPhysicalDeviceSurfaceSupportWSI(physicalDevice,
+ queueNodeIndex,
+ pSurfaceDescription,
+ pSupported);
+ }
+
+ return res;
+}
+
+
+void *wsi_swapchain_GetInstanceProcAddr(
+ struct loader_instance *ptr_instance,
+ const char* pName)
+{
+ if (ptr_instance == VK_NULL_HANDLE || !ptr_instance->wsi_swapchain_enabled) {
+ return NULL;
+ }
+
+ if (!strcmp(pName, "vkGetPhysicalDeviceSurfaceSupportWSI")) {
+ return (void*) wsi_swapchain_GetPhysicalDeviceSurfaceSupportWSI;
+ }
+
+ return NULL;
+}
diff --git a/loader/wsi_swapchain.h b/loader/wsi_swapchain.h
new file mode 100644
index 00000000..598ffd40
--- /dev/null
+++ b/loader/wsi_swapchain.h
@@ -0,0 +1,49 @@
+/*
+ * Vulkan
+ *
+ * Copyright (C) 2015 LunarG, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Jon Ashburn <jon@lunarg.com>
+ * Courtney Goeltzenleuchter <courtney@lunarg.com>
+ * Ian Elliott <ian@lunarg.com>
+ */
+
+#include "vk_loader_platform.h"
+#include "loader.h"
+#include "vk_wsi_swapchain.h"
+
+void wsi_swapchain_add_instance_extensions(
+ struct loader_extension_list *ext_list);
+
+void wsi_swapchain_create_instance(
+ struct loader_instance *ptr_instance,
+ const VkInstanceCreateInfo *pCreateInfo);
+
+void *wsi_swapchain_GetInstanceProcAddr(
+ struct loader_instance *ptr_instance,
+ const char* pName);
+
+VkResult loader_GetPhysicalDeviceSurfaceSupportWSI(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueNodeIndex,
+ const VkSurfaceDescriptionWSI* pSurfaceDescription,
+ VkBool32* pSupported);