From 8b9e8c29ef7fa4a478d81cff8aef8ea2ae3d75b2 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 12 Feb 2022 20:52:10 -0500 Subject: [PATCH] Use VK_EXT_metal_surface on iOS --- engine/gfx/vulkan/src/gfx_vulkan.cpp | 3 +++ platforms/ios/ViewController.mm.in | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/engine/gfx/vulkan/src/gfx_vulkan.cpp b/engine/gfx/vulkan/src/gfx_vulkan.cpp index 5487b40..c048b63 100755 --- a/engine/gfx/vulkan/src/gfx_vulkan.cpp +++ b/engine/gfx/vulkan/src/gfx_vulkan.cpp @@ -1917,7 +1917,10 @@ void GFXVulkan::createLogicalDevice(std::vector extensions) { VkPhysicalDeviceFeatures enabledFeatures = {}; //enabledFeatures.vertexPipelineStoresAndAtomics = true; + // TODO: really not supported or are we not checking something? +#ifndef PLATFORM_IOS enabledFeatures.fragmentStoresAndAtomics = true; +#endif enabledFeatures.samplerAnisotropy = true; enabledFeatures.fillModeNonSolid = true; enabledFeatures.imageCubeArray = true; diff --git a/platforms/ios/ViewController.mm.in b/platforms/ios/ViewController.mm.in index af2ed83..e31169f 100644 --- a/platforms/ios/ViewController.mm.in +++ b/platforms/ios/ViewController.mm.in @@ -1,4 +1,5 @@ #include +#define VK_USE_PLATFORM_METAL_EXT #include #include @@ -181,7 +182,16 @@ void platform::end_text_input() { } void* platform::create_native_surface(platform::window_ptr index, void* instance) { - return nullptr; + VkMetalSurfaceCreateInfoEXT surfaceInfo = {}; + surfaceInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; + surfaceInfo.pNext = 0; + surfaceInfo.flags = 0; + surfaceInfo.pLayer = (CAMetalLayer*)layer; + + VkSurfaceKHR surface; + vkCreateMetalSurfaceEXT((VkInstance)instance, &surfaceInfo, nullptr, &surface); + + return surface; } bool platform::is_main_window(platform::window_ptr index) { @@ -189,7 +199,7 @@ bool platform::is_main_window(platform::window_ptr index) { } std::vector platform::get_native_surface_extension() { - return {}; + return {VK_EXT_METAL_SURFACE_EXTENSION_NAME}; } void platform::show_window(const platform::window_ptr index) {