Massive fmtlib refactor

This commit is contained in:
Jack Andersen
2019-07-19 18:22:36 -10:00
parent b2bf7549f5
commit deefc8e995
38 changed files with 364 additions and 400 deletions

View File

@@ -73,7 +73,7 @@ public:
scDesc.Format = b3dCtx.m_ctx11.m_fbFormat;
if (FAILED(b3dCtx.m_ctx11.m_dxFactory->CreateSwapChainForHwnd(b3dCtx.m_ctx11.m_dev.Get(), hwnd, &scDesc, nullptr,
nullptr, &m_swapChain)))
Log.report(logvisor::Fatal, "unable to create swap chain");
Log.report(logvisor::Fatal, fmt("unable to create swap chain"));
b3dCtx.m_ctx11.m_dxFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);
auto insIt = b3dCtx.m_ctx11.m_windows.emplace(std::make_pair(parentWindow, D3D11Context::Window()));
@@ -85,7 +85,7 @@ public:
m_commandQueue->startRenderer();
if (FAILED(m_swapChain->GetContainingOutput(&m_output)))
Log.report(logvisor::Fatal, "unable to get DXGI output");
Log.report(logvisor::Fatal, fmt("unable to get DXGI output"));
}
~GraphicsContextWin32D3D() { m_3dCtx.m_ctx11.m_windows.erase(m_parentWindow); }
@@ -151,14 +151,14 @@ public:
}
if (!m_output)
Log.report(logvisor::Fatal, "unable to find window's IDXGIOutput");
Log.report(logvisor::Fatal, fmt("unable to find window's IDXGIOutput"));
auto insIt = b3dCtx.m_ctxOgl.m_windows.emplace(std::make_pair(parentWindow, OGLContext::Window()));
OGLContext::Window& w = insIt.first->second;
w.m_hwnd = hwnd;
w.m_deviceContext = GetDC(hwnd);
if (!w.m_deviceContext)
Log.report(logvisor::Fatal, "unable to create window's device context");
Log.report(logvisor::Fatal, fmt("unable to create window's device context"));
if (!m_3dCtx.m_ctxOgl.m_lastContext) {
PIXELFORMATDESCRIPTOR pfd = {sizeof(PIXELFORMATDESCRIPTOR),
@@ -195,7 +195,7 @@ public:
HGLRC tmpCtx = wglCreateContext(w.m_deviceContext);
wglMakeCurrent(w.m_deviceContext, tmpCtx);
if (glewInit() != GLEW_OK)
Log.report(logvisor::Fatal, "glewInit failed");
Log.report(logvisor::Fatal, fmt("glewInit failed"));
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
wglMakeCurrent(w.m_deviceContext, 0);
@@ -238,10 +238,10 @@ public:
// w.m_mainContext = wglCreateContext(w.m_deviceContext);
w.m_mainContext = wglCreateContextAttribsARB(w.m_deviceContext, 0, ContextAttribs);
if (!w.m_mainContext)
Log.report(logvisor::Fatal, "unable to create window's main context");
Log.report(logvisor::Fatal, fmt("unable to create window's main context"));
if (m_3dCtx.m_ctxOgl.m_lastContext)
if (!wglShareLists(w.m_mainContext, m_3dCtx.m_ctxOgl.m_lastContext))
Log.report(logvisor::Fatal, "unable to share contexts");
Log.report(logvisor::Fatal, fmt("unable to share contexts"));
m_3dCtx.m_ctxOgl.m_lastContext = w.m_mainContext;
m_dataFactory = _NewGLDataFactory(this, &b3dCtx.m_ctxOgl.m_glCtx);
@@ -268,13 +268,13 @@ public:
void makeCurrent() {
OGLContext::Window& w = m_3dCtx.m_ctxOgl.m_windows[m_parentWindow];
// if (!wglMakeCurrent(w.m_deviceContext, w.m_mainContext))
// Log.report(logvisor::Fatal, "unable to make WGL context current");
// Log.report(logvisor::Fatal, fmt("unable to make WGL context current"));
w.m_renderContext = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
if (!w.m_renderContext)
Log.report(logvisor::Fatal, "unable to make new WGL context");
Log.report(logvisor::Fatal, fmt("unable to make new WGL context"));
if (!wglMakeCurrent(w.m_deviceContext, w.m_renderContext))
Log.report(logvisor::Fatal, "unable to make WGL context current");
Log.report(logvisor::Fatal, fmt("unable to make WGL context current"));
}
void postInit() {
@@ -284,12 +284,12 @@ public:
// wglGetProcAddress("wglCreateContextAttribsARB");
// w.m_renderContext = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
// if (!w.m_renderContext)
// Log.report(logvisor::Fatal, "unable to make new WGL context");
// Log.report(logvisor::Fatal, fmt("unable to make new WGL context"));
// if (!wglMakeCurrent(w.m_deviceContext, w.m_renderContext))
// Log.report(logvisor::Fatal, "unable to make WGL context current");
// Log.report(logvisor::Fatal, fmt("unable to make WGL context current"));
if (!WGLEW_EXT_swap_control)
Log.report(logvisor::Fatal, "WGL_EXT_swap_control not available");
Log.report(logvisor::Fatal, fmt("WGL_EXT_swap_control not available"));
wglSwapIntervalEXT(1);
}
@@ -309,10 +309,10 @@ public:
if (!m_mainCtx) {
m_mainCtx = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
if (!m_mainCtx)
Log.report(logvisor::Fatal, "unable to make main WGL context");
Log.report(logvisor::Fatal, fmt("unable to make main WGL context"));
}
if (!wglMakeCurrent(w.m_deviceContext, m_mainCtx))
Log.report(logvisor::Fatal, "unable to make main WGL context current");
Log.report(logvisor::Fatal, fmt("unable to make main WGL context current"));
return m_dataFactory.get();
}
@@ -323,10 +323,10 @@ public:
if (!m_loadCtx) {
m_loadCtx = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
if (!m_loadCtx)
Log.report(logvisor::Fatal, "unable to make load WGL context");
Log.report(logvisor::Fatal, fmt("unable to make load WGL context"));
}
if (!wglMakeCurrent(w.m_deviceContext, m_loadCtx))
Log.report(logvisor::Fatal, "unable to make load WGL context current");
Log.report(logvisor::Fatal, fmt("unable to make load WGL context current"));
return m_dataFactory.get();
}
};
@@ -348,7 +348,7 @@ struct GraphicsContextWin32Vulkan : GraphicsContextWin32 {
static void ThrowIfFailed(VkResult res) {
if (res != VK_SUCCESS)
Log.report(logvisor::Fatal, "%d\n", res);
Log.report(logvisor::Fatal, fmt("%d\n"), res);
}
public:
@@ -382,7 +382,7 @@ public:
}
if (!m_output)
Log.report(logvisor::Fatal, "unable to find window's IDXGIOutput");
Log.report(logvisor::Fatal, fmt("unable to find window's IDXGIOutput"));
}
void destroy() {
@@ -452,18 +452,18 @@ public:
/* Generate error if could not find a queue that supports both a graphics
* and present */
if (m_ctx->m_graphicsQueueFamilyIndex == UINT32_MAX)
Log.report(logvisor::Fatal, "Could not find a queue that supports both graphics and present");
Log.report(logvisor::Fatal, fmt("Could not find a queue that supports both graphics and present"));
m_ctx->initDevice();
} else {
/* Subsequent window, verify present */
if (supportsPresent[m_ctx->m_graphicsQueueFamilyIndex] == VK_FALSE)
Log.report(logvisor::Fatal, "subsequent surface doesn't support present");
Log.report(logvisor::Fatal, fmt("subsequent surface doesn't support present"));
}
free(supportsPresent);
if (!vk::GetPhysicalDeviceWin32PresentationSupportKHR(m_ctx->m_gpus[0], m_ctx->m_graphicsQueueFamilyIndex)) {
Log.report(logvisor::Fatal, "Win32 doesn't support vulkan present");
Log.report(logvisor::Fatal, fmt("Win32 doesn't support vulkan present"));
return false;
}
@@ -496,10 +496,10 @@ public:
}
}
} else
Log.report(logvisor::Fatal, "no surface formats available for Vulkan swapchain");
Log.report(logvisor::Fatal, fmt("no surface formats available for Vulkan swapchain"));
if (m_format == VK_FORMAT_UNDEFINED)
Log.report(logvisor::Fatal, "no UNORM formats available for Vulkan swapchain");
Log.report(logvisor::Fatal, fmt("no UNORM formats available for Vulkan swapchain"));
m_ctx->initSwapChain(*m_windowCtx, m_surface, m_format, m_colorspace);
@@ -724,7 +724,7 @@ static HGLOBAL MakeUnicodeCRLF(const char* data, size_t sz) {
int32_t ch;
int chSz = utf8proc_iterate(reinterpret_cast<const uint8_t*>(data + i), -1, &ch);
if (chSz < 0)
Log.report(logvisor::Fatal, "invalid UTF-8 char");
Log.report(logvisor::Fatal, fmt("invalid UTF-8 char"));
if (ch <= 0xffff) {
if (ch == '\n' && lastCh != '\r')
retSz += 4;
@@ -984,7 +984,7 @@ public:
void _immSetOpenStatus(bool open) {
if (GetCurrentThreadId() != g_mainThreadId) {
if (!PostThreadMessageW(g_mainThreadId, WM_USER + 3, WPARAM(m_imc), LPARAM(open)))
Log.report(logvisor::Fatal, "PostThreadMessage error");
Log.report(logvisor::Fatal, fmt("PostThreadMessage error"));
return;
}
ImmSetOpenStatus(m_imc, open);
@@ -999,7 +999,7 @@ public:
if (GetCurrentThreadId() != g_mainThreadId) {
if (!PostThreadMessageW(g_mainThreadId, WM_USER + 4, WPARAM(m_imc), LPARAM(&m_cForm)))
Log.report(logvisor::Fatal, "PostThreadMessage error");
Log.report(logvisor::Fatal, fmt("PostThreadMessage error"));
return;
}
ImmSetCompositionWindow(m_imc, &m_cForm);