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 "Emu/System.h"
#include "Emu/system_config.h"
#include <QOpenGLContext>
@ -31,7 +32,11 @@ draw_context_t gl_gs_frame::make_context()
{
auto surface = new QOffscreenSurface();
surface->setFormat(m_format);
// 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
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);
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
constexpr int c_map_noreserve = MAP_NORESERVE;
#else
constexpr int c_map_noreserve = 0;
[[maybe_unused]] constexpr int c_map_noreserve = 0;
#endif
#ifdef MADV_FREE
@ -66,7 +66,7 @@ namespace utils
#ifdef MADV_HUGEPAGE
constexpr int c_madv_hugepage = MADV_HUGEPAGE;
#else
constexpr int c_madv_hugepage = 0;
[[maybe_unused]] constexpr int c_madv_hugepage = 0;
#endif
#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_dump = MADV_CORE;
#else
constexpr int c_madv_no_dump = 0;
constexpr int c_madv_dump = 0;
[[maybe_unused]] constexpr int c_madv_no_dump = 0;
[[maybe_unused]] constexpr int c_madv_dump = 0;
#endif
#if defined(MFD_HUGETLB) && defined(MFD_HUGE_2MB)