aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Ashburn <jon@lunarg.com>2015-05-21 18:13:33 -0600
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-06-17 19:47:02 -0600
commit0b85d05acedb722d9b8a219eb2a7c7ccd133d753 (patch)
tree8f85f4e0ec67064b9213b0716fd54c7278a0cbd1
parent18495c0e7338cc1b782974d6da47f2a1bb0da2a1 (diff)
downloadusermoji-0b85d05acedb722d9b8a219eb2a7c7ccd133d753.tar.xz
misc: Make wsi lunarg an extension rather than core entrypoints
-rw-r--r--demos/cube.c29
-rw-r--r--demos/tri.c30
-rw-r--r--icd/nulldrv/nulldrv.c6
-rw-r--r--include/vk_wsi_lunarg.h1
-rw-r--r--loader/CMakeLists.txt6
-rw-r--r--loader/gpa_helper.h12
-rw-r--r--loader/loader.c54
-rw-r--r--loader/loader.h6
-rw-r--r--loader/table_ops.h5
-rw-r--r--loader/trampoline.c47
-rw-r--r--loader/wsi_lunarg.c190
-rw-r--r--loader/wsi_lunarg.h46
12 files changed, 339 insertions, 93 deletions
diff --git a/demos/cube.c b/demos/cube.c
index 9830cba2..64641dcc 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -296,6 +296,10 @@ struct demo {
VkDisplayPropertiesWSI *display_props;
int num_displays;
+ PFN_vkCreateSwapChainWSI fpCreateSwapChainWSI;
+ PFN_vkDestroySwapChainWSI fpDestroySwapChainWSI;
+ PFN_vkGetSwapChainInfoWSI fpGetSwapChainInfoWSI;
+ PFN_vkQueuePresentWSI fpQueuePresentWSI;
VkSwapChainWSI swap_chain;
struct {
VkImage image;
@@ -563,7 +567,7 @@ static void demo_draw(struct demo *demo)
VK_NULL_HANDLE);
assert(!err);
- err = vkQueuePresentWSI(demo->queue, &present);
+ err = demo->fpQueuePresentWSI(demo->queue, &present);
assert(!err);
demo->current_buffer = (demo->current_buffer + 1) % DEMO_BUFFER_COUNT;
@@ -594,10 +598,10 @@ static void demo_prepare_buffers(struct demo *demo)
VkResult U_ASSERT_ONLY err;
uint32_t i;
- err = vkCreateSwapChainWSI(demo->device, &swap_chain, &demo->swap_chain);
+ err = demo->fpCreateSwapChainWSI(demo->device, &swap_chain, &demo->swap_chain);
assert(!err);
- err = vkGetSwapChainInfoWSI(demo->swap_chain,
+ err = demo->fpGetSwapChainInfoWSI(demo->swap_chain,
VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI,
&images_size, images);
assert(!err && images_size == sizeof(images));
@@ -1880,6 +1884,23 @@ static void demo_init_vk(struct demo *demo)
err = vkCreateDevice(demo->gpu, &device, &demo->device);
assert(!err);
+ demo->fpCreateSwapChainWSI = vkGetDeviceProcAddr(demo->device, "vkCreateSwapChainWSI");
+ if (demo->fpCreateSwapChainWSI == NULL)
+ ERR_EXIT("vkGetDeviceProcAddr failed to find vkCreateSwapChainWSI",
+ "vkGetDeviceProcAddr Failure");
+ demo->fpDestroySwapChainWSI = vkGetDeviceProcAddr(demo->device, "vkDestroySwapChainWSI");
+ if (demo->fpDestroySwapChainWSI == NULL)
+ ERR_EXIT("vkGetDeviceProcAddr failed to find vkDestroySwapChainWSI",
+ "vkGetDeviceProcAddr Failure");
+ demo->fpGetSwapChainInfoWSI = vkGetDeviceProcAddr(demo->device, "vkGetSwapChainInfoWSI");
+ if (demo->fpGetSwapChainInfoWSI == NULL)
+ ERR_EXIT("vkGetDeviceProcAddr failed to find vkGetSwapChainInfoWSI",
+ "vkGetDeviceProcAddr Failure");
+ demo->fpQueuePresentWSI = vkGetDeviceProcAddr(demo->device, "vkQueuePresentWSI");
+ if (demo->fpQueuePresentWSI == NULL)
+ ERR_EXIT("vkGetDeviceProcAddr failed to find vkQueuePresentWSI",
+ "vkGetDeviceProcAddr Failure");
+
err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES,
&data_size, NULL);
assert(!err);
@@ -2038,7 +2059,7 @@ static void demo_cleanup(struct demo *demo)
vkFreeMemory(demo->device, demo->textures[i].mem);
vkDestroyObject(demo->device, VK_OBJECT_TYPE_SAMPLER, demo->textures[i].sampler);
}
- vkDestroySwapChainWSI(demo->swap_chain);
+ demo->fpDestroySwapChainWSI(demo->swap_chain);
vkDestroyObject(demo->device, VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW, demo->depth.view);
vkDestroyObject(demo->device, VK_OBJECT_TYPE_IMAGE, demo->depth.image);
diff --git a/demos/tri.c b/demos/tri.c
index 27eec3ce..3fae85a5 100644
--- a/demos/tri.c
+++ b/demos/tri.c
@@ -120,6 +120,11 @@ struct demo {
VkDisplayPropertiesWSI *display_props;
int num_displays;
+ PFN_vkCreateSwapChainWSI fpCreateSwapChainWSI;
+ PFN_vkDestroySwapChainWSI fpDestroySwapChainWSI;
+ PFN_vkGetSwapChainInfoWSI fpGetSwapChainInfoWSI;
+ PFN_vkQueuePresentWSI fpQueuePresentWSI;
+
VkSwapChainWSI swap_chain;
struct {
VkImage image;
@@ -365,7 +370,7 @@ static void demo_draw(struct demo *demo)
err = vkQueueSubmit(demo->queue, 1, &demo->draw_cmd, VK_NULL_HANDLE);
assert(!err);
- err = vkQueuePresentWSI(demo->queue, &present);
+ err = demo->fpQueuePresentWSI(demo->queue, &present);
assert(!err);
demo->current_buffer = (demo->current_buffer + 1) % DEMO_BUFFER_COUNT;
@@ -396,10 +401,10 @@ static void demo_prepare_buffers(struct demo *demo)
VkResult U_ASSERT_ONLY err;
uint32_t i;
- err = vkCreateSwapChainWSI(demo->device, &swap_chain, &demo->swap_chain);
+ err = demo->fpCreateSwapChainWSI(demo->device, &swap_chain, &demo->swap_chain);
assert(!err);
- err = vkGetSwapChainInfoWSI(demo->swap_chain,
+ err = demo->fpGetSwapChainInfoWSI(demo->swap_chain,
VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI,
&images_size, images);
assert(!err && images_size == sizeof(images));
@@ -1429,6 +1434,23 @@ static void demo_init_vk(struct demo *demo)
"vkCreateInstance Failure");
}
+ demo->fpCreateSwapChainWSI = vkGetInstanceProcAddr(demo->inst, "vkCreateSwapChainWSI");
+ if (demo->fpCreateSwapChainWSI == NULL)
+ ERR_EXIT("vkGetInstanceProcAddr failed to find vkCreateSwapChainWSI",
+ "vkGetInstanceProcAddr Failure");
+ demo->fpDestroySwapChainWSI = vkGetInstanceProcAddr(demo->inst, "vkDestroySwapChainWSI");
+ if (demo->fpDestroySwapChainWSI == NULL)
+ ERR_EXIT("vkGetInstanceProcAddr failed to find vkDestroySwapChainWSI",
+ "vkGetInstanceProcAddr Failure");
+ demo->fpGetSwapChainInfoWSI = vkGetInstanceProcAddr(demo->inst, "vkGetSwapChainInfoWSI");
+ if (demo->fpGetSwapChainInfoWSI == NULL)
+ ERR_EXIT("vkGetInstanceProcAddr failed to find vkGetSwapChainInfoWSI",
+ "vkGetInstanceProcAddr Failure");
+ demo->fpQueuePresentWSI = vkGetInstanceProcAddr(demo->inst, "vkQueuePresentWSI");
+ if (demo->fpQueuePresentWSI == NULL)
+ ERR_EXIT("vkGetInstanceProcAddr failed to find vkQueuePresentWSI",
+ "vkGetInstanceProcAddr Failure");
+
gpu_count = 1;
err = vkEnumeratePhysicalDevices(demo->inst, &gpu_count, &demo->gpu);
assert(!err && gpu_count == 1);
@@ -1606,7 +1628,7 @@ static void demo_cleanup(struct demo *demo)
for (i = 0; i < DEMO_BUFFER_COUNT; i++) {
vkDestroyObject(demo->device, VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW, demo->buffers[i].view);
}
- vkDestroySwapChainWSI(demo->swap_chain);
+ demo->fpDestroySwapChainWSI(demo->swap_chain);
vkDestroyDevice(demo->device);
vkDestroyInstance(demo->inst);
diff --git a/icd/nulldrv/nulldrv.c b/icd/nulldrv/nulldrv.c
index 5e4cdd8c..80ceb19e 100644
--- a/icd/nulldrv/nulldrv.c
+++ b/icd/nulldrv/nulldrv.c
@@ -40,7 +40,7 @@
// The null driver supports all WSI extenstions ... for now ...
static const char * const nulldrv_gpu_exts[NULLDRV_EXT_COUNT] = {
- [NULLDRV_EXT_WSI_LUNARG] = "VK_WSI_LunarG",
+ [NULLDRV_EXT_WSI_LUNARG] = VK_WSI_LUNARG_EXTENSION_NAME,
};
static struct nulldrv_base *nulldrv_base(VkObject base)
@@ -1569,8 +1569,8 @@ ICD_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(
else {
ext_props = (VkExtensionProperties *) pData;
ext_props->version = VK_WSI_LUNARG_REVISION;
- strncpy(ext_props->extName, "VK_WSI_LunarG",
- strlen("VK_WSI_LunarG")+1);
+ strncpy(ext_props->extName, VK_WSI_LUNARG_EXTENSION_NAME,
+ strlen(VK_WSI_LUNARG_EXTENSION_NAME)+1);
return VK_SUCCESS;
}
break;
diff --git a/include/vk_wsi_lunarg.h b/include/vk_wsi_lunarg.h
index 84de8d2c..3507cfe8 100644
--- a/include/vk_wsi_lunarg.h
+++ b/include/vk_wsi_lunarg.h
@@ -31,6 +31,7 @@
#define VK_WSI_LUNARG_REVISION 3
#define VK_WSI_LUNARG_EXTENSION_NUMBER 1
+#define VK_WSI_LUNARG_EXTENSION_NAME "VK_WSI_LunarG"
#ifdef __cplusplus
extern "C"
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt
index 6365e8d1..b334af31 100644
--- a/loader/CMakeLists.txt
+++ b/loader/CMakeLists.txt
@@ -10,16 +10,16 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
if (WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVK_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS -DXCB_NVIDIA")
- add_library(vulkan SHARED loader.c loader.h loader_platform.h dirent_on_windows.c trampoline.c table_ops.h gpa_helper.h vulkan.def)
+ add_library(vulkan SHARED loader.c loader.h loader_platform.h dirent_on_windows.c trampoline.c wsi_lunarg.c wsi_lunarg.h table_ops.h gpa_helper.h vulkan.def)
set_target_properties(vulkan PROPERTIES LINK_FLAGS "/DEF:${PROJECT_SOURCE_DIR}/loader/vulkan.def")
- add_library(VKstatic STATIC loader.c loader.h dirent_on_windows.c trampoline.c table_ops.h gpa_helper.h)
+ add_library(VKstatic STATIC loader.c loader.h dirent_on_windows.c trampoline.c wsi_lunarg.c wsi_lunarg.h table_ops.h gpa_helper.h)
set_target_properties(VKstatic PROPERTIES OUTPUT_NAME VKstatic)
target_link_libraries(vulkan)
endif()
if (NOT WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVK_PROTOTYPES -Wpointer-arith")
- add_library(vulkan SHARED loader.c trampoline.c loader.h loader_platform.h table_ops.h gpa_helper.h)
+ add_library(vulkan SHARED loader.c trampoline.c wsi_lunarg.c wsi_lunarg.h loader.h loader_platform.h table_ops.h gpa_helper.h)
set_target_properties(vulkan PROPERTIES SOVERSION 0)
target_link_libraries(vulkan -ldl -lpthread)
endif()
diff --git a/loader/gpa_helper.h b/loader/gpa_helper.h
index 3e491954..6e831bd4 100644
--- a/loader/gpa_helper.h
+++ b/loader/gpa_helper.h
@@ -276,16 +276,6 @@ static inline void* globalGetProcAddr(const char *name)
return (void*) vkCmdDbgMarkerBegin;
if (!strcmp(name, "CmdDbgMarkerEnd"))
return (void*) vkCmdDbgMarkerEnd;
- if (!strcmp(name, "GetDisplayInfoWSI"))
- return (void*) vkGetDisplayInfoWSI;
- if (!strcmp(name, "CreateSwapChainWSI"))
- return (void*) vkCreateSwapChainWSI;
- if (!strcmp(name, "DestroySwapChainWSI"))
- return (void*) vkDestroySwapChainWSI;
- if (!strcmp(name, "GetSwapChainInfoWSI"))
- return (void*) vkGetSwapChainInfoWSI;
- if (!strcmp(name, "QueuePresentWSI"))
- return (void*) vkQueuePresentWSI;
return NULL;
}
@@ -328,8 +318,6 @@ static inline void *loader_non_passthrough_gpa(const char *name)
return (void*) vkDbgUnregisterMsgCallback;
if (!strcmp(name, "DbgSetGlobalOption"))
return (void*) vkDbgSetGlobalOption;
- if (!strcmp(name, "CreateSwapChainWSI"))
- return (void*) vkCreateSwapChainWSI;
return NULL;
}
diff --git a/loader/loader.c b/loader/loader.c
index 0d114a48..1c53f176 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -42,6 +42,7 @@
#endif // WIN32
#include "loader_platform.h"
#include "loader.h"
+#include "wsi_lunarg.h"
#include "gpa_helper.h"
#include "table_ops.h"
#include "vkIcd.h"
@@ -741,6 +742,15 @@ static void* VKAPI loader_gpa_device_internal(VkPhysicalDevice physDev, const ch
return NULL;
return disp_table->GetDeviceProcAddr(physDev, pName);
}
+#if 0
+ return icd->GetDeviceProcAddr(physDev, pName);
+ uint32_t gpu_index;
+ struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) physDev, &gpu_index);
+ if (icd->GetDeviceProcAddr == NULL)
+ //if (disp_table->GetDeviceProcAddr == NULL)
+ return NULL;
+ return icd->GetDeviceProcAddr(physDev, pName);
+#endif
}
static void* VKAPI loader_gpa_instance_internal(VkInstance inst, const char * pName)
@@ -1397,11 +1407,27 @@ VkResult loader_CreateDevice(
LOADER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const char * pName)
{
- if (instance != VK_NULL_HANDLE) {
+ if (instance == VK_NULL_HANDLE)
+ return NULL;
+ void *addr;
+ /* get entrypoint addresses that are global (in the loader)*/
+ addr = globalGetProcAddr(pName);
+ if (addr)
+ return addr;
- /* return entrypoint addresses that are global (in the loader)*/
- return globalGetProcAddr(pName);
- }
+ /* return any extension global entrypoints */
+ addr = wsi_lunarg_GetInstanceProcAddr(instance, pName);
+ if (addr)
+ return addr;
+
+ /* return the instance dispatch table entrypoint for extensions */
+ const VkLayerInstanceDispatchTable *disp_table = * (VkLayerInstanceDispatchTable **) instance;
+ if (disp_table == NULL)
+ return NULL;
+
+ addr = loader_lookup_instance_dispatch_table(disp_table, pName);
+ if (addr)
+ return addr;
return NULL;
}
@@ -1421,6 +1447,11 @@ LOADER_EXPORT void * VKAPI vkGetDeviceProcAddr(VkDevice device, const char * pNa
return addr;
}
+ /* return any extension device entrypoints the loader knows about */
+ 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)
@@ -1709,18 +1740,3 @@ VkResult loader_DbgSetGlobalOption(VkInstance instance, VK_DBG_GLOBAL_OPTION dbg
return res;
}
-VkResult loader_GetDisplayInfoWSI(
- VkDisplayWSI display,
- VkDisplayInfoTypeWSI infoType,
- size_t* pDataSize,
- void* pData)
-{
- uint32_t gpu_index;
- struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) display, &gpu_index);
- VkResult res = VK_ERROR_INITIALIZATION_FAILED;
-
- if (icd->GetDisplayInfoWSI)
- res = icd->GetDisplayInfoWSI(display, infoType, pDataSize, pData);
-
- return res;
-}
diff --git a/loader/loader.h b/loader/loader.h
index 972b4f1b..e7a4618d 100644
--- a/loader/loader.h
+++ b/loader/loader.h
@@ -205,11 +205,7 @@ VkResult loader_DbgSetGlobalOption(
size_t dataSize,
const void* pData);
-VkResult loader_GetDisplayInfoWSI(
- VkDisplayWSI display,
- VkDisplayInfoTypeWSI infoType,
- size_t* pDataSize,
- void* pData);
+
/* function definitions */
bool loader_is_extension_scanned(const char *name);
diff --git a/loader/table_ops.h b/loader/table_ops.h
index 9a5a0c0e..adcc42a1 100644
--- a/loader/table_ops.h
+++ b/loader/table_ops.h
@@ -142,6 +142,7 @@ static inline void loader_init_device_dispatch_table(VkLayerDispatchTable *table
table->DbgSetDeviceOption = (PFN_vkDbgSetDeviceOption) gpa(dev, "vkDbgSetDeviceOption");
table->CmdDbgMarkerBegin = (PFN_vkCmdDbgMarkerBegin) gpa(dev, "vkCmdDbgMarkerBegin");
table->CmdDbgMarkerEnd = (PFN_vkCmdDbgMarkerEnd) gpa(dev, "vkCmdDbgMarkerEnd");
+//TODO move into it's own table
table->CreateSwapChainWSI = (PFN_vkCreateSwapChainWSI) gpa(dev, "vkCreateSwapChainWSI");
table->DestroySwapChainWSI = (PFN_vkDestroySwapChainWSI) gpa(dev, "vkDestroySwapChainWSI");
table->GetSwapChainInfoWSI = (PFN_vkGetSwapChainInfoWSI) gpa(dev, "vkGetSwapChainInfoWSI");
@@ -376,6 +377,7 @@ static inline void *loader_lookup_device_dispatch_table(
return (void *) table->CmdDbgMarkerBegin;
if (!strcmp(name, "CmdDbgMarkerEnd"))
return (void *) table->CmdDbgMarkerEnd;
+//TODO put in it's own table
if (!strcmp(name, "CreateSwapChainWSI"))
return (void *) table->CreateSwapChainWSI;
if (!strcmp(name, "DestroySwapChainWSI"))
@@ -405,6 +407,7 @@ static inline void loader_init_instance_dispatch_table(VkLayerInstanceDispatchTa
table->DbgRegisterMsgCallback = (PFN_vkDbgRegisterMsgCallback) gpa(inst, "vkDbgRegisterMsgCallback");
table->DbgUnregisterMsgCallback = (PFN_vkDbgUnregisterMsgCallback) gpa(inst, "vkDbgUnregisterMsgCallback");
table->DbgSetGlobalOption = (PFN_vkDbgSetGlobalOption) gpa(inst, "vkDbgSetGlobalOption");
+//TODO put in it's own table
table->GetDisplayInfoWSI = (PFN_vkGetDisplayInfoWSI) gpa(inst, "vkGetDisplayInfoWSI");
}
@@ -442,8 +445,8 @@ static inline void *loader_lookup_instance_dispatch_table(
return (void *) table->DbgUnregisterMsgCallback;
if (!strcmp(name, "DbgSetGlobalOption"))
return (void *) table->DbgSetGlobalOption;
+ //TODO eventually extensions are in their own table
if (!strcmp(name, "GetDisplayInfoWSI"))
return (void *) table->GetDisplayInfoWSI;
-
return NULL;
}
diff --git a/loader/trampoline.c b/loader/trampoline.c
index 20fbe35c..c5186e33 100644
--- a/loader/trampoline.c
+++ b/loader/trampoline.c
@@ -26,6 +26,7 @@
#include "loader_platform.h"
#include "loader.h"
+#include "wsi_lunarg.h"
#if defined(WIN32)
// On Windows need to disable global optimization for function entrypoints or
@@ -76,6 +77,10 @@ LOADER_EXPORT VkResult VKAPI vkCreateInstance(
memcpy(ptr_instance->disp, &instance_disp, sizeof(instance_disp));
ptr_instance->next = loader.instances;
loader.instances = ptr_instance;
+
+ wsi_lunarg_register_extensions(pCreateInfo);
+
+ /* enable any layers on instance chain */
loader_activate_instance_layers(ptr_instance);
*pInstance = (VkInstance) ptr_instance;
@@ -1217,48 +1222,6 @@ LOADER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer)
disp->CmdDbgMarkerEnd(cmdBuffer);
}
-LOADER_EXPORT VkResult VKAPI vkGetDisplayInfoWSI(VkDisplayWSI display, VkDisplayInfoTypeWSI infoType, size_t* pDataSize, void* pData)
-{
- const VkLayerInstanceDispatchTable *disp;
-
- disp = loader_get_instance_dispatch(display);
-
- return disp->GetDisplayInfoWSI(display, infoType, pDataSize, pData);
-}
-
-LOADER_EXPORT VkResult VKAPI vkCreateSwapChainWSI(VkDevice device, const VkSwapChainCreateInfoWSI* pCreateInfo, VkSwapChainWSI* pSwapChain)
-{
- const VkLayerDispatchTable *disp;
- VkResult res;
-
- disp = loader_get_dispatch(device);
-
- res = disp->CreateSwapChainWSI(device, pCreateInfo, pSwapChain);
- if (res == VK_SUCCESS) {
- loader_init_dispatch(*pSwapChain, disp);
- }
-
- return res;
-}
-
-LOADER_EXPORT VkResult VKAPI vkDestroySwapChainWSI(VkSwapChainWSI swapChain)
-{
- const VkLayerDispatchTable *disp;
-
- disp = loader_get_dispatch(swapChain);
-
- return disp->DestroySwapChainWSI(swapChain);
-}
-
-LOADER_EXPORT VkResult VKAPI vkGetSwapChainInfoWSI(VkSwapChainWSI swapChain, VkSwapChainInfoTypeWSI infoType, size_t* pDataSize, void* pData)
-{
- const VkLayerDispatchTable *disp;
-
- disp = loader_get_dispatch(swapChain);
-
- return disp->GetSwapChainInfoWSI(swapChain, infoType, pDataSize, pData);
-}
-
LOADER_EXPORT VkResult VKAPI vkQueuePresentWSI(VkQueue queue, const VkPresentInfoWSI* pPresentInfo)
{
const VkLayerDispatchTable *disp;
diff --git a/loader/wsi_lunarg.c b/loader/wsi_lunarg.c
new file mode 100644
index 00000000..5d8a51b8
--- /dev/null
+++ b/loader/wsi_lunarg.c
@@ -0,0 +1,190 @@
+/*
+ * 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>
+ */
+
+#include <string.h>
+#include "loader_platform.h"
+#include "loader.h"
+#include "wsi_lunarg.h"
+
+/************ Trampoline entrypoints *******************/
+/* since one entrypoint is instance level will make available all entrypoints */
+VkResult VKAPI wsi_lunarg_GetDisplayInfoWSI(
+ VkDisplayWSI display,
+ VkDisplayInfoTypeWSI infoType,
+ size_t* pDataSize,
+ void* pData)
+{
+ const VkLayerInstanceDispatchTable *disp;
+
+ disp = loader_get_instance_dispatch(display);
+
+ return disp->GetDisplayInfoWSI(display, infoType, pDataSize, pData);
+}
+
+VkResult wsi_lunarg_CreateSwapChainWSI(
+ VkDevice device,
+ const VkSwapChainCreateInfoWSI* pCreateInfo,
+ VkSwapChainWSI* pSwapChain)
+{
+ const VkLayerDispatchTable *disp;
+ VkResult res;
+
+ disp = loader_get_dispatch(device);
+
+ res = disp->CreateSwapChainWSI(device, pCreateInfo, pSwapChain);
+ if (res == VK_SUCCESS) {
+ loader_init_dispatch(*pSwapChain, disp);
+ }
+
+ return res;
+}
+
+VkResult wsi_lunarg_DestroySwapChainWSI(
+ VkSwapChainWSI swapChain)
+{
+ const VkLayerDispatchTable *disp;
+
+ disp = loader_get_dispatch(swapChain);
+
+ return disp->DestroySwapChainWSI(swapChain);
+}
+
+static VkResult wsi_lunarg_GetSwapChainInfoWSI(
+ VkSwapChainWSI swapChain,
+ VkSwapChainInfoTypeWSI infoType,
+ size_t* pDataSize,
+ void* pData)
+{
+ const VkLayerDispatchTable *disp;
+
+ disp = loader_get_dispatch(swapChain);
+
+ return disp->GetSwapChainInfoWSI(swapChain, infoType, pDataSize, pData);
+}
+
+static VkResult wsi_lunarg_QueuePresentWSI(
+ VkQueue queue,
+ const VkPresentInfoWSI* pPresentInfo)
+{
+ const VkLayerDispatchTable *disp;
+
+ disp = loader_get_dispatch(queue);
+
+ return disp->QueuePresentWSI(queue, pPresentInfo);
+}
+
+/************ loader instance chain termination entrypoints ***************/
+VkResult loader_GetDisplayInfoWSI(
+ VkDisplayWSI display,
+ VkDisplayInfoTypeWSI infoType,
+ size_t* pDataSize,
+ void* pData)
+{
+ uint32_t gpu_index;
+ struct loader_icd *icd = loader_get_icd((const VkBaseLayerObject *) display, &gpu_index);
+ VkResult res = VK_ERROR_INITIALIZATION_FAILED;
+
+ if (icd->GetDisplayInfoWSI)
+ res = icd->GetDisplayInfoWSI(display, infoType, pDataSize, pData);
+
+ return res;
+}
+
+
+/************ extension enablement ***************/
+static bool wsi_enabled = false;
+
+struct ext_props {
+ uint32_t version;
+ const char * const name;
+};
+
+#define WSI_LUNARG_EXT_ARRAY_SIZE 1
+static const struct ext_props wsi_lunarg_exts[WSI_LUNARG_EXT_ARRAY_SIZE] = {
+ {VK_WSI_LUNARG_REVISION, VK_WSI_LUNARG_EXTENSION_NAME},
+};
+
+void wsi_lunarg_register_extensions(
+ const VkInstanceCreateInfo* pCreateInfo)
+{
+ uint32_t i, ext_idx;
+
+ for (i = 0; i < pCreateInfo->extensionCount; i++) {
+ for (ext_idx = 0; ext_idx < WSI_LUNARG_EXT_ARRAY_SIZE; ext_idx++) {
+ /* TODO: Should we include version number as well as extension name? */
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], wsi_lunarg_exts[ext_idx].name) == 0) {
+ /* Found a matching extension name, mark it enabled */
+ wsi_enabled = true;
+ }
+
+ }
+ }
+
+}
+
+void *wsi_lunarg_GetInstanceProcAddr(
+ VkInstance instance,
+ const char* pName)
+{
+ if (instance == VK_NULL_HANDLE)
+ return NULL;
+
+ if (wsi_enabled == false)
+ return NULL;
+
+ /* since two of these entrypoints must be loader handled will report all */
+ if (!strcmp(pName, "vkGetDisplayInfoWSI"))
+ return (void*) wsi_lunarg_GetDisplayInfoWSI;
+ if (!strcmp(pName, "vkCreateSwapChainWSI"))
+ return (void*) wsi_lunarg_CreateSwapChainWSI;
+ if (!strcmp(pName, "vkDestroySwapChainWSI"))
+ return (void*) wsi_lunarg_DestroySwapChainWSI;
+ if (!strcmp(pName, "vkGetSwapChainInfoWSI"))
+ return (void*) wsi_lunarg_GetSwapChainInfoWSI;
+ if (!strcmp(pName, "vkQueuePresentWSI"))
+ return (void*) wsi_lunarg_QueuePresentWSI;
+
+ return NULL;
+}
+
+void *wsi_lunarg_GetDeviceProcAddr(
+ VkDevice device,
+ const char* name)
+{
+ if (device == VK_NULL_HANDLE)
+ return NULL;
+
+ if (wsi_enabled == false)
+ return NULL;
+
+ /* only handle device entrypoints that are loader special cases */
+ if (!strcmp(name, "vkCreateSwapChainWSI"))
+ return (void*) wsi_lunarg_CreateSwapChainWSI;
+
+ return NULL;
+}
diff --git a/loader/wsi_lunarg.h b/loader/wsi_lunarg.h
new file mode 100644
index 00000000..fd1b6da0
--- /dev/null
+++ b/loader/wsi_lunarg.h
@@ -0,0 +1,46 @@
+/*
+ * 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>
+ */
+
+#include "vk_wsi_lunarg.h"
+
+VkResult loader_GetDisplayInfoWSI(
+ VkDisplayWSI display,
+ VkDisplayInfoTypeWSI infoType,
+ size_t* pDataSize,
+ void* pData);
+
+void wsi_lunarg_register_extensions(
+ const VkInstanceCreateInfo* pCreateInfo);
+
+void *wsi_lunarg_GetInstanceProcAddr(
+ VkInstance instance,
+ const char* pName);
+
+void *wsi_lunarg_GetDeviceProcAddr(
+ VkDevice device,
+ const char* pName);