| 33 | }; |
| 34 | |
| 35 | void* KVulkdanSDLImpl::createVulkanSurface(const XWindowPtr& wnd, void* instance) { |
| 36 | VkSurfaceKHR result = {0}; |
| 37 | |
| 38 | #ifdef __MACH__ |
| 39 | // if SDL_Vulkan_CreateSurface isn't on the main there, then it won't draw on Mac |
| 40 | DISPATCH_MAIN_THREAD_BLOCK_THIS_BEGIN_WITH_ARG2(=, &result) |
| 41 | if (!screen->additionalSDLWindowFlags) { |
| 42 | screen->additionalSDLWindowFlags = SDL_WINDOW_VULKAN; |
| 43 | screen->recreateMainWindow(); |
| 44 | } |
| 45 | screen->setScreenSize(wnd->width(), wnd->height()); |
| 46 | screen->showWindow(true); |
| 47 | |
| 48 | if (!SDL_Vulkan_CreateSurface(screen->window, (VkInstance)instance, &result)) { |
| 49 | result = 0; |
| 50 | } |
| 51 | DISPATCH_MAIN_THREAD_BLOCK_END |
| 52 | #else |
| 53 | DISPATCH_MAIN_THREAD_BLOCK_THIS_BEGIN |
| 54 | if (!screen->additionalSDLWindowFlags) { |
| 55 | screen->additionalSDLWindowFlags = SDL_WINDOW_VULKAN; |
| 56 | screen->recreateMainWindow(); |
| 57 | } |
| 58 | screen->setScreenSize(wnd->width(), wnd->height()); |
| 59 | screen->showWindow(true); |
| 60 | DISPATCH_MAIN_THREAD_BLOCK_END |
| 61 | |
| 62 | if (!SDL_Vulkan_CreateSurface(screen->window, (VkInstance)instance, &result)) { |
| 63 | result = 0; |
| 64 | } |
| 65 | #endif |
| 66 | if (!result) { |
| 67 | kwarn_fmt("Failed to create vulkan surface: %s\n", SDL_GetError()); |
| 68 | } |
| 69 | return (void*)result; |
| 70 | } |
| 71 | |
| 72 | KVulkanPtr KVulkanSDL::create(const KNativeScreenSDLPtr& screen) { |
| 73 | return std::make_shared<KVulkdanSDLImpl>(screen); |
no test coverage detected