This commit is contained in:
Megamouse 2025-04-27 16:01:10 +00:00 committed by GitHub
commit c6dd6e92bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 21 deletions

View file

@ -443,7 +443,8 @@ VKGSRender::VKGSRender(utils::serial* ar) noexcept : GSRender(ar)
using T = std::decay_t<decltype(p)>; using T = std::decay_t<decltype(p)>;
if constexpr (std::is_same_v<T, std::pair<Display*, Window>>) if constexpr (std::is_same_v<T, std::pair<Display*, Window>>)
{ {
m_display_handle = p.first; XFlush(m_display_handle); m_display_handle = p.first;
XFlush(m_display_handle);
} }
}, display); }, display);
#endif #endif

View file

@ -22,14 +22,16 @@ using display_handle_t = void*; // NSView
#else #else
#include <variant> #include <variant>
using display_handle_t = std::variant< using display_handle_t = std::variant<
#if defined(HAVE_X11) && defined(VK_USE_PLATFORM_WAYLAND_KHR) #if defined(HAVE_X11)
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
std::pair<Display*, Window>, std::pair<wl_display*, wl_surface*> std::pair<Display*, Window>, std::pair<wl_display*, wl_surface*>
#elif defined(HAVE_X11) #else
std::pair<Display*, Window> std::pair<Display*, Window>
#endif
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR) #elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
std::pair<wl_display*, wl_surface*> std::pair<wl_display*, wl_surface*>
#elif defined(ANDROID) #elif defined(ANDROID)
struct ANativeWindow * struct ANativeWindow*
#endif #endif
>; >;
#endif #endif

View file

@ -36,7 +36,7 @@
#elif defined(__APPLE__) #elif defined(__APPLE__)
//nothing //nothing
#else #else
#ifdef HAVE_WAYLAND #ifdef VK_USE_PLATFORM_WAYLAND_KHR
#include <QGuiApplication> #include <QGuiApplication>
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#endif #endif
@ -665,29 +665,22 @@ void gs_frame::show()
display_handle_t gs_frame::handle() const display_handle_t gs_frame::handle() const
{ {
#ifdef _WIN32 #if defined(_WIN32) || defined(__APPLE__)
return reinterpret_cast<HWND>(this->winId()); return reinterpret_cast<display_handle_t>(this->winId());
#elif defined(__APPLE__)
return reinterpret_cast<void*>(this->winId()); //NSView
#else #else
#ifdef HAVE_WAYLAND #ifdef VK_USE_PLATFORM_WAYLAND_KHR
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface(); QPlatformNativeInterface* native = QGuiApplication::platformNativeInterface();
struct wl_display *wl_dpy = static_cast<struct wl_display *>( struct wl_display* wl_dpy = static_cast<struct wl_display*>(native->nativeResourceForWindow("display", nullptr));
native->nativeResourceForWindow("display", NULL)); struct wl_surface* wl_surf = static_cast<struct wl_surface*>(native->nativeResourceForWindow("surface", const_cast<QWindow*>(static_cast<const QWindow*>(this))));
struct wl_surface *wl_surf = static_cast<struct wl_surface *>( if (wl_dpy && wl_surf)
native->nativeResourceForWindow("surface", const_cast<QWindow*>(static_cast<const QWindow*>(this))));
if (wl_dpy != nullptr && wl_surf != nullptr)
{ {
return std::make_pair(wl_dpy, wl_surf); return std::make_pair(wl_dpy, wl_surf);
} }
else
#endif #endif
#ifdef HAVE_X11 #ifdef HAVE_X11
{ return std::make_pair(XOpenDisplay(0), static_cast<ulong>(this->winId()));
return std::make_pair(XOpenDisplay(0), static_cast<ulong>(this->winId()));
}
#else #else
fmt::throw_exception("Vulkan X11 support disabled at compile-time."); fmt::throw_exception("Vulkan X11 support disabled at compile-time.");
#endif #endif
#endif #endif
} }