opengl: fix Qt warnings (#14249)

This commit is contained in:
oltolm 2023-07-24 06:30:21 +02:00 committed by GitHub
parent a975b4937a
commit 7cb2d3f143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -1,5 +1,6 @@
#include "gl_gs_frame.h" #include "gl_gs_frame.h"
#include "Emu/System.h"
#include "Emu/system_config.h" #include "Emu/system_config.h"
#include <QOpenGLContext> #include <QOpenGLContext>
@ -31,7 +32,11 @@ draw_context_t gl_gs_frame::make_context()
{ {
auto surface = new QOffscreenSurface(); auto surface = new QOffscreenSurface();
surface->setFormat(m_format); surface->setFormat(m_format);
surface->create(); // Workaround for the Qt warning: "Attempting to create QWindow-based QOffscreenSurface outside the gui thread. Expect failures."
Emu.BlockingCallFromMainThread([&]()
{
surface->create();
});
// Share resources with the first created context // Share resources with the first created context
context->handle->setShareContext(m_primary_context->handle); context->handle->setShareContext(m_primary_context->handle);
@ -117,5 +122,8 @@ void gl_gs_frame::flip(draw_context_t context, bool skip_frame)
const auto gl_ctx = static_cast<GLContext*>(context); const auto gl_ctx = static_cast<GLContext*>(context);
gl_ctx->handle->swapBuffers(gl_ctx->surface); if (auto window = dynamic_cast<QWindow*>(gl_ctx->surface); window && window->isExposed())
{
gl_ctx->handle->swapBuffers(gl_ctx->surface);
}
} }

View File

@ -52,7 +52,7 @@ namespace utils
#ifdef MAP_NORESERVE #ifdef MAP_NORESERVE
constexpr int c_map_noreserve = MAP_NORESERVE; constexpr int c_map_noreserve = MAP_NORESERVE;
#else #else
constexpr int c_map_noreserve = 0; [[maybe_unused]] constexpr int c_map_noreserve = 0;
#endif #endif
#ifdef MADV_FREE #ifdef MADV_FREE
@ -66,7 +66,7 @@ namespace utils
#ifdef MADV_HUGEPAGE #ifdef MADV_HUGEPAGE
constexpr int c_madv_hugepage = MADV_HUGEPAGE; constexpr int c_madv_hugepage = MADV_HUGEPAGE;
#else #else
constexpr int c_madv_hugepage = 0; [[maybe_unused]] constexpr int c_madv_hugepage = 0;
#endif #endif
#if defined(MADV_DONTDUMP) && defined(MADV_DODUMP) #if defined(MADV_DONTDUMP) && defined(MADV_DODUMP)
@ -76,8 +76,8 @@ namespace utils
constexpr int c_madv_no_dump = MADV_NOCORE; constexpr int c_madv_no_dump = MADV_NOCORE;
constexpr int c_madv_dump = MADV_CORE; constexpr int c_madv_dump = MADV_CORE;
#else #else
constexpr int c_madv_no_dump = 0; [[maybe_unused]] constexpr int c_madv_no_dump = 0;
constexpr int c_madv_dump = 0; [[maybe_unused]] constexpr int c_madv_dump = 0;
#endif #endif
#if defined(MFD_HUGETLB) && defined(MFD_HUGE_2MB) #if defined(MFD_HUGETLB) && defined(MFD_HUGE_2MB)