Humungous refactor

This commit is contained in:
Jack Andersen
2016-03-04 13:02:18 -10:00
parent 5c66d46cfe
commit 8ac929d140
19 changed files with 181 additions and 181 deletions

View File

@@ -16,7 +16,7 @@
#include "boo/IApplication.hpp"
#include "boo/inputdev/DeviceFinder.hpp"
#include "boo/graphicsdev/D3D.hpp"
#include <LogVisor/LogVisor.hpp>
#include "logvisor/logvisor.hpp"
DWORD g_mainThreadId = 0;
@@ -57,7 +57,7 @@ static bool FindBestD3DCompile()
namespace boo
{
static LogVisor::LogModule Log("boo::ApplicationWin32");
static logvisor::Module Log("boo::ApplicationWin32");
Win32Cursors WIN32_CURSORS;
IWindow* _WindowWin32New(const SystemString& title, Boo3DAppContext& d3dCtx, uint32_t sampleCount);
@@ -96,12 +96,12 @@ public:
{
HMODULE dxgilib = LoadLibraryW(L"dxgi.dll");
if (!dxgilib)
Log.report(LogVisor::FatalError, "unable to load dxgi.dll");
Log.report(logvisor::Fatal, "unable to load dxgi.dll");
typedef HRESULT(WINAPI*CreateDXGIFactory1PROC)(REFIID riid, _COM_Outptr_ void **ppFactory);
CreateDXGIFactory1PROC MyCreateDXGIFactory1 = (CreateDXGIFactory1PROC)GetProcAddress(dxgilib, "CreateDXGIFactory1");
if (!MyCreateDXGIFactory1)
Log.report(LogVisor::FatalError, "unable to find CreateDXGIFactory1 in DXGI.dll\n");
Log.report(logvisor::Fatal, "unable to find CreateDXGIFactory1 in DXGI.dll\n");
bool no12 = false;
bool noD3d = false;
@@ -129,7 +129,7 @@ public:
}
#endif
if (!FindBestD3DCompile())
Log.report(LogVisor::FatalError, "unable to find D3DCompile_[43-47].dll");
Log.report(logvisor::Fatal, "unable to find D3DCompile_[43-47].dll");
D3D12SerializeRootSignaturePROC =
(PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)GetProcAddress(d3d12lib, "D3D12SerializeRootSignature");
@@ -137,22 +137,22 @@ public:
/* Create device */
PFN_D3D12_CREATE_DEVICE MyD3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)GetProcAddress(d3d12lib, "D3D12CreateDevice");
if (!MyD3D12CreateDevice)
Log.report(LogVisor::FatalError, "unable to find D3D12CreateDevice in D3D12.dll");
Log.report(logvisor::Fatal, "unable to find D3D12CreateDevice in D3D12.dll");
/* Create device */
HRESULT hr = MyD3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_0, __uuidof(ID3D12Device), &m_3dCtx.m_ctx12.m_dev);
if (FAILED(hr))
Log.report(LogVisor::FatalError, "unable to create D3D12 device");
Log.report(logvisor::Fatal, "unable to create D3D12 device");
/* Obtain DXGI Factory */
hr = MyCreateDXGIFactory1(__uuidof(IDXGIFactory2), &m_3dCtx.m_ctx12.m_dxFactory);
if (FAILED(hr))
Log.report(LogVisor::FatalError, "unable to create DXGI factory");
Log.report(logvisor::Fatal, "unable to create DXGI factory");
/* Establish loader objects */
if (FAILED(m_3dCtx.m_ctx12.m_dev->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT,
__uuidof(ID3D12CommandAllocator), &m_3dCtx.m_ctx12.m_loadqalloc)))
Log.report(LogVisor::FatalError, "unable to create loader allocator");
Log.report(logvisor::Fatal, "unable to create loader allocator");
D3D12_COMMAND_QUEUE_DESC desc =
{
@@ -161,18 +161,18 @@ public:
D3D12_COMMAND_QUEUE_FLAG_NONE
};
if (FAILED(m_3dCtx.m_ctx12.m_dev->CreateCommandQueue(&desc, __uuidof(ID3D12CommandQueue), &m_3dCtx.m_ctx12.m_loadq)))
Log.report(LogVisor::FatalError, "unable to create loader queue");
Log.report(logvisor::Fatal, "unable to create loader queue");
if (FAILED(m_3dCtx.m_ctx12.m_dev->CreateFence(0, D3D12_FENCE_FLAG_NONE, __uuidof(ID3D12Fence), &m_3dCtx.m_ctx12.m_loadfence)))
Log.report(LogVisor::FatalError, "unable to create loader fence");
Log.report(logvisor::Fatal, "unable to create loader fence");
m_3dCtx.m_ctx12.m_loadfencehandle = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (FAILED(m_3dCtx.m_ctx12.m_dev->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_3dCtx.m_ctx12.m_loadqalloc.Get(),
nullptr, __uuidof(ID3D12GraphicsCommandList), &m_3dCtx.m_ctx12.m_loadlist)))
Log.report(LogVisor::FatalError, "unable to create loader list");
Log.report(logvisor::Fatal, "unable to create loader list");
Log.report(LogVisor::Info, "initialized D3D12 renderer");
Log.report(logvisor::Info, "initialized D3D12 renderer");
return;
}
#endif
@@ -180,12 +180,12 @@ public:
if (d3d11lib && !noD3d)
{
if (!FindBestD3DCompile())
Log.report(LogVisor::FatalError, "unable to find D3DCompile_[43-47].dll");
Log.report(logvisor::Fatal, "unable to find D3DCompile_[43-47].dll");
/* Create device proc */
PFN_D3D11_CREATE_DEVICE MyD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(d3d11lib, "D3D11CreateDevice");
if (!MyD3D11CreateDevice)
Log.report(LogVisor::FatalError, "unable to find D3D11CreateDevice in D3D11.dll");
Log.report(logvisor::Fatal, "unable to find D3D11CreateDevice in D3D11.dll");
/* Create device */
D3D_FEATURE_LEVEL level = D3D_FEATURE_LEVEL_11_0;
@@ -193,7 +193,7 @@ public:
ComPtr<ID3D11DeviceContext> tempCtx;
if (FAILED(MyD3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, D3D11_CREATE_DEVICE_FLAGS, &level,
1, D3D11_SDK_VERSION, &tempDev, nullptr, &tempCtx)))
Log.report(LogVisor::FatalError, "unable to create D3D11 device");
Log.report(logvisor::Fatal, "unable to create D3D11 device");
tempDev.As<ID3D11Device1>(&m_3dCtx.m_ctx11.m_dev);
tempCtx.As<ID3D11DeviceContext1>(&m_3dCtx.m_ctx11.m_devCtx);
@@ -211,7 +211,7 @@ public:
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
m_3dCtx.m_ctx11.m_dev->CreateSamplerState(&sampDesc, &m_3dCtx.m_ctx11.m_ss);
Log.report(LogVisor::Info, "initialized D3D11 renderer");
Log.report(logvisor::Info, "initialized D3D11 renderer");
return;
}
@@ -220,13 +220,13 @@ public:
/* Obtain DXGI Factory */
HRESULT hr = MyCreateDXGIFactory1(__uuidof(IDXGIFactory1), &m_3dCtx.m_ctxOgl.m_dxFactory);
if (FAILED(hr))
Log.report(LogVisor::FatalError, "unable to create DXGI factory");
Log.report(logvisor::Fatal, "unable to create DXGI factory");
Log.report(LogVisor::Info, "initialized OpenGL renderer");
Log.report(logvisor::Info, "initialized OpenGL renderer");
return;
}
Log.report(LogVisor::FatalError, "system doesn't support OGL, D3D11 or D3D12");
Log.report(logvisor::Fatal, "system doesn't support OGL, D3D11 or D3D12");
}
EPlatformType getPlatformType() const
@@ -365,7 +365,7 @@ public:
{
std::unique_lock<std::mutex> lk(m_nwmt);
if (!PostThreadMessage(g_mainThreadId, WM_USER, WPARAM(&title), 0))
Log.report(LogVisor::FatalError, "PostThreadMessage error");
Log.report(logvisor::Fatal, "PostThreadMessage error");
m_nwcv.wait(lk);
return m_mwret;
}

View File

@@ -2,7 +2,7 @@
#include <Windowsx.h>
#include "boo/IWindow.hpp"
#include "boo/IGraphicsContext.hpp"
#include <LogVisor/LogVisor.hpp>
#include "logvisor/logvisor.hpp"
#include "boo/graphicsdev/D3D.hpp"
#include "boo/graphicsdev/GL.hpp"
@@ -21,7 +21,7 @@ static const int ContextAttribs[] =
namespace boo
{
static LogVisor::LogModule Log("boo::WindowWin32");
static logvisor::Module Log("boo::WindowWin32");
#if _WIN32_WINNT_WIN10
IGraphicsCommandQueue* _NewD3D12CommandQueue(D3D12Context* ctx, D3D12Context::Window* windowCtx, IGraphicsContext* parent,
ID3D12CommandQueue** cmdQueueOut);
@@ -82,7 +82,7 @@ public:
HRESULT hr = b3dCtx.m_ctx12.m_dxFactory->CreateSwapChainForHwnd(cmdQueue,
hwnd, &scDesc, nullptr, nullptr, &m_swapChain);
if (FAILED(hr))
Log.report(LogVisor::FatalError, "unable to create swap chain");
Log.report(logvisor::Fatal, "unable to create swap chain");
b3dCtx.m_ctx12.m_dxFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);
m_swapChain.As<IDXGISwapChain3>(&w.m_swapChain);
@@ -94,14 +94,14 @@ public:
w.height = resDesc.Height;
if (FAILED(m_swapChain->GetContainingOutput(&m_output)))
Log.report(LogVisor::FatalError, "unable to get DXGI output");
Log.report(logvisor::Fatal, "unable to get DXGI output");
}
else
#endif
{
if (FAILED(b3dCtx.m_ctx11.m_dxFactory->CreateSwapChainForHwnd(b3dCtx.m_ctx11.m_dev.Get(),
hwnd, &scDesc, nullptr, nullptr, &m_swapChain)))
Log.report(LogVisor::FatalError, "unable to create swap chain");
Log.report(logvisor::Fatal, "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()));
@@ -118,7 +118,7 @@ public:
m_commandQueue = _NewD3D11CommandQueue(&b3dCtx.m_ctx11, &insIt.first->second, this);
if (FAILED(m_swapChain->GetContainingOutput(&m_output)))
Log.report(LogVisor::FatalError, "unable to get DXGI output");
Log.report(logvisor::Fatal, "unable to get DXGI output");
}
}
@@ -221,14 +221,14 @@ public:
}
if (!m_output)
Log.report(LogVisor::FatalError, "unable to find window's IDXGIOutput");
Log.report(logvisor::Fatal, "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::FatalError, "unable to create window's device context");
Log.report(logvisor::Fatal, "unable to create window's device context");
if (!m_3dCtx.m_ctxOgl.m_lastContext)
{
@@ -258,10 +258,10 @@ public:
w.m_mainContext = wglCreateContext(w.m_deviceContext);
if (!w.m_mainContext)
Log.report(LogVisor::FatalError, "unable to create window's main context");
Log.report(logvisor::Fatal, "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::FatalError, "unable to share contexts");
Log.report(logvisor::Fatal, "unable to share contexts");
m_3dCtx.m_ctxOgl.m_lastContext = w.m_mainContext;
m_dataFactory = new GLDataFactory(this, sampleCount);
@@ -301,7 +301,7 @@ public:
{
OGLContext::Window& w = m_3dCtx.m_ctxOgl.m_windows[m_parentWindow];
if (!wglMakeCurrent(w.m_deviceContext, w.m_mainContext))
Log.report(LogVisor::FatalError, "unable to make WGL context current");
Log.report(logvisor::Fatal, "unable to make WGL context current");
}
void postInit()
@@ -312,12 +312,12 @@ public:
wglGetProcAddress("wglCreateContextAttribsARB");
w.m_renderContext = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
if (!w.m_renderContext)
Log.report(LogVisor::FatalError, "unable to make new WGL context");
Log.report(logvisor::Fatal, "unable to make new WGL context");
if (!wglMakeCurrent(w.m_deviceContext, w.m_renderContext))
Log.report(LogVisor::FatalError, "unable to make WGL context current");
Log.report(logvisor::Fatal, "unable to make WGL context current");
if (!WGLEW_EXT_swap_control)
Log.report(LogVisor::FatalError, "WGL_EXT_swap_control not available");
Log.report(logvisor::Fatal, "WGL_EXT_swap_control not available");
wglSwapIntervalEXT(1);
}
@@ -346,10 +346,10 @@ public:
{
m_mainCtx = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
if (!m_mainCtx)
Log.report(LogVisor::FatalError, "unable to make main WGL context");
Log.report(logvisor::Fatal, "unable to make main WGL context");
}
if (!wglMakeCurrent(w.m_deviceContext, m_mainCtx))
Log.report(LogVisor::FatalError, "unable to make main WGL context current");
Log.report(logvisor::Fatal, "unable to make main WGL context current");
return m_dataFactory;
}
@@ -362,10 +362,10 @@ public:
{
m_loadCtx = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
if (!m_loadCtx)
Log.report(LogVisor::FatalError, "unable to make load WGL context");
Log.report(logvisor::Fatal, "unable to make load WGL context");
}
if (!wglMakeCurrent(w.m_deviceContext, m_loadCtx))
Log.report(LogVisor::FatalError, "unable to make load WGL context current");
Log.report(logvisor::Fatal, "unable to make load WGL context current");
return m_dataFactory;
}
};
@@ -581,7 +581,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::FatalError, "invalid UTF-8 char");
Log.report(logvisor::Fatal, "invalid UTF-8 char");
if (ch <= 0xffff)
{
if (ch == '\n' && lastCh != '\r')
@@ -855,7 +855,7 @@ public:
if (GetCurrentThreadId() != g_mainThreadId)
{
if (!PostThreadMessage(g_mainThreadId, WM_USER+3, WPARAM(m_imc), LPARAM(open)))
Log.report(LogVisor::FatalError, "PostThreadMessage error");
Log.report(logvisor::Fatal, "PostThreadMessage error");
return;
}
ImmSetOpenStatus(m_imc, open);
@@ -872,7 +872,7 @@ public:
if (GetCurrentThreadId() != g_mainThreadId)
{
if (!PostThreadMessage(g_mainThreadId, WM_USER+4, WPARAM(m_imc), LPARAM(&m_cForm)))
Log.report(LogVisor::FatalError, "PostThreadMessage error");
Log.report(logvisor::Fatal, "PostThreadMessage error");
return;
}
ImmSetCompositionWindow(m_imc, &m_cForm);