diff options
| author | Léo Lam <leo@leolam.fr> | 2020-10-26 19:01:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-26 19:01:26 +0100 |
| commit | 07e6d008bd6c34b8af07247935bc8aa6abc596df (patch) | |
| tree | e5084fc3c855e85bcff41046533ec765135e3656 /Source/Core/Common/GL/GLInterface | |
| parent | 7f66de062c3c0b7d0f1e49682f8663dc978e76fc (diff) | |
| parent | 4e8df93f4179a684b507d9c712b7e8121fc83119 (diff) | |
Merge pull request #9187 from lioncash/commonlog
Common: Migrate logging to fmt
Diffstat (limited to 'Source/Core/Common/GL/GLInterface')
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/AGL.mm | 8 | ||||
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/EGL.cpp | 40 | ||||
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/GLX.cpp | 30 | ||||
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/WGL.cpp | 31 |
4 files changed, 61 insertions, 48 deletions
diff --git a/Source/Core/Common/GL/GLInterface/AGL.mm b/Source/Core/Common/GL/GLInterface/AGL.mm index 0c8b45e328..93195f1bb6 100644 --- a/Source/Core/Common/GL/GLInterface/AGL.mm +++ b/Source/Core/Common/GL/GLInterface/AGL.mm @@ -30,7 +30,7 @@ static bool AttachContextToView(NSOpenGLContext* context, NSView* view, u32* wid NSWindow* window = [view window]; if (window == nil) { - ERROR_LOG(VIDEO, "failed to get NSWindow"); + ERROR_LOG_FMT(VIDEO, "failed to get NSWindow"); return false; } @@ -83,14 +83,14 @@ bool GLContextAGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor m_pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; if (m_pixel_format == nil) { - ERROR_LOG(VIDEO, "failed to create pixel format"); + ERROR_LOG_FMT(VIDEO, "failed to create pixel format"); return false; } m_context = [[NSOpenGLContext alloc] initWithFormat:m_pixel_format shareContext:nil]; if (m_context == nil) { - ERROR_LOG(VIDEO, "failed to create context"); + ERROR_LOG_FMT(VIDEO, "failed to create context"); return false; } @@ -112,7 +112,7 @@ std::unique_ptr<GLContext> GLContextAGL::CreateSharedContext() shareContext:m_context]; if (new_agl_context == nil) { - ERROR_LOG(VIDEO, "failed to create shared context"); + ERROR_LOG_FMT(VIDEO, "failed to create shared context"); return nullptr; } diff --git a/Source/Core/Common/GL/GLInterface/EGL.cpp b/Source/Core/Common/GL/GLInterface/EGL.cpp index 6163754095..13a8bc0eb9 100644 --- a/Source/Core/Common/GL/GLInterface/EGL.cpp +++ b/Source/Core/Common/GL/GLInterface/EGL.cpp @@ -78,7 +78,7 @@ void GLContextEGL::DetectMode() // Get how many configs there are if (!eglChooseConfig(m_egl_display, attribs, nullptr, 0, &num_configs)) { - INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config"); + INFO_LOG_FMT(VIDEO, "Error: couldn't get an EGL visual config"); continue; } @@ -87,7 +87,7 @@ void GLContextEGL::DetectMode() // Get all the configurations if (!eglChooseConfig(m_egl_display, attribs, config, num_configs, &num_configs)) { - INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config"); + INFO_LOG_FMT(VIDEO, "Error: couldn't get an EGL visual config"); delete[] config; continue; } @@ -110,18 +110,18 @@ void GLContextEGL::DetectMode() if (supportsGL) { - INFO_LOG(VIDEO, "Using OpenGL"); + INFO_LOG_FMT(VIDEO, "Using OpenGL"); m_opengl_mode = Mode::OpenGL; } else if (supportsGLES3) { - INFO_LOG(VIDEO, "Using OpenGL|ES"); + INFO_LOG_FMT(VIDEO, "Using OpenGL|ES"); m_opengl_mode = Mode::OpenGLES; } else { // Errored before we found a mode - ERROR_LOG(VIDEO, "Error: Failed to detect OpenGL flavour, falling back to OpenGL"); + ERROR_LOG_FMT(VIDEO, "Error: Failed to detect OpenGL flavour, falling back to OpenGL"); // This will fail to create a context, as it'll try to use the same attribs we just failed to // find a matching config with m_opengl_mode = Mode::OpenGL; @@ -149,13 +149,13 @@ bool GLContextEGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor m_egl_display = OpenEGLDisplay(); if (!m_egl_display) { - INFO_LOG(VIDEO, "Error: eglGetDisplay() failed"); + INFO_LOG_FMT(VIDEO, "Error: eglGetDisplay() failed"); return false; } if (!eglInitialize(m_egl_display, &egl_major, &egl_minor)) { - INFO_LOG(VIDEO, "Error: eglInitialize() failed"); + INFO_LOG_FMT(VIDEO, "Error: eglInitialize() failed"); return false; } @@ -191,13 +191,13 @@ bool GLContextEGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor ctx_attribs = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE}; break; default: - ERROR_LOG(VIDEO, "Unknown opengl mode set"); + ERROR_LOG_FMT(VIDEO, "Unknown opengl mode set"); return false; } if (!eglChooseConfig(m_egl_display, attribs, &m_config, 1, &num_configs)) { - INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config"); + INFO_LOG_FMT(VIDEO, "Error: couldn't get an EGL visual config"); return false; } @@ -247,13 +247,13 @@ bool GLContextEGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor if (!m_egl_context) { - INFO_LOG(VIDEO, "Error: eglCreateContext failed"); + INFO_LOG_FMT(VIDEO, "Error: eglCreateContext failed"); return false; } if (!CreateWindowSurface()) { - ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed 0x%04x", eglGetError()); + ERROR_LOG_FMT(VIDEO, "Error: CreateWindowSurface failed {:#06x}", eglGetError()); return false; } @@ -267,7 +267,7 @@ std::unique_ptr<GLContext> GLContextEGL::CreateSharedContext() eglCreateContext(m_egl_display, m_config, m_egl_context, m_attribs.data()); if (!new_egl_context) { - INFO_LOG(VIDEO, "Error: eglCreateContext failed 0x%04x", eglGetError()); + INFO_LOG_FMT(VIDEO, "Error: eglCreateContext failed {:#06x}", eglGetError()); return nullptr; } @@ -281,7 +281,7 @@ std::unique_ptr<GLContext> GLContextEGL::CreateSharedContext() new_context->m_is_shared = true; if (!new_context->CreateWindowSurface()) { - ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed 0x%04x", eglGetError()); + ERROR_LOG_FMT(VIDEO, "Error: CreateWindowSurface failed {:#06x}", eglGetError()); return nullptr; } @@ -296,7 +296,7 @@ bool GLContextEGL::CreateWindowSurface() m_egl_surface = eglCreateWindowSurface(m_egl_display, m_config, native_window, nullptr); if (!m_egl_surface) { - INFO_LOG(VIDEO, "Error: eglCreateWindowSurface failed"); + INFO_LOG_FMT(VIDEO, "Error: eglCreateWindowSurface failed"); return false; } @@ -305,8 +305,8 @@ bool GLContextEGL::CreateWindowSurface() if (!eglQuerySurface(m_egl_display, m_egl_surface, EGL_WIDTH, &surface_width) || !eglQuerySurface(m_egl_display, m_egl_surface, EGL_HEIGHT, &surface_height)) { - WARN_LOG(VIDEO, - "Failed to get surface dimensions via eglQuerySurface. Size may be incorrect."); + WARN_LOG_FMT(VIDEO, + "Failed to get surface dimensions via eglQuerySurface. Size may be incorrect."); } m_backbuffer_width = static_cast<int>(surface_width); m_backbuffer_height = static_cast<int>(surface_height); @@ -319,7 +319,7 @@ bool GLContextEGL::CreateWindowSurface() m_egl_surface = eglCreatePbufferSurface(m_egl_display, m_config, attrib_list); if (!m_egl_surface) { - INFO_LOG(VIDEO, "Error: eglCreatePbufferSurface failed"); + INFO_LOG_FMT(VIDEO, "Error: eglCreatePbufferSurface failed"); return false; } } @@ -338,7 +338,7 @@ void GLContextEGL::DestroyWindowSurface() if (eglGetCurrentSurface(EGL_DRAW) == m_egl_surface) eglMakeCurrent(m_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (!eglDestroySurface(m_egl_display, m_egl_surface)) - NOTICE_LOG(VIDEO, "Could not destroy window surface."); + NOTICE_LOG_FMT(VIDEO, "Could not destroy window surface."); m_egl_surface = EGL_NO_SURFACE; } @@ -370,9 +370,9 @@ void GLContextEGL::DestroyContext() if (eglGetCurrentContext() == m_egl_context) eglMakeCurrent(m_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (!eglDestroyContext(m_egl_display, m_egl_context)) - NOTICE_LOG(VIDEO, "Could not destroy drawing context."); + NOTICE_LOG_FMT(VIDEO, "Could not destroy drawing context."); if (!m_is_shared && !eglTerminate(m_egl_display)) - NOTICE_LOG(VIDEO, "Could not destroy display connection."); + NOTICE_LOG_FMT(VIDEO, "Could not destroy display connection."); m_egl_context = EGL_NO_CONTEXT; m_egl_display = EGL_NO_DISPLAY; } diff --git a/Source/Core/Common/GL/GLInterface/GLX.cpp b/Source/Core/Common/GL/GLInterface/GLX.cpp index 70ee8485b2..052dbbf6a1 100644 --- a/Source/Core/Common/GL/GLInterface/GLX.cpp +++ b/Source/Core/Common/GL/GLInterface/GLX.cpp @@ -54,11 +54,18 @@ void GLContextGLX::SwapInterval(int Interval) // Try EXT_swap_control, then MESA_swap_control. if (glXSwapIntervalEXTPtr) + { glXSwapIntervalEXTPtr(m_display, m_drawable, Interval); + } else if (glXSwapIntervalMESAPtr) + { glXSwapIntervalMESAPtr(static_cast<unsigned int>(Interval)); + } else - ERROR_LOG(VIDEO, "No support for SwapInterval (framerate clamped to monitor refresh rate)."); + { + ERROR_LOG_FMT(VIDEO, + "No support for SwapInterval (framerate clamped to monitor refresh rate)."); + } } void* GLContextGLX::GetFuncAddress(const std::string& name) @@ -83,8 +90,8 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor glXQueryVersion(m_display, &glxMajorVersion, &glxMinorVersion); if (glxMajorVersion < 1 || (glxMajorVersion == 1 && glxMinorVersion < 4)) { - ERROR_LOG(VIDEO, "glX-Version %d.%d detected, but need at least 1.4", glxMajorVersion, - glxMinorVersion); + ERROR_LOG_FMT(VIDEO, "glX-Version {}.{} detected, but need at least 1.4", glxMajorVersion, + glxMinorVersion); return false; } @@ -93,8 +100,8 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor (PFNGLXCREATECONTEXTATTRIBSPROC)GetFuncAddress("glXCreateContextAttribsARB"); if (!glXCreateContextAttribs) { - ERROR_LOG(VIDEO, - "glXCreateContextAttribsARB not found, do you support GLX_ARB_create_context?"); + ERROR_LOG_FMT(VIDEO, + "glXCreateContextAttribsARB not found, do you support GLX_ARB_create_context?"); return false; } @@ -124,7 +131,7 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor GLXFBConfig* fbc = glXChooseFBConfig(m_display, screen, visual_attribs, &fbcount); if (!fbc || !fbcount) { - ERROR_LOG(VIDEO, "Failed to retrieve a framebuffer config"); + ERROR_LOG_FMT(VIDEO, "Failed to retrieve a framebuffer config"); return false; } m_fbconfig = *fbc; @@ -150,7 +157,8 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor continue; // Got a context. - INFO_LOG(VIDEO, "Created a GLX context with version %d.%d", version.first, version.second); + INFO_LOG_FMT(VIDEO, "Created a GLX context with version {}.{}", version.first, + version.second); m_attribs.insert(m_attribs.end(), context_attribs.begin(), context_attribs.end()); break; } @@ -169,7 +177,7 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor } if (!m_context || s_glxError) { - ERROR_LOG(VIDEO, "Unable to create GL context."); + ERROR_LOG_FMT(VIDEO, "Unable to create GL context."); XSetErrorHandler(oldHandler); return false; } @@ -206,7 +214,7 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor if (!CreateWindowSurface(reinterpret_cast<Window>(wsi.render_surface))) { - ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed\n"); + ERROR_LOG_FMT(VIDEO, "Error: CreateWindowSurface failed\n"); XSetErrorHandler(oldHandler); return false; } @@ -227,7 +235,7 @@ std::unique_ptr<GLContext> GLContextGLX::CreateSharedContext() if (!new_glx_context || s_glxError) { - ERROR_LOG(VIDEO, "Unable to create GL context."); + ERROR_LOG_FMT(VIDEO, "Unable to create GL context."); XSetErrorHandler(oldHandler); return nullptr; } @@ -242,7 +250,7 @@ std::unique_ptr<GLContext> GLContextGLX::CreateSharedContext() if (m_supports_pbuffer && !new_context->CreateWindowSurface(None)) { - ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed"); + ERROR_LOG_FMT(VIDEO, "Error: CreateWindowSurface failed"); XSetErrorHandler(oldHandler); return nullptr; } diff --git a/Source/Core/Common/GL/GLInterface/WGL.cpp b/Source/Core/Common/GL/GLInterface/WGL.cpp index 034d05a415..cf30dcf5e3 100644 --- a/Source/Core/Common/GL/GLInterface/WGL.cpp +++ b/Source/Core/Common/GL/GLInterface/WGL.cpp @@ -162,10 +162,10 @@ GLContextWGL::~GLContextWGL() if (m_rc) { if (wglGetCurrentContext() == m_rc && !wglMakeCurrent(m_dc, nullptr)) - NOTICE_LOG(VIDEO, "Could not release drawing context."); + NOTICE_LOG_FMT(VIDEO, "Could not release drawing context."); if (!wglDeleteContext(m_rc)) - ERROR_LOG(VIDEO, "Attempt to release rendering context failed."); + ERROR_LOG_FMT(VIDEO, "Attempt to release rendering context failed."); m_rc = nullptr; } @@ -183,7 +183,7 @@ GLContextWGL::~GLContextWGL() else { if (!ReleaseDC(m_window_handle, m_dc)) - ERROR_LOG(VIDEO, "Attempt to release device context failed."); + ERROR_LOG_FMT(VIDEO, "Attempt to release device context failed."); m_dc = nullptr; } @@ -198,9 +198,14 @@ bool GLContextWGL::IsHeadless() const void GLContextWGL::SwapInterval(int interval) { if (wglSwapIntervalEXT) + { wglSwapIntervalEXT(interval); + } else - ERROR_LOG(VIDEO, "No support for SwapInterval (framerate clamped to monitor refresh rate)."); + { + ERROR_LOG_FMT(VIDEO, + "No support for SwapInterval (framerate clamped to monitor refresh rate)."); + } } void GLContextWGL::Swap() { @@ -331,7 +336,7 @@ bool GLContextWGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor } else { - WARN_LOG(VIDEO, "Failed to create a core OpenGL context. Using fallback context."); + WARN_LOG_FMT(VIDEO, "Failed to create a core OpenGL context. Using fallback context."); } } @@ -367,7 +372,7 @@ HGLRC GLContextWGL::CreateCoreContext(HDC dc, HGLRC share_context) { if (!wglCreateContextAttribsARB) { - WARN_LOG(VIDEO, "Missing WGL_ARB_create_context extension"); + WARN_LOG_FMT(VIDEO, "Missing WGL_ARB_create_context extension"); return nullptr; } @@ -400,18 +405,18 @@ HGLRC GLContextWGL::CreateCoreContext(HDC dc, HGLRC share_context) { if (!wglShareLists(share_context, core_context)) { - ERROR_LOG(VIDEO, "wglShareLists failed"); + ERROR_LOG_FMT(VIDEO, "wglShareLists failed"); wglDeleteContext(core_context); return nullptr; } } - INFO_LOG(VIDEO, "WGL: Created a GL %d.%d core context", version.first, version.second); + INFO_LOG_FMT(VIDEO, "WGL: Created a GL {}.{} core context", version.first, version.second); return core_context; } } - WARN_LOG(VIDEO, "Unable to create a core OpenGL context of an acceptable version"); + WARN_LOG_FMT(VIDEO, "Unable to create a core OpenGL context of an acceptable version"); return nullptr; } @@ -421,7 +426,7 @@ bool GLContextWGL::CreatePBuffer(HDC onscreen_dc, int width, int height, HANDLE* if (!wglChoosePixelFormatARB || !wglCreatePbufferARB || !wglGetPbufferDCARB || !wglReleasePbufferDCARB || !wglDestroyPbufferARB) { - ERROR_LOG(VIDEO, "Missing WGL_ARB_pbuffer extension"); + ERROR_LOG_FMT(VIDEO, "Missing WGL_ARB_pbuffer extension"); return false; } @@ -448,7 +453,7 @@ bool GLContextWGL::CreatePBuffer(HDC onscreen_dc, int width, int height, HANDLE* if (!wglChoosePixelFormatARB(onscreen_dc, pf_iattribs.data(), pf_fattribs.data(), 1, &pixel_format, &num_pixel_formats)) { - ERROR_LOG(VIDEO, "Failed to obtain a compatible pbuffer pixel format"); + ERROR_LOG_FMT(VIDEO, "Failed to obtain a compatible pbuffer pixel format"); return false; } @@ -458,14 +463,14 @@ bool GLContextWGL::CreatePBuffer(HDC onscreen_dc, int width, int height, HANDLE* wglCreatePbufferARB(onscreen_dc, pixel_format, width, height, pb_attribs.data()); if (!pbuffer) { - ERROR_LOG(VIDEO, "Failed to create pbuffer"); + ERROR_LOG_FMT(VIDEO, "Failed to create pbuffer"); return false; } HDC dc = wglGetPbufferDCARB(pbuffer); if (!dc) { - ERROR_LOG(VIDEO, "Failed to get drawing context from pbuffer"); + ERROR_LOG_FMT(VIDEO, "Failed to get drawing context from pbuffer"); wglDestroyPbufferARB(pbuffer); return false; } |
