diff --git a/CMakeLists.txt b/CMakeLists.txt
index eaf5adbf..0d0a904a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,6 +12,8 @@ include_directories(external/gli)
include_directories(external/assimp)
include_directories(base)
+OPTION(USE_D2D_WSI "Build the project using Direct to Display swapchain" OFF)
+
IF(WIN32)
find_library(VULKAN_LIB NAMES vulkan-1 vulkan PATHS ${CMAKE_SOURCE_DIR}/libs/vulkan)
find_library(ASSIMP_LIBRARIES NAMES assimp libassimp.dll.a PATHS ${CMAKE_SOURCE_DIR}/libs/assimp)
@@ -19,9 +21,14 @@ IF(WIN32)
ELSE(WIN32)
find_library(VULKAN_LIB NAMES libvulkan.so PATHS ${CMAKE_SOURCE_DIR}/libs/vulkan)
find_package(ASSIMP REQUIRED)
- find_package(XCB REQUIRED)
find_package(Threads REQUIRED)
+IF(USE_D2D_WSI)
+ MESSAGE("Using direct to display extension...")
+ add_definitions(-D_DIRECT2DISPLAY)
+ELSE(USE_D2D_WSI)
+ find_package(XCB REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_XCB_KHR")
+ENDIF(USE_D2D_WSI)
# Todo : android?
ENDIF(WIN32)
diff --git a/README.md b/README.md
index 33283c81..6edc960c 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,8 @@ Use the provided CMakeLists.txt with [CMake](https://cmake.org) to generate a bu
Note that you need [assimp](https://github.com/assimp/assimp) in order to compile the examples for Linux. Either compile and install from the repository, or install libassimp-dev. The examples require at least version 3.2.
+To use the Direct to Display swapchain extension (VK_KHR_display), please turn on the USE_D2D_WSI cmake option: "-DUSE_D2D_WSI=ON".
+
##
[Android](android/)
Building on Android is done using the [Android NDK](http://developer.android.com/tools/sdk/ndk/index.html) and requires a device that supports Vulkan. Please see the [Android readme](./android/README.md) on how to build and deploy the examples.
diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp
index f19bdeb5..824dd014 100644
--- a/base/vulkanexamplebase.cpp
+++ b/base/vulkanexamplebase.cpp
@@ -25,6 +25,8 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
enabledExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#elif defined(__ANDROID__)
enabledExtensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
+#elif defined(_DIRECT2DISPLAY)
+ enabledExtensions.push_back(VK_KHR_DISPLAY_EXTENSION_NAME);
#elif defined(__linux__)
enabledExtensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
#endif
@@ -509,6 +511,43 @@ void VulkanExampleBase::renderLoop()
}
}
}
+#elif defined(_DIRECT2DISPLAY)
+ while (!quit)
+ {
+ auto tStart = std::chrono::high_resolution_clock::now();
+ if (viewUpdated)
+ {
+ viewUpdated = false;
+ viewChanged();
+ }
+ render();
+ frameCounter++;
+ auto tEnd = std::chrono::high_resolution_clock::now();
+ auto tDiff = std::chrono::duration(tEnd - tStart).count();
+ frameTimer = tDiff / 1000.0f;
+ camera.update(frameTimer);
+ if (camera.moving())
+ {
+ viewUpdated = true;
+ }
+ // Convert to clamped timer value
+ if (!paused)
+ {
+ timer += timerSpeed * frameTimer;
+ if (timer > 1.0)
+ {
+ timer -= 1.0f;
+ }
+ }
+ fpsTimer += (float)tDiff;
+ if (fpsTimer > 1000.0f)
+ {
+ lastFPS = frameCounter;
+ updateTextOverlay();
+ fpsTimer = 0.0f;
+ frameCounter = 0;
+ }
+ }
#elif defined(__linux__)
xcb_flush(connection);
while (!quit)
@@ -654,6 +693,8 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation, PFN_GetEnabledFeatur
// Vulkan library is loaded dynamically on Android
bool libLoaded = loadVulkanLibrary();
assert(libLoaded);
+#elif defined(_DIRECT2DISPLAY)
+
#elif defined(__linux__)
initxcbConnection();
#endif
@@ -733,7 +774,9 @@ VulkanExampleBase::~VulkanExampleBase()
vkDestroyInstance(instance, nullptr);
-#if defined(__linux)
+#if defined(_DIRECT2DISPLAY)
+
+#elif defined(__linux)
#if defined(__ANDROID__)
// todo : android cleanup (if required)
#else
@@ -1212,6 +1255,7 @@ void VulkanExampleBase::handleAppCommand(android_app * app, int32_t cmd)
break;
}
}
+#elif defined(_DIRECT2DISPLAY)
#elif defined(__linux__)
// Set up a window using XCB and request event types
xcb_window_t VulkanExampleBase::setupWindow()
@@ -1652,6 +1696,8 @@ void VulkanExampleBase::initSwapchain()
swapChain.initSurface(windowInstance, window);
#elif defined(__ANDROID__)
swapChain.initSurface(androidApp->window);
+#elif defined(_DIRECT2DISPLAY)
+ swapChain.initSurface(width, height);
#elif defined(__linux__)
swapChain.initSurface(connection, window);
#endif
diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h
index c31468bc..acf8cb3b 100644
--- a/base/vulkanexamplebase.h
+++ b/base/vulkanexamplebase.h
@@ -392,6 +392,23 @@ void android_main(android_app* state) \
vulkanExample->renderLoop(); \
delete(vulkanExample); \
}
+#elif defined(_DIRECT2DISPLAY)
+// Linux entry point with direct to display wsi
+// todo: extract command line arguments
+#define VULKAN_EXAMPLE_MAIN() \
+VulkanExample *vulkanExample; \
+static void handleEvent() \
+{ \
+} \
+int main(const int argc, const char *argv[]) \
+{ \
+ vulkanExample = new VulkanExample(); \
+ vulkanExample->initSwapchain(); \
+ vulkanExample->prepare(); \
+ vulkanExample->renderLoop(); \
+ delete(vulkanExample); \
+ return 0; \
+}
#elif defined(__linux__)
// Linux entry point
// todo: extract command line arguments
diff --git a/base/vulkanswapchain.hpp b/base/vulkanswapchain.hpp
index da630861..7b55ccb5 100644
--- a/base/vulkanswapchain.hpp
+++ b/base/vulkanswapchain.hpp
@@ -107,7 +107,11 @@ public:
#ifdef __ANDROID__
ANativeWindow* window
#else
- xcb_connection_t* connection, xcb_window_t window
+#ifdef _DIRECT2DISPLAY
+ uint32_t width, uint32_t height
+#else
+ xcb_connection_t* connection, xcb_window_t window
+#endif
#endif
#endif
)
@@ -127,6 +131,9 @@ public:
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
surfaceCreateInfo.window = window;
err = vkCreateAndroidSurfaceKHR(instance, &surfaceCreateInfo, NULL, &surface);
+#else
+#if defined(_DIRECT2DISPLAY)
+ createDirect2DisplaySurface(width, height);
#else
VkXcbSurfaceCreateInfoKHR surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
@@ -134,6 +141,7 @@ public:
surfaceCreateInfo.window = window;
err = vkCreateXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface);
#endif
+#endif
#endif
// Get available queue family properties
@@ -480,4 +488,143 @@ public:
swapChain = VK_NULL_HANDLE;
}
+ /**
+ * Create direct to display surface
+ */
+ void createDirect2DisplaySurface(uint32_t width, uint32_t height)
+ {
+ uint32_t displayPropertyCount;
+
+ // Get display property
+ vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertyCount, NULL);
+ VkDisplayPropertiesKHR* pDisplayProperties = new VkDisplayPropertiesKHR[displayPropertyCount];
+ vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertyCount, pDisplayProperties);
+
+ // Get plane property
+ uint32_t planePropertyCount;
+ vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &planePropertyCount, NULL);
+ VkDisplayPlanePropertiesKHR* pPlaneProperties = new VkDisplayPlanePropertiesKHR[planePropertyCount];
+ vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &planePropertyCount, pPlaneProperties);
+
+ VkDisplayKHR display = VK_NULL_HANDLE;
+ VkDisplayModeKHR displayMode;
+ VkDisplayModePropertiesKHR* pModeProperties;
+ bool foundMode = false;
+
+ for(uint32_t i = 0; i < displayPropertyCount;++i)
+ {
+ display = pDisplayProperties[i].display;
+ uint32_t modeCount;
+ vkGetDisplayModePropertiesKHR(physicalDevice, display, &modeCount, NULL);
+ pModeProperties = new VkDisplayModePropertiesKHR[modeCount];
+ vkGetDisplayModePropertiesKHR(physicalDevice, display, &modeCount, pModeProperties);
+
+ for (uint32_t j = 0; j < modeCount; ++j)
+ {
+ const VkDisplayModePropertiesKHR* mode = &pModeProperties[j];
+
+ if (mode->parameters.visibleRegion.width == width && mode->parameters.visibleRegion.height == height)
+ {
+ displayMode = mode->displayMode;
+ foundMode = true;
+ break;
+ }
+ }
+ if (foundMode)
+ {
+ break;
+ }
+ delete [] pModeProperties;
+ }
+
+ if(!foundMode)
+ {
+ vkTools::exitFatal("Can't find a display and a display mode!", "Fatal error");
+ return;
+ }
+
+ // Search for a best plane we can use
+ uint32_t bestPlaneIndex = UINT32_MAX;
+ VkDisplayKHR* pDisplays = NULL;
+ for(uint32_t i = 0; i < planePropertyCount; i++)
+ {
+ uint32_t planeIndex=i;
+ uint32_t displayCount;
+ vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, &displayCount, NULL);
+ if (pDisplays)
+ {
+ delete [] pDisplays;
+ }
+ pDisplays = new VkDisplayKHR[displayCount];
+ vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, &displayCount, pDisplays);
+
+ // Find a display that matches the current plane
+ bestPlaneIndex = UINT32_MAX;
+ for(uint32_t j = 0; j < displayCount; j++)
+ {
+ if(display == pDisplays[j])
+ {
+ bestPlaneIndex = i;
+ break;
+ }
+ }
+ if(bestPlaneIndex != UINT32_MAX)
+ {
+ break;
+ }
+ }
+
+ if(bestPlaneIndex == UINT32_MAX)
+ {
+ vkTools::exitFatal("Can't find a plane for displaying!", "Fatal error");
+ return;
+ }
+
+ VkDisplayPlaneCapabilitiesKHR planeCap;
+ vkGetDisplayPlaneCapabilitiesKHR(physicalDevice, displayMode, bestPlaneIndex, &planeCap);
+ VkDisplayPlaneAlphaFlagBitsKHR alphaMode;
+
+ if (planeCap.supportedAlpha & VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR)
+ {
+ alphaMode = VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR;
+ }
+ else if (planeCap.supportedAlpha & VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR)
+ {
+
+ alphaMode = VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR;
+ }
+ else
+ {
+ alphaMode = VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR;
+ }
+
+ VkDisplaySurfaceCreateInfoKHR surfaceInfo =
+ {
+ .sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR,
+ .pNext = NULL,
+ .flags = 0,
+ .displayMode = displayMode,
+ .planeIndex = bestPlaneIndex,
+ .planeStackIndex = pPlaneProperties[bestPlaneIndex].currentStackIndex,
+ .transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR,
+ .globalAlpha = 1.0,
+ .alphaMode = alphaMode,
+ .imageExtent =
+ {
+ width,
+ height,
+ }
+ };
+
+ VkResult result = vkCreateDisplayPlaneSurfaceKHR(instance, &surfaceInfo, NULL, &surface);
+ if(result !=VK_SUCCESS)
+ {
+ vkTools::exitFatal("Failed to create surface!", "Fatal error");
+ }
+
+ delete[] pDisplays;
+ delete[] pModeProperties;
+ delete[] pDisplayProperties;
+ delete[] pPlaneProperties;
+ }
};
diff --git a/debugmarker/debugmarker.cpp b/debugmarker/debugmarker.cpp
index c9759aeb..00890895 100644
--- a/debugmarker/debugmarker.cpp
+++ b/debugmarker/debugmarker.cpp
@@ -1172,7 +1172,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -1208,7 +1208,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/displacement/displacement.cpp b/displacement/displacement.cpp
index 69230035..addaa5e4 100644
--- a/displacement/displacement.cpp
+++ b/displacement/displacement.cpp
@@ -603,7 +603,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -639,7 +639,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/distancefieldfonts/distancefieldfonts.cpp b/distancefieldfonts/distancefieldfonts.cpp
index 4256ee49..1298fd5e 100644
--- a/distancefieldfonts/distancefieldfonts.cpp
+++ b/distancefieldfonts/distancefieldfonts.cpp
@@ -751,7 +751,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -787,7 +787,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/gears/gears.cpp b/gears/gears.cpp
index a9a0663d..b6f71d2b 100644
--- a/gears/gears.cpp
+++ b/gears/gears.cpp
@@ -383,7 +383,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -419,7 +419,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/geometryshader/geometryshader.cpp b/geometryshader/geometryshader.cpp
index cc189035..aba781ae 100644
--- a/geometryshader/geometryshader.cpp
+++ b/geometryshader/geometryshader.cpp
@@ -506,7 +506,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -542,7 +542,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/instancing/instancing.cpp b/instancing/instancing.cpp
index 4406dc9a..ef95a0bb 100644
--- a/instancing/instancing.cpp
+++ b/instancing/instancing.cpp
@@ -608,7 +608,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -644,7 +644,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/mesh/mesh.cpp b/mesh/mesh.cpp
index 5075c4c9..1e2f5748 100644
--- a/mesh/mesh.cpp
+++ b/mesh/mesh.cpp
@@ -642,7 +642,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -678,7 +678,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/occlusionquery/occlusionquery.cpp b/occlusionquery/occlusionquery.cpp
index 9334f6df..b463d34c 100644
--- a/occlusionquery/occlusionquery.cpp
+++ b/occlusionquery/occlusionquery.cpp
@@ -657,7 +657,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -693,7 +693,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/parallaxmapping/parallaxmapping.cpp b/parallaxmapping/parallaxmapping.cpp
index 4ef05653..cda7918a 100644
--- a/parallaxmapping/parallaxmapping.cpp
+++ b/parallaxmapping/parallaxmapping.cpp
@@ -623,7 +623,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -659,7 +659,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/particlefire/particlefire.cpp b/particlefire/particlefire.cpp
index 44fd2e65..8182676f 100644
--- a/particlefire/particlefire.cpp
+++ b/particlefire/particlefire.cpp
@@ -799,7 +799,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -835,7 +835,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/pipelines/pipelines.cpp b/pipelines/pipelines.cpp
index 8f7687f0..330bf0fd 100644
--- a/pipelines/pipelines.cpp
+++ b/pipelines/pipelines.cpp
@@ -482,7 +482,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -518,7 +518,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/pushconstants/pushconstants.cpp b/pushconstants/pushconstants.cpp
index 8ad687ca..4793f5f1 100644
--- a/pushconstants/pushconstants.cpp
+++ b/pushconstants/pushconstants.cpp
@@ -489,7 +489,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -525,7 +525,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/scenerendering/scenerendering.cpp b/scenerendering/scenerendering.cpp
index 525dc01c..8a61e1a3 100644
--- a/scenerendering/scenerendering.cpp
+++ b/scenerendering/scenerendering.cpp
@@ -888,7 +888,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -924,7 +924,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/shadowmappingomni/shadowmappingomni.cpp b/shadowmappingomni/shadowmappingomni.cpp
index 1c7399bf..d980729c 100644
--- a/shadowmappingomni/shadowmappingomni.cpp
+++ b/shadowmappingomni/shadowmappingomni.cpp
@@ -1101,7 +1101,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -1137,7 +1137,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/sphericalenvmapping/sphericalenvmapping.cpp b/sphericalenvmapping/sphericalenvmapping.cpp
index c927d4bf..cb0dd6b2 100644
--- a/sphericalenvmapping/sphericalenvmapping.cpp
+++ b/sphericalenvmapping/sphericalenvmapping.cpp
@@ -500,7 +500,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -536,7 +536,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/terraintessellation/terraintessellation.cpp b/terraintessellation/terraintessellation.cpp
index 575f9594..a266b1c5 100644
--- a/terraintessellation/terraintessellation.cpp
+++ b/terraintessellation/terraintessellation.cpp
@@ -990,7 +990,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -1026,7 +1026,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/tessellation/tessellation.cpp b/tessellation/tessellation.cpp
index ce682ec9..f11ff572 100644
--- a/tessellation/tessellation.cpp
+++ b/tessellation/tessellation.cpp
@@ -609,7 +609,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -645,7 +645,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/textoverlay/textoverlay.cpp b/textoverlay/textoverlay.cpp
index e0f51550..761f93a3 100644
--- a/textoverlay/textoverlay.cpp
+++ b/textoverlay/textoverlay.cpp
@@ -1238,7 +1238,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -1274,7 +1274,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/texturearray/texturearray.cpp b/texturearray/texturearray.cpp
index 08c9899f..4e44bb69 100644
--- a/texturearray/texturearray.cpp
+++ b/texturearray/texturearray.cpp
@@ -703,7 +703,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -739,7 +739,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/texturecubemap/texturecubemap.cpp b/texturecubemap/texturecubemap.cpp
index 524e18b3..a8d7cd9e 100644
--- a/texturecubemap/texturecubemap.cpp
+++ b/texturecubemap/texturecubemap.cpp
@@ -788,7 +788,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != NULL)
@@ -824,7 +824,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
diff --git a/triangle/triangle.cpp b/triangle/triangle.cpp
index 066dc1db..e5618982 100644
--- a/triangle/triangle.cpp
+++ b/triangle/triangle.cpp
@@ -1028,7 +1028,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
-#elif defined(__linux__) && !defined(__ANDROID__)
+#elif defined(__linux__) && !defined(__ANDROID__) && !defined(_DIRECT2DISPLAY)
static void handleEvent(const xcb_generic_event_t *event)
{
if (vulkanExample != nullptr)
@@ -1064,7 +1064,7 @@ int main(const int argc, const char *argv[])
state->onAppCmd = VulkanExample::handleAppCommand;
state->onInputEvent = VulkanExample::handleAppInput;
vulkanExample->androidApp = state;
-#elif defined(__linux__)
+#elif defined(__linux__) && !defined(_DIRECT2DISPLAY)
vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)