From 7e5bb54a3e70b38ac9b1cac8fbd983dd0f76c794 Mon Sep 17 00:00:00 2001 From: Daniel Kalmar <1355747+kalmard0@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:02:06 +0200 Subject: [PATCH] Improve NX Vulkan support. (#3357) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change was developed using publicly available information found in Vulkan headers and official documentation. No proprietary NX resources were used. Co-authored-by: Бранимир Караџић --- src/renderer_vk.cpp | 10 ++++++++++ src/renderer_vk.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index c94a81844..0a55c663e 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -7022,6 +7022,16 @@ VK_DESTROY result = vkCreateMacOSSurfaceMVK(instance, &sci, allocatorCb, &m_surface); } } +#elif BX_PLATFORM_NX + if (NULL != vkCreateViSurfaceNN) + { + VkViSurfaceCreateInfoNN sci; + sci.sType = VK_STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN; + sci.pNext = NULL; + sci.flags = 0; + sci.window = m_nwh; + result = vkCreateViSurfaceNN(instance, &sci, allocatorCb, &m_surface); + } #else # error "Figure out KHR surface..." #endif // BX_PLATFORM_ diff --git a/src/renderer_vk.h b/src/renderer_vk.h index b138ba9eb..244faf0ad 100644 --- a/src/renderer_vk.h +++ b/src/renderer_vk.h @@ -31,6 +31,10 @@ # define VK_USE_PLATFORM_MACOS_MVK # define KHR_SURFACE_EXTENSION_NAME VK_MVK_MACOS_SURFACE_EXTENSION_NAME # define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_MACOS +#elif BX_PLATFORM_NX +# define VK_USE_PLATFORM_VI_NN +# define KHR_SURFACE_EXTENSION_NAME VK_NN_VI_SURFACE_EXTENSION_NAME +# define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_NX #else # define KHR_SURFACE_EXTENSION_NAME "" # define VK_IMPORT_INSTANCE_PLATFORM @@ -102,6 +106,10 @@ /* VK_MVK_macos_surface */ \ VK_IMPORT_INSTANCE_FUNC(true, vkCreateMacOSSurfaceMVK); \ +#define VK_IMPORT_INSTANCE_NX \ + /* VK_NN_vi_surface */ \ + VK_IMPORT_INSTANCE_FUNC(true, vkCreateViSurfaceNN); \ + #define VK_IMPORT_INSTANCE \ VK_IMPORT_INSTANCE_FUNC(false, vkDestroyInstance); \ VK_IMPORT_INSTANCE_FUNC(false, vkEnumeratePhysicalDevices); \