diff options
author | RSDuck <RSDuck@users.noreply.github.com> | 2022-10-17 22:55:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 22:55:11 +0200 |
commit | ac3118cbc54715da55856958b42817fbd1eed666 (patch) | |
tree | 717e66ec7df79171821f46e02b47d1357256ace2 /src/frontend/duckstation/gl/context_egl_x11.cpp | |
parent | 31ba585d392c9745917a141c72b3349d029586f0 (diff) |
No more context mess (#1531)
* WIP: use Duckstation's context code to directly render into QT Widget from separate thread without two OpenGL contexts
currently only works on Windows
* reenable gay OSD
* add back vsync
* make it atleast a little more thread safe
* linux support
* don't segfault on closing
* reorganise and cleanup build system
it's still not good, but better than before
* macos?
* try to get it working on Ubuntu CI
also update instructions
* let's try this
* ok how about this
* try creating an OGL 4.3 context first
(https://i.kym-cdn.com/photos/images/original/001/264/842/220.png)
* fix Ubuntu
* hm
* try again for Windows
* let's try this
* make the OpenGL renderer work again
that was stupid
* do OGL surface resizing from the mainthread
* Fix small mistake in GL context creation on macOS causing version 3.2 to
be considered invalid
* C stupidness
* cleanup
* don't let the emuthread deinit OGL if there's no OGL
* reset lastScreenWidth/Height when deiniting OpenGL
* disable stencil test while drawing framebuffers
* macOS: Link Cocoa framework explicitly when not building with Qt6
Seems to be needed for the classes used by DuckStation's GL context
code.
* Set ScreenPanelGL's minimum size immediately
Fixes GL context creation for OpenGL display on macOS using the wrong
size as the underlying window was not resized to the correct size by Qt
yet.
* don't emit window updates when OGL display is used
* stuff Arisotura said
Co-authored-by: Nadia Holmquist Pedersen <nadia@nhp.sh>
Diffstat (limited to 'src/frontend/duckstation/gl/context_egl_x11.cpp')
-rw-r--r-- | src/frontend/duckstation/gl/context_egl_x11.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/frontend/duckstation/gl/context_egl_x11.cpp b/src/frontend/duckstation/gl/context_egl_x11.cpp new file mode 100644 index 0000000..c7310e3 --- /dev/null +++ b/src/frontend/duckstation/gl/context_egl_x11.cpp @@ -0,0 +1,69 @@ +#include "context_egl_x11.h" +#include "../log.h" +Log_SetChannel(GL::ContextEGLX11); + +namespace GL { +ContextEGLX11::ContextEGLX11(const WindowInfo& wi) : ContextEGL(wi) {} +ContextEGLX11::~ContextEGLX11() = default; + +std::unique_ptr<Context> ContextEGLX11::Create(const WindowInfo& wi, const Version* versions_to_try, + size_t num_versions_to_try) +{ + std::unique_ptr<ContextEGLX11> context = std::make_unique<ContextEGLX11>(wi); + if (!context->Initialize(versions_to_try, num_versions_to_try)) + return nullptr; + + return context; +} + +std::unique_ptr<Context> ContextEGLX11::CreateSharedContext(const WindowInfo& wi) +{ + std::unique_ptr<ContextEGLX11> context = std::make_unique<ContextEGLX11>(wi); + context->m_display = m_display; + + if (!context->CreateContextAndSurface(m_version, m_context, false)) + return nullptr; + + return context; +} + +void ContextEGLX11::ResizeSurface(u32 new_surface_width, u32 new_surface_height) +{ + m_window.Resize(); + ContextEGL::ResizeSurface(new_surface_width, new_surface_height); +} + +EGLNativeWindowType ContextEGLX11::GetNativeWindow(EGLConfig config) +{ + X11InhibitErrors ei; + + EGLint native_visual_id = 0; + if (!eglGetConfigAttrib(m_display, m_config, EGL_NATIVE_VISUAL_ID, &native_visual_id)) + { + Log_ErrorPrintf("Failed to get X11 visual ID"); + return false; + } + + XVisualInfo vi_query = {}; + vi_query.visualid = native_visual_id; + + int num_vis; + XVisualInfo* vi = XGetVisualInfo(static_cast<Display*>(m_wi.display_connection), VisualIDMask, &vi_query, &num_vis); + if (num_vis <= 0 || !vi) + { + Log_ErrorPrintf("Failed to query visual from X11"); + return false; + } + + m_window.Destroy(); + if (!m_window.Create(GetDisplay(), static_cast<Window>(reinterpret_cast<uintptr_t>(m_wi.window_handle)), vi)) + { + Log_ErrorPrintf("Faild to create X11 child window"); + XFree(vi); + return false; + } + + XFree(vi); + return static_cast<EGLNativeWindowType>(m_window.GetWindow()); +} +} // namespace GL |