mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Common: Migrate logging to fmt
Continues the migration of our code over to the fmt logger.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user