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

@@ -1,5 +1,5 @@
#include "../win/Win32Common.hpp"
#include <LogVisor/LogVisor.hpp>
#include "logvisor/logvisor.hpp"
#include "boo/graphicsdev/D3D.hpp"
#include "boo/IGraphicsContext.hpp"
#include <vector>
@@ -19,7 +19,7 @@ extern pD3DCompile D3DCompilePROC;
namespace boo
{
static LogVisor::LogModule Log("boo::D3D11");
static logvisor::Module Log("boo::D3D11");
static inline void ThrowIfFailed(HRESULT hr)
{
@@ -28,7 +28,7 @@ static inline void ThrowIfFailed(HRESULT hr)
// Set a breakpoint on this line to catch Win32 API errors.
_com_error err(hr);
LPCTSTR errMsg = err.ErrorMessage();
Log.report(LogVisor::FatalError, errMsg);
Log.report(logvisor::Fatal, errMsg);
}
}
@@ -48,7 +48,7 @@ struct D3D11Data : IGraphicsData
bool decref()
{
if (!m_deleteCountdown)
Log.report(LogVisor::FatalError, "Can't decrement 0-data");
Log.report(logvisor::Fatal, "Can't decrement 0-data");
--m_deleteCountdown;
if (!m_deleteCountdown)
{
@@ -144,7 +144,7 @@ class D3D11TextureS : public ITextureS
pxPitchDenom = 2;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
CD3D11_TEXTURE2D_DESC desc(pfmt, width, height, 1, mips,
@@ -257,7 +257,7 @@ class D3D11TextureD : public ITextureD
pxPitch = 1;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
m_cpuSz = width * height * pxPitch;
@@ -567,7 +567,7 @@ struct D3D11ShaderDataBinding : IShaderDataBinding
{
#ifndef NDEBUG
if (!m_committed)
Log.report(LogVisor::FatalError,
Log.report(logvisor::Fatal,
"attempted to use uncommitted D3D11ShaderDataBinding");
#endif
@@ -1152,7 +1152,7 @@ public:
if (FAILED(D3DCompilePROC(vertSource, strlen(vertSource), "HECL Vert Source", nullptr, nullptr, "main",
"vs_5_0", BOO_D3DCOMPILE_FLAG, 0, &vertBlobOut, &errBlob)))
{
Log.report(LogVisor::FatalError, "error compiling vert shader: %s", errBlob->GetBufferPointer());
Log.report(logvisor::Fatal, "error compiling vert shader: %s", errBlob->GetBufferPointer());
return nullptr;
}
}
@@ -1162,7 +1162,7 @@ public:
if (FAILED(D3DCompilePROC(fragSource, strlen(fragSource), "HECL Pixel Source", nullptr, nullptr, "main",
"ps_5_0", BOO_D3DCOMPILE_FLAG, 0, &fragBlobOut, &errBlob)))
{
Log.report(LogVisor::FatalError, "error compiling pixel shader: %s", errBlob->GetBufferPointer());
Log.report(logvisor::Fatal, "error compiling pixel shader: %s", errBlob->GetBufferPointer());
return nullptr;
}
}

View File

@@ -1,6 +1,6 @@
#include "../win/Win32Common.hpp"
#if _WIN32_WINNT_WIN10
#include <LogVisor/LogVisor.hpp>
#include "logvisor/logvisor.hpp"
#include "boo/graphicsdev/D3D.hpp"
#include "boo/IGraphicsContext.hpp"
#include <vector>
@@ -21,7 +21,7 @@ extern pD3DCompile D3DCompilePROC;
namespace boo
{
static LogVisor::LogModule Log("boo::D3D12");
static logvisor::Module Log("boo::D3D12");
static inline void ThrowIfFailed(HRESULT hr)
{
@@ -30,7 +30,7 @@ static inline void ThrowIfFailed(HRESULT hr)
// Set a breakpoint on this line to catch Win32 API errors.
_com_error err(hr);
LPCTSTR errMsg = err.ErrorMessage();
Log.report(LogVisor::FatalError, errMsg);
Log.report(logvisor::Fatal, errMsg);
}
}
@@ -83,7 +83,7 @@ class D3D12GraphicsBufferS : public IGraphicsBufferS
D3D12_SUBRESOURCE_DATA upData = {data, LONG_PTR(m_sz), LONG_PTR(m_sz)};
if (!PrepSubresources<1>(ctx->m_dev.Get(), &m_gpuDesc, m_buf.Get(), 0, 0, 1, &upData))
Log.report(LogVisor::FatalError, "error preparing resource for upload");
Log.report(logvisor::Fatal, "error preparing resource for upload");
}
public:
size_t m_stride;
@@ -186,7 +186,7 @@ class D3D12TextureS : public ITextureS
pxPitchDenom = 2;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
@@ -210,7 +210,7 @@ class D3D12TextureS : public ITextureS
}
if (!PrepSubresources<16>(ctx->m_dev.Get(), &m_gpuDesc, m_tex.Get(), 0, 0, m_gpuDesc.MipLevels, upData))
Log.report(LogVisor::FatalError, "error preparing resource for upload");
Log.report(logvisor::Fatal, "error preparing resource for upload");
}
public:
ComPtr<ID3D12Resource> m_tex;
@@ -258,7 +258,7 @@ class D3D12TextureSA : public ITextureSA
pixelFmt = DXGI_FORMAT_R8_UNORM;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
m_gpuDesc = CD3DX12_RESOURCE_DESC::Tex2D(pixelFmt, width, height, layers, 1);
@@ -281,7 +281,7 @@ class D3D12TextureSA : public ITextureSA
dataIt += upData[i].SlicePitch;
}
if (!PrepSubresources(ctx->m_dev.Get(), &m_gpuDesc, m_tex.Get(), 0, 0, layers, upData.get()))
Log.report(LogVisor::FatalError, "error preparing resource for upload");
Log.report(logvisor::Fatal, "error preparing resource for upload");
}
else
{
@@ -294,7 +294,7 @@ class D3D12TextureSA : public ITextureSA
dataIt += upData[i].SlicePitch;
}
if (!PrepSubresources<16>(ctx->m_dev.Get(), &m_gpuDesc, m_tex.Get(), 0, 0, layers, upData))
Log.report(LogVisor::FatalError, "error preparing resource for upload");
Log.report(logvisor::Fatal, "error preparing resource for upload");
}
}
public:
@@ -353,7 +353,7 @@ class D3D12TextureD : public ITextureD
pixelFmt = DXGI_FORMAT_R8_UNORM;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
m_gpuDesc = CD3DX12_RESOURCE_DESC::Tex2D(pixelFmt, width, height);
@@ -958,7 +958,7 @@ struct D3D12ShaderDataBinding : IShaderDataBinding
{
#ifndef NDEBUG
if (!m_committed)
Log.report(LogVisor::FatalError,
Log.report(logvisor::Fatal,
"attempted to use uncommitted D3D12ShaderDataBinding");
#endif
@@ -1357,7 +1357,7 @@ void D3D12GraphicsBufferD::update(int b)
m_q->m_dynamicCmdList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(gpuRes,
m_state, D3D12_RESOURCE_STATE_COPY_DEST));
if (!UpdateSubresources<1>(m_q->m_dynamicCmdList.Get(), gpuRes, res, 0, 0, 1, &d))
Log.report(LogVisor::FatalError, "unable to update dynamic buffer data");
Log.report(logvisor::Fatal, "unable to update dynamic buffer data");
m_q->m_dynamicCmdList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(gpuRes,
D3D12_RESOURCE_STATE_COPY_DEST, m_state));
m_validSlots |= slot;
@@ -1393,7 +1393,7 @@ void D3D12TextureD::update(int b)
m_q->m_dynamicCmdList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(gpuRes,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_DEST));
if (!UpdateSubresources<1>(m_q->m_dynamicCmdList.Get(), gpuRes, res, 0, 0, 1, &d))
Log.report(LogVisor::FatalError, "unable to update dynamic texture data");
Log.report(logvisor::Fatal, "unable to update dynamic texture data");
m_q->m_dynamicCmdList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(gpuRes,
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE));
m_validSlots |= slot;
@@ -1600,7 +1600,7 @@ public:
if (FAILED(D3DCompilePROC(vertSource, strlen(vertSource), "HECL Vert Source", nullptr, nullptr, "main",
"vs_5_0", BOO_D3DCOMPILE_FLAG, 0, &vertBlobOut, &errBlob)))
{
Log.report(LogVisor::FatalError, "error compiling vert shader: %s", errBlob->GetBufferPointer());
Log.report(logvisor::Fatal, "error compiling vert shader: %s", errBlob->GetBufferPointer());
return nullptr;
}
}
@@ -1610,7 +1610,7 @@ public:
if (FAILED(D3DCompilePROC(fragSource, strlen(fragSource), "HECL Pixel Source", nullptr, nullptr, "main",
"ps_5_0", BOO_D3DCOMPILE_FLAG, 0, &fragBlobOut, &errBlob)))
{
Log.report(LogVisor::FatalError, "error compiling pixel shader: %s", errBlob->GetBufferPointer());
Log.report(logvisor::Fatal, "error compiling pixel shader: %s", errBlob->GetBufferPointer());
return nullptr;
}
}

View File

@@ -7,14 +7,14 @@
#include <condition_variable>
#include <array>
#include <LogVisor/LogVisor.hpp>
#include "logvisor/logvisor.hpp"
#undef min
#undef max
namespace boo
{
static LogVisor::LogModule Log("boo::GL");
static logvisor::Module Log("boo::GL");
ThreadLocalPtr<struct GLData> GLDataFactory::m_deferredData;
struct GLData : IGraphicsData
@@ -143,7 +143,7 @@ class GLTextureS : public ITextureS
compressed = true;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
if (compressed)
@@ -453,7 +453,7 @@ IShaderPipeline* GLDataFactory::newShaderPipeline
GLShaderPipeline shader;
if (!shader.initObjects())
{
Log.report(LogVisor::Error, "unable to create shader objects\n");
Log.report(logvisor::Error, "unable to create shader objects\n");
return nullptr;
}
shader.m_sfactor = BLEND_FACTOR_TABLE[int(srcFac)];
@@ -472,7 +472,7 @@ IShaderPipeline* GLDataFactory::newShaderPipeline
glGetShaderiv(shader.m_vert, GL_INFO_LOG_LENGTH, &logLen);
char* log = (char*)malloc(logLen);
glGetShaderInfoLog(shader.m_vert, logLen, nullptr, log);
Log.report(LogVisor::Error, "unable to compile vert source\n%s\n%s\n", log, vertSource);
Log.report(logvisor::Error, "unable to compile vert source\n%s\n%s\n", log, vertSource);
free(log);
return nullptr;
}
@@ -486,7 +486,7 @@ IShaderPipeline* GLDataFactory::newShaderPipeline
glGetShaderiv(shader.m_frag, GL_INFO_LOG_LENGTH, &logLen);
char* log = (char*)malloc(logLen);
glGetShaderInfoLog(shader.m_frag, logLen, nullptr, log);
Log.report(LogVisor::Error, "unable to compile frag source\n%s\n%s\n", log, fragSource);
Log.report(logvisor::Error, "unable to compile frag source\n%s\n%s\n", log, fragSource);
free(log);
return nullptr;
}
@@ -499,7 +499,7 @@ IShaderPipeline* GLDataFactory::newShaderPipeline
glGetProgramiv(shader.m_prog, GL_INFO_LOG_LENGTH, &logLen);
char* log = (char*)malloc(logLen);
glGetProgramInfoLog(shader.m_prog, logLen, nullptr, log);
Log.report(LogVisor::Error, "unable to link shader program\n%s\n", log);
Log.report(logvisor::Error, "unable to link shader program\n%s\n", log);
free(log);
return nullptr;
}
@@ -513,7 +513,7 @@ IShaderPipeline* GLDataFactory::newShaderPipeline
{
GLint uniLoc = glGetUniformBlockIndex(shader.m_prog, uniformBlockNames[i]);
if (uniLoc < 0)
Log.report(LogVisor::Error, "unable to find uniform block '%s'", uniformBlockNames[i]);
Log.report(logvisor::Error, "unable to find uniform block '%s'", uniformBlockNames[i]);
shader.m_uniLocs.push_back(uniLoc);
}
}
@@ -522,7 +522,7 @@ IShaderPipeline* GLDataFactory::newShaderPipeline
{
GLint texLoc = glGetUniformLocation(shader.m_prog, texArrayName);
if (texLoc < 0)
Log.report(LogVisor::Error, "unable to find sampler variable '%s'", texArrayName);
Log.report(logvisor::Error, "unable to find sampler variable '%s'", texArrayName);
else
{
if (texCount > m_texUnis.size())
@@ -585,7 +585,7 @@ struct GLShaderDataBinding : IShaderDataBinding
{
#ifndef NDEBUG
if (!m_committed)
Log.report(LogVisor::FatalError,
Log.report(logvisor::Fatal,
"attempted to use uncommitted GLShaderDataBinding");
#endif
@@ -874,9 +874,9 @@ struct GLCommandQueue : IGraphicsCommandQueue
std::unique_lock<std::mutex> lk(self->m_initmt);
self->m_parent->makeCurrent();
if (glewInit() != GLEW_OK)
Log.report(LogVisor::FatalError, "unable to init glew");
Log.report(logvisor::Fatal, "unable to init glew");
const GLubyte* version = glGetString(GL_VERSION);
Log.report(LogVisor::Info, "OpenGL Version: %s", version);
Log.report(logvisor::Info, "OpenGL Version: %s", version);
self->m_parent->postInit();
}
self->m_initcv.notify_one();
@@ -1290,7 +1290,7 @@ GLTextureD::GLTextureD(size_t width, size_t height, TextureFormat fmt)
pxPitch = 1;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
m_cpuSz = width * height * pxPitch;
m_cpuBuf.reset(new uint8_t[m_cpuSz]);

View File

@@ -1,16 +1,16 @@
#include "boo/graphicsdev/glxew.h"
#include <LogVisor/LogVisor.hpp>
#include "logvisor/logvisor.hpp"
namespace boo
{
static LogVisor::LogModule Log("boo::GLX");
static logvisor::Module Log("boo::GLX");
void GLXExtensionCheck()
{
if (!GLXEW_SGI_video_sync)
Log.report(LogVisor::FatalError, "GLX_SGI_video_sync not available");
Log.report(logvisor::Fatal, "GLX_SGI_video_sync not available");
if (!GLXEW_EXT_swap_control && !GLXEW_MESA_swap_control && !GLXEW_SGI_swap_control)
Log.report(LogVisor::FatalError, "swap_control not available");
Log.report(logvisor::Fatal, "swap_control not available");
}
void GLXEnableVSync(Display* disp, GLXWindow drawable)

View File

@@ -12,7 +12,7 @@
#include <SPIRV/disassemble.h>
#include "boo/graphicsdev/GLSLMacros.hpp"
#include <LogVisor/LogVisor.hpp>
#include "logvisor/logvisor.hpp"
#undef min
#undef max
@@ -214,19 +214,19 @@ static void init_resources(TBuiltInResource &Resources) {
namespace boo
{
static LogVisor::LogModule Log("boo::Vulkan");
static logvisor::Module Log("boo::Vulkan");
VulkanContext g_VulkanContext;
static inline void ThrowIfFailed(VkResult res)
{
if (res != VK_SUCCESS)
Log.report(LogVisor::FatalError, "%d\n", res);
Log.report(logvisor::Fatal, "%d\n", res);
}
static inline void ThrowIfFalse(bool res)
{
if (!res)
Log.report(LogVisor::FatalError, "operation failed\n", res);
Log.report(logvisor::Fatal, "operation failed\n", res);
}
static VKAPI_ATTR VkBool32 VKAPI_CALL
@@ -235,15 +235,15 @@ dbgFunc(VkDebugReportFlagsEXT msgFlags, VkDebugReportObjectTypeEXT objType,
const char *pLayerPrefix, const char *pMsg, void *pUserData)
{
if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
Log.report(LogVisor::FatalError, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Fatal, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
} else if (msgFlags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
Log.report(LogVisor::Warning, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Warning, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
} else if (msgFlags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) {
Log.report(LogVisor::Warning, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Warning, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
} else if (msgFlags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) {
Log.report(LogVisor::Info, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Info, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
} else if (msgFlags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
Log.report(LogVisor::Info, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Info, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
}
/*
@@ -373,7 +373,7 @@ static void demo_check_layers(const std::vector<VulkanContext::LayerProperties>&
}
}
if (!found) {
Log.report(LogVisor::FatalError, "Cannot find layer: %s", layerNames[i]);
Log.report(logvisor::Fatal, "Cannot find layer: %s", layerNames[i]);
}
}
}
@@ -381,7 +381,7 @@ static void demo_check_layers(const std::vector<VulkanContext::LayerProperties>&
void VulkanContext::initVulkan(const char* appName)
{
if (!glslang::InitializeProcess())
Log.report(LogVisor::FatalError, "unable to initialize glslang");
Log.report(logvisor::Fatal, "unable to initialize glslang");
uint32_t instanceLayerCount;
VkLayerProperties* vkProps = nullptr;
@@ -482,7 +482,7 @@ void VulkanContext::initVulkan(const char* appName)
PFN_vkCreateDebugReportCallbackEXT createDebugReportCallback =
(PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(m_instance, "vkCreateDebugReportCallbackEXT");
if (!createDebugReportCallback)
Log.report(LogVisor::FatalError, "GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function.");
Log.report(logvisor::Fatal, "GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function.");
VkDebugReportCallbackCreateInfoEXT debugCreateInfo = {};
debugCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
@@ -516,7 +516,7 @@ void VulkanContext::initVulkan(const char* appName)
void VulkanContext::initDevice()
{
if (m_graphicsQueueFamilyIndex == UINT32_MAX)
Log.report(LogVisor::FatalError,
Log.report(logvisor::Fatal,
"VulkanContext::m_graphicsQueueFamilyIndex hasn't been initialized");
/* create the device */
@@ -909,7 +909,7 @@ class VulkanTextureS : public ITextureS
pxPitchDenom = 2;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
m_vkFmt = pfmt;
@@ -1145,7 +1145,7 @@ class VulkanTextureSA : public ITextureSA
pfmt = VK_FORMAT_R8_UNORM;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
m_vkFmt = pfmt;
@@ -1371,7 +1371,7 @@ class VulkanTextureD : public ITextureD
m_cpuSz = m_srcRowPitch * height;
break;
default:
Log.report(LogVisor::FatalError, "unsupported tex format");
Log.report(logvisor::Fatal, "unsupported tex format");
}
m_cpuBuf.reset(new uint8_t[m_cpuSz]);
@@ -2190,7 +2190,7 @@ struct VulkanShaderDataBinding : IShaderDataBinding
{
#ifndef NDEBUG
if (!m_committed)
Log.report(LogVisor::FatalError,
Log.report(logvisor::Fatal,
"attempted to use uncommitted VulkanShaderDataBinding");
#endif
@@ -2878,7 +2878,7 @@ IShaderPipeline* VulkanDataFactory::newShaderPipeline
vs.setStrings(&vertSource, 1);
if (!vs.parse(&DefaultBuiltInResource, 110, false, messages))
{
Log.report(LogVisor::FatalError, "unable to compile vertex shader\n%s", vs.getInfoLog());
Log.report(logvisor::Fatal, "unable to compile vertex shader\n%s", vs.getInfoLog());
return nullptr;
}
@@ -2886,7 +2886,7 @@ IShaderPipeline* VulkanDataFactory::newShaderPipeline
fs.setStrings(&fragSource, 1);
if (!fs.parse(&DefaultBuiltInResource, 110, false, messages))
{
Log.report(LogVisor::FatalError, "unable to compile fragment shader\n%s", fs.getInfoLog());
Log.report(logvisor::Fatal, "unable to compile fragment shader\n%s", fs.getInfoLog());
return nullptr;
}
@@ -2895,7 +2895,7 @@ IShaderPipeline* VulkanDataFactory::newShaderPipeline
prog.addShader(&fs);
if (!prog.link(messages))
{
Log.report(LogVisor::FatalError, "unable to link shader program\n%s", prog.getInfoLog());
Log.report(logvisor::Fatal, "unable to link shader program\n%s", prog.getInfoLog());
return nullptr;
}
glslang::GlslangToSpv(*prog.getIntermediate(EShLangVertex), vertBlobOut);