wsi: Make WSI cases more consistent, fail if not set correctly
Filled in build details for Mir, Wayland, etc.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 59bfd6b..4dc19b1 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,11 +11,16 @@
# vulkan-<major>.dll (and other files).
set(MAJOR "0")
-if(WIN32)
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
+ add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ add_definitions(-DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XLIB_KHR)
+# TODO: Add support to SDK for Wayland and Mir
+# add_definitions(-DVK_USE_PLATFORM_MIR_KHR -DVK_USEPLATFORM_WAYLAND_KHR)
else()
- add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
- add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
+ message(FATAL_ERROR "Unsupported Platform!")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
diff --git a/include/vulkan/vk_layer.h b/include/vulkan/vk_layer.h
index 47165f7..a2b25d2 100644
--- a/include/vulkan/vk_layer.h
+++ b/include/vulkan/vk_layer.h
@@ -196,6 +196,9 @@
PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR;
PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR GetPhysicalDeviceXlibPresentationSupportKHR;
#endif
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ PFN_vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR;
+#endif
} VkLayerInstanceDispatchTable;
// LL node for tree of dbg callback functions
diff --git a/layers/apidump.h b/layers/apidump.h
index 274e42c..fb13170 100644
--- a/layers/apidump.h
+++ b/layers/apidump.h
@@ -96,10 +96,26 @@
#if VK_USE_PLATFORM_WIN32_KHR
pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) gpa(instance, "vkCreateWin32SurfaceKHR");
pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
-#elif VK_USE_PLATFORM_XCB_KHR
+#endif // VK_USE_PLATFORM_WIN32_KHR
+#ifdef VK_USE_PLATFORM_XCB_KHR
pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) gpa(instance, "vkCreateXcbSurfaceKHR");
pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
-#endif
+#endif // VK_USE_PLATFORM_XCB_KHR
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+ pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR) gpa(instance, "vkCreateXlibSurfaceKHR");
+ pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_XLIB_KHR
+#ifdef VK_USE_PLATFORM_MIR_KHR
+ pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) gpa(instance, "vkCreateMirSurfaceKHR");
+ pDisp->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_MIR_KHR
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+ pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR) gpa(instance, "vkCreateWaylandSurfaceKHR");
+ pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_WAYLAND_KHR
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR) gpa(instance, "vkCreateAndroidSurfaceKHR");
+#endif // VK_USE_PLATFORM_ANDROID_KHR
instanceExtMap[pDisp].wsi_enabled = false;
for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
diff --git a/layers/object_track.h b/layers/object_track.h
index 6debcb9..e28dc80 100644
--- a/layers/object_track.h
+++ b/layers/object_track.h
@@ -219,10 +219,26 @@
#if VK_USE_PLATFORM_WIN32_KHR
pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) gpa(instance, "vkCreateWin32SurfaceKHR");
pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
-#elif VK_USE_PLATFORM_XCB_KHR
+#endif // VK_USE_PLATFORM_WIN32_KHR
+#ifdef VK_USE_PLATFORM_XCB_KHR
pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) gpa(instance, "vkCreateXcbSurfaceKHR");
pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
-#endif
+#endif // VK_USE_PLATFORM_XCB_KHR
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+ pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR) gpa(instance, "vkCreateXlibSurfaceKHR");
+ pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_XLIB_KHR
+#ifdef VK_USE_PLATFORM_MIR_KHR
+ pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) gpa(instance, "vkCreateMirSurfaceKHR");
+ pDisp->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_MIR_KHR
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+ pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR) gpa(instance, "vkCreateWaylandSurfaceKHR");
+ pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
+#endif // VK_USE_PLATFORM_WAYLAND_KHR
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR) gpa(instance, "vkCreateAndroidSurfaceKHR");
+#endif // VK_USE_PLATFORM_ANDROID_KHR
instanceExtMap[pDisp].wsi_enabled = false;
for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
diff --git a/loader/loader.c b/loader/loader.c
index bc020ee..73a3939 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -136,6 +136,9 @@
.CreateXlibSurfaceKHR = loader_CreateXlibSurfaceKHR,
.GetPhysicalDeviceXlibPresentationSupportKHR = loader_GetPhysicalDeviceXlibPresentationSupportKHR,
#endif
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ .CreateAndroidSurfaceKHR = loader_CreateAndroidSurfaceKHR,
+#endif
};
LOADER_PLATFORM_THREAD_ONCE_DECLARATION(once_init);
diff --git a/loader/loader.h b/loader/loader.h
index c6fc08d..1c1dd2d 100644
--- a/loader/loader.h
+++ b/loader/loader.h
@@ -205,7 +205,6 @@
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR GetPhysicalDeviceXcbPresentationSupportKHR;
- PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR GetPhysicalDeviceXlibPresentationSupportKHR;
@@ -246,14 +245,24 @@
VkAllocationCallbacks alloc_callbacks;
bool wsi_surface_enabled;
-#ifdef _WIN32
+#ifdef VK_USE_PLATFORM_WIN32_KHR
bool wsi_win32_surface_enabled;
-#else // _WIN32
+#endif
+#ifdef VK_USE_PLATFORM_MIR_KHR
bool wsi_mir_surface_enabled;
+#endif
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
bool wsi_wayland_surface_enabled;
+#endif
+#ifdef VK_USE_PLATFORM_XCB_KHR
bool wsi_xcb_surface_enabled;
+#endif
+#ifdef VK_USE_PLATFORM_XLIB_KHR
bool wsi_xlib_surface_enabled;
-#endif // _WIN32
+#endif
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ bool wsi_android_surface_enabled;
+#endif
};
/* per enumerated PhysicalDevice structure */
diff --git a/loader/wsi.c b/loader/wsi.c
index f5dc823..c22459b 100644
--- a/loader/wsi.c
+++ b/loader/wsi.c
@@ -38,14 +38,13 @@
.specVersion = VK_KHR_SURFACE_REVISION,
};
-#ifdef _WIN32
#ifdef VK_USE_PLATFORM_WIN32_KHR
static const VkExtensionProperties wsi_win32_surface_extension_info = {
.extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
.specVersion = VK_KHR_WIN32_SURFACE_REVISION,
};
-#endif/ VK_USE_PLATFORM_WIN32_KHR
-#else // _WIN32
+#endif // VK_USE_PLATFORM_WIN32_KHR
+
#ifdef VK_USE_PLATFORM_MIR_KHR
static const VkExtensionProperties wsi_mir_surface_extension_info = {
.extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
@@ -73,18 +72,22 @@
.specVersion = VK_KHR_XLIB_SURFACE_REVISION,
};
#endif // VK_USE_PLATFORM_XLIB_KHR
-#endif // _WIN32
+
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+static const VkExtensionProperties wsi_android_surface_extension_info = {
+ .extensionName = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
+ .specVersion = VK_KHR_ANDROID_SURFACE_REVISION,
+};
+#endif // VK_USE_PLATFORM_ANDROID_KHR
void wsi_add_instance_extensions(
const struct loader_instance *inst,
struct loader_extension_list *ext_list)
{
loader_add_to_ext_list(inst, ext_list, 1, &wsi_surface_extension_info);
-#ifdef _WIN32
#ifdef VK_USE_PLATFORM_WIN32_KHR
loader_add_to_ext_list(inst, ext_list, 1, &wsi_win32_surface_extension_info);
-#endif/ VK_USE_PLATFORM_WIN32_KHR
-#else // _WIN32
+#endif // VK_USE_PLATFORM_WIN32_KHR
#ifdef VK_USE_PLATFORM_MIR_KHR
loader_add_to_ext_list(inst, ext_list, 1, &wsi_mir_surface_extension_info);
#endif // VK_USE_PLATFORM_MIR_KHR
@@ -97,7 +100,9 @@
#ifdef VK_USE_PLATFORM_XLIB_KHR
loader_add_to_ext_list(inst, ext_list, 1, &wsi_xlib_surface_extension_info);
#endif // VK_USE_PLATFORM_XLIB_KHR
-#endif // _WIN32
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ loader_add_to_ext_list(inst, ext_list, 1, &wsi_android_surface_extension_info);
+#endif // VK_USE_PLATFORM_ANDROID_KHR
}
void wsi_create_instance(
@@ -105,28 +110,37 @@
const VkInstanceCreateInfo *pCreateInfo)
{
ptr_instance->wsi_surface_enabled = false;
-#ifdef _WIN32
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
ptr_instance->wsi_win32_surface_enabled = true;
-#else // _WIN32
+#endif // VK_USE_PLATFORM_WIN32_KHR
+#ifdef VK_USE_PLATFORM_MIR_KHR
ptr_instance->wsi_mir_surface_enabled = false;
+#endif // VK_USE_PLATFORM_MIR_KHR
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
ptr_instance->wsi_wayland_surface_enabled = false;
+#endif // VK_USE_PLATFORM_WAYLAND_KHR
+#ifdef VK_USE_PLATFORM_XCB_KHR
ptr_instance->wsi_xcb_surface_enabled = false;
+#endif // VK_USE_PLATFORM_XCB_KHR
+#ifdef VK_USE_PLATFORM_XLIB_KHR
ptr_instance->wsi_xlib_surface_enabled = false;
-#endif // _WIN32
+#endif // VK_USE_PLATFORM_XLIB_KHR
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ ptr_instance->wsi_android_surface_enabled = false;
+#endif // VK_USE_PLATFORM_ANDROID_KHR
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
ptr_instance->wsi_surface_enabled = true;
continue;
}
-#ifdef _WIN32
#ifdef VK_USE_PLATFORM_WIN32_KHR
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
ptr_instance->wsi_win32_surface_enabled = true;
continue;
}
-#endif/ VK_USE_PLATFORM_WIN32_KHR
-#else // _WIN32
+#endif // VK_USE_PLATFORM_WIN32_KHR
#ifdef VK_USE_PLATFORM_MIR_KHR
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
ptr_instance->wsi_mir_surface_enabled = true;
@@ -151,7 +165,12 @@
continue;
}
#endif // VK_USE_PLATFORM_XLIB_KHR
-#endif // _WIN32
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
+ ptr_instance->wsi_android_surface_enabled = true;
+ continue;
+ }
+#endif // VK_USE_PLATFORM_ANDROID_KHR
}
}
@@ -454,8 +473,6 @@
}
-#ifdef _WIN32
-
#ifdef VK_USE_PLATFORM_WIN32_KHR
/*
@@ -544,9 +561,7 @@
return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
queueFamilyIndex);
}
-#endif/ VK_USE_PLATFORM_WIN32_KHR
-
-#else // _WIN32 (i.e. Linux)
+#endif // VK_USE_PLATFORM_WIN32_KHR
#ifdef VK_USE_PLATFORM_MIR_KHR
@@ -932,8 +947,60 @@
}
#endif // VK_USE_PLATFORM_XLIB_KHR
-#endif // _WIN32
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+/*
+ * Functions for the VK_KHR_android_surface extension:
+ */
+
+/*
+ * This is the trampoline entrypoint
+ * for CreateAndroidSurfaceKHR
+ */
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
+ VkInstance instance,
+ ANativeWindow* window,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface)
+{
+ const VkLayerInstanceDispatchTable *disp;
+ disp = loader_get_instance_dispatch(instance);
+ VkResult res;
+
+ res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
+ return res;
+}
+
+/*
+ * This is the instance chain terminator function
+ * for CreateAndroidSurfaceKHR
+ */
+VKAPI_ATTR VkResult VKAPI_CALL loader_CreateAndroidSurfaceKHR(
+ VkInstance instance,
+ Window window,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface)
+{
+ struct loader_instance *ptr_instance = loader_get_instance(instance);
+ VkIcdSurfaceAndroid *pIcdSurface = NULL;
+
+ pIcdSurface = loader_heap_alloc(ptr_instance,
+ sizeof(VkIcdSurfaceAndroid),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ if (pIcdSurface == NULL) {
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ }
+
+ pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
+ pIcdSurface->dpy = dpy;
+ pIcdSurface->window = window;
+
+ *pSurface = (VkSurfaceKHR) pIcdSurface;
+
+ return VK_SUCCESS;
+}
+
+#endif // VK_USE_PLATFORM_ANDROID_KHR
bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
const char* name, void **addr)
@@ -993,7 +1060,6 @@
return true;
}
-#ifdef _WIN32
#ifdef VK_USE_PLATFORM_WIN32_KHR
/*
* Functions for the VK_KHR_win32_surface extension:
@@ -1007,7 +1073,6 @@
return true;
}
#endif // VK_USE_PLATFORM_WIN32_KHR
-#else // _WIN32 (i.e. Linux)
#ifdef VK_USE_PLATFORM_MIR_KHR
/*
* Functions for the VK_KHR_mir_surface extension:
@@ -1058,7 +1123,15 @@
return true;
}
#endif // VK_USE_PLATFORM_XLIB_KHR
-#endif // _WIN32
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+ /*
+ * Functions for the VK_KHR_android_surface extension:
+ */
+ if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
+ *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkCreateAndroidSurfaceKHR : NULL;
+ return true;
+ }
+#endif // VK_USE_PLATFORM_ANDROID_KHR
return false;
}
diff --git a/vk-layer-generate.py b/vk-layer-generate.py
index 5218ec5..466ba4e 100755
--- a/vk-layer-generate.py
+++ b/vk-layer-generate.py
@@ -40,11 +40,61 @@
from collections import defaultdict
def proto_is_global(proto):
- if proto.params[0].ty == "VkInstance" or proto.params[0].ty == "VkPhysicalDevice" or proto.name == "CreateInstance" or proto.name == "EnumerateInstanceLayerProperties" or proto.name == "EnumerateInstanceExtensionProperties" or proto.name == "EnumerateDeviceLayerProperties" or proto.name == "EnumerateDeviceExtensionProperties" or proto.name == "CreateXcbSurfaceKHR" or proto.name == "vkGetPhysicalDeviceXcbPresentationSupportKHR" or proto.name == "CreateWin32SurfaceKHR" or proto.name == "vkGetPhysicalDeviceWin32PresentationSupportKHR":
+ global_function_names = [
+ "CreateInstance",
+ "EnumerateInstanceLayerProperties",
+ "EnumerateInstanceExtensionProperties",
+ "EnumerateDeviceLayerProperties",
+ "EnumerateDeviceExtensionProperties",
+ "CreateXcbSurfaceKHR",
+ "vkGetPhysicalDeviceXcbPresentationSupportKHR",
+ "CreateXlibSurfaceKHR",
+ "vkGetPhysicalDeviceXlibPresentationSupportKHR",
+ "CreateWaylandSurfaceKHR",
+ "vkGetPhysicalDeviceWaylandPresentationSupportKHR",
+ "CreateMirSurfaceKHR",
+ "vkGetPhysicalDeviceMirPresentationSupportKHR",
+ "CreateAndroidSurfaceKHR",
+ "CreateWin32SurfaceKHR",
+ "vkGetPhysicalDeviceWin32PresentationSupportKHR"
+ ]
+ if proto.params[0].ty == "VkInstance" or proto.params[0].ty == "VkPhysicalDevice" or proto.name in global_function_names:
return True
else:
return False
+def wsi_name(ext_name):
+ wsi_prefix = ""
+ if 'Xcb' in ext_name:
+ wsi_prefix = 'XCB'
+ elif 'Xlib' in ext_name:
+ wsi_prefix = 'XLIB'
+ elif 'Win32' in ext_name:
+ wsi_prefix = 'WIN32'
+ elif 'Mir' in ext_name:
+ wsi_prefix = 'MIR'
+ elif 'Wayland' in ext_name:
+ wsi_prefix = 'WAYLAND'
+ elif 'Android' in ext_name:
+ wsi_prefix = 'ANDROID'
+ else:
+ wsi_prefix = ''
+ return wsi_prefix
+
+def wsi_ifdef(ext_name):
+ wsi_prefix = wsi_name(ext_name)
+ if not wsi_prefix:
+ return ''
+ else:
+ return "#ifdef VK_USE_PLATFORM_%s_KHR" % wsi_prefix
+
+def wsi_endif(ext_name):
+ wsi_prefix = wsi_name(ext_name)
+ if not wsi_prefix:
+ return ''
+ else:
+ return "#endif // VK_USE_PLATFORM_%s_KHR" % wsi_prefix
+
def generate_get_proc_addr_check(name):
return " if (!%s || %s[0] != 'v' || %s[1] != 'k')\n" \
" return NULL;" % ((name,) * 3)
@@ -431,12 +481,12 @@
func_body.append(' {')
extra_space = " "
for ext_name in ext_list:
- if 'Xcb' in ext_name:
- func_body.append("#ifdef VK_USE_PLATFORM_XCB_KHR")
+ if wsi_name(ext_name):
+ func_body.append('%s' % wsi_ifdef(ext_name))
func_body.append(' %sif (!strcmp("%s", funcName))\n'
' return reinterpret_cast<PFN_vkVoidFunction>(%s);' % (extra_space, ext_name, ext_name))
- if 'Xcb' in ext_name:
- func_body.append("#endif //VK_USE_PLATFORM_XCB_KHR")
+ if wsi_name(ext_name):
+ func_body.append('%s' % wsi_endif(ext_name))
if 0 != len(ext_enable):
func_body.append(' }\n')
@@ -541,12 +591,12 @@
func_body.append(' {')
extra_space = " "
for ext_name in ext_list:
- if 'Xcb' in ext_name:
- func_body.append('#ifdef VK_USE_PLATFORM_XCB_KHR')
+ if wsi_name(ext_name):
+ func_body.append('%s' % wsi_ifdef(ext_name))
func_body.append(' %sif (!strcmp("%s", funcName))\n'
' return reinterpret_cast<PFN_vkVoidFunction>(%s);' % (extra_space, ext_name, ext_name))
- if 'Xcb' in ext_name:
- func_body.append('#endif //VK_USE_PLATFORM_XCB_KHR')
+ if wsi_name(ext_name):
+ func_body.append('%s' % wsi_endif(ext_name))
if 0 != len(ext_enable):
func_body.append(' }\n')
@@ -748,8 +798,8 @@
' return result;\n'
'}\n' % (qual, decl, ret_val, proto.c_call(), proto.name))
else:
- if 'Xcb' in proto.name:
- funcs.append("#ifdef VK_USE_PLATFORM_XCB_KHR")
+ if wsi_name(proto.name):
+ funcs.append('%s' % wsi_ifdef(proto.name))
funcs.append('%s' % self.lineinfo.get())
dispatch_param = proto.params[0].name
# Must use 'instance' table for these APIs, 'device' table otherwise
@@ -763,8 +813,8 @@
' %s%s_dispatch_table(%s)->%s;\n'
'%s'
'}' % (qual, decl, ret_val, table_type, dispatch_param, proto.c_call(), stmt))
- if 'Xcb' in proto.name:
- funcs.append("#endif //VK_USE_PLATFORM_XCB_KHR")
+ if wsi_name(proto.name):
+ funcs.append('%s' % wsi_endif(proto.name))
return "\n\n".join(funcs)
def generate_body(self):
@@ -1172,8 +1222,8 @@
'%s'
'}' % (qual, decl, table_type, dispatch_param, ret_val, proto.c_call(), f_open, log_func, f_close, stmt))
else:
- if 'Xcb' in decl:
- funcs.append('#ifdef VK_USE_PLATFORM_XCB_KHR')
+ if wsi_name(decl):
+ funcs.append('%s' % wsi_ifdef(decl))
funcs.append('%s%s\n'
'{\n'
' using namespace StreamControl;\n'
@@ -1181,13 +1231,13 @@
' %s%s%s\n'
'%s'
'}' % (qual, decl, ret_val, table_type, dispatch_param, proto.c_call(), f_open, log_func, f_close, stmt))
- if 'Xcb' in decl:
- funcs.append('#endif //VK_USE_PLATFORM_XCB_KHR')
+ if wsi_name(decl):
+ funcs.append('%s' % wsi_endif(decl))
return "\n\n".join(funcs)
def generate_body(self):
self.layer_name = "APIDump"
- if sys.platform == 'win32':
+ if sys.platform.startswith('win32'):
instance_extensions=[('wsi_enabled',
['vkGetPhysicalDeviceSurfaceSupportKHR',
'vkGetPhysicalDeviceSurfaceCapabilitiesKHR',
@@ -1195,7 +1245,7 @@
'vkGetPhysicalDeviceSurfacePresentModesKHR',
'vkCreateWin32SurfaceKHR',
'vkGetPhysicalDeviceWin32PresentationSupportKHR'])]
- else:
+ elif sys.platform.startswith('linux'):
instance_extensions=[('wsi_enabled',
['vkGetPhysicalDeviceSurfaceSupportKHR',
'vkGetPhysicalDeviceSurfaceCapabilitiesKHR',
@@ -1203,6 +1253,13 @@
'vkGetPhysicalDeviceSurfacePresentModesKHR',
'vkCreateXcbSurfaceKHR',
'vkGetPhysicalDeviceXcbPresentationSupportKHR'])]
+ # TODO: Add cases for Mir, Xlib, Wayland
+ else:
+ instance_extensions=[('wsi_enabled',
+ ['vkGetPhysicalDeviceSurfaceSupportKHR',
+ 'vkGetPhysicalDeviceSurfaceCapabilitiesKHR',
+ 'vkGetPhysicalDeviceSurfaceFormatsKHR',
+ 'vkGetPhysicalDeviceSurfacePresentModesKHR'])]
extensions=[('wsi_enabled',
['vkCreateSwapchainKHR',
'vkDestroySwapchainKHR', 'vkGetSwapchainImagesKHR',
@@ -1724,8 +1781,8 @@
table_type = "instance"
else:
table_type = "device"
- if 'Xcb' in proto.name:
- funcs.append("#ifdef VK_USE_PLATFORM_XCB_KHR")
+ if wsi_name(proto.name):
+ funcs.append('%s' % wsi_ifdef(proto.name))
funcs.append('%s%s\n'
'{\n'
'%s'
@@ -1734,8 +1791,8 @@
'%s'
'%s'
'}' % (qual, decl, using_line, destroy_line, ret_val, table_type, dispatch_param, proto.c_call(), create_line, stmt))
- if 'Xcb' in proto.name:
- funcs.append("#endif //VK_USE_PLATFORM_XCB_KHR")
+ if wsi_name(proto.name):
+ funcs.append('%s' % wsi_endif(proto.name))
return "\n\n".join(funcs)
def generate_body(self):
@@ -1744,7 +1801,7 @@
['vkCreateSwapchainKHR',
'vkDestroySwapchainKHR', 'vkGetSwapchainImagesKHR',
'vkAcquireNextImageKHR', 'vkQueuePresentKHR'])]
- if sys.platform == 'win32':
+ if sys.platform.startswith('win32'):
instance_extensions=[('msg_callback_get_proc_addr', []),
('wsi_enabled',
['vkGetPhysicalDeviceSurfaceSupportKHR',
@@ -1753,7 +1810,7 @@
'vkGetPhysicalDeviceSurfacePresentModesKHR',
'vkCreateWin32SurfaceKHR',
'vkGetPhysicalDeviceWin32PresentationSupportKHR'])]
- else:
+ elif sys.platform.startswith('linux'):
instance_extensions=[('msg_callback_get_proc_addr', []),
('wsi_enabled',
['vkGetPhysicalDeviceSurfaceSupportKHR',
@@ -1762,6 +1819,14 @@
'vkGetPhysicalDeviceSurfacePresentModesKHR',
'vkCreateXcbSurfaceKHR',
'vkGetPhysicalDeviceXcbPresentationSupportKHR'])]
+ # TODO: Add cases for Mir, Wayland and Xlib
+ else: # android
+ instance_extensions=[('msg_callback_get_proc_addr', []),
+ ('wsi_enabled',
+ ['vkGetPhysicalDeviceSurfaceSupportKHR',
+ 'vkGetPhysicalDeviceSurfaceCapabilitiesKHR',
+ 'vkGetPhysicalDeviceSurfaceFormatsKHR',
+ 'vkGetPhysicalDeviceSurfacePresentModesKHR'])]
body = [self.generate_maps(),
self.generate_procs(),
self.generate_destroy_instance(),