Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve NX Vulkan support. #3356

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/renderer_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,7 @@ VK_IMPORT_DEVICE

setGraphicsDebuggerPresent(NULL != m_renderDocDll);

#if defined(VK_NO_PROTOTYPES)
m_vulkan1Dll = bx::dlopen(
#if BX_PLATFORM_WINDOWS
"vulkan-1.dll"
Expand Down Expand Up @@ -1203,6 +1204,21 @@ VK_IMPORT

#undef VK_IMPORT_FUNC

#else // VK_NO_PROTOTYPES

vkGetInstanceProcAddr = ::vkGetInstanceProcAddr;
vkGetDeviceProcAddr = ::vkGetDeviceProcAddr;
#define VK_IMPORT_FUNC(_optional, _func) \
kalmard0 marked this conversation as resolved.
Show resolved Hide resolved
if (NULL == _func) { \
_func = (PFN_##_func)vkGetInstanceProcAddr(NULL, #_func); \
BX_TRACE("\t%p " #_func, _func); \
imported &= _optional || NULL != _func; \
} while(0)

VK_IMPORT
#undef VK_IMPORT_FUNC
#endif // VK_NO_PROTOTYPES

if (!imported)
{
BX_TRACE("Init error: Failed to load shared library functions.");
Expand Down Expand Up @@ -7022,6 +7038,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_
Expand Down
10 changes: 10 additions & 0 deletions src/renderer_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@
# 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
#endif // BX_PLATFORM_*

#define VK_NO_STDINT_H
#if !BX_PLATFORM_NX
#define VK_NO_PROTOTYPES
#endif
#include <vulkan-local/vulkan.h>
#include <vulkan-local/vulkan_beta.h>

Expand Down Expand Up @@ -102,6 +108,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); \
Expand Down
Loading