From 8ac929d140d25f9e6ba267a1a9b0a9a57fd81295 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 4 Mar 2016 13:02:18 -1000 Subject: [PATCH] Humungous refactor --- .gitmodules | 6 +- CMakeLists.txt | 18 +++--- include/boo/audiodev/IAudioVoiceAllocator.hpp | 2 +- lib/audiodev/ALSA.cpp | 12 ++-- lib/audiodev/AQS.cpp | 12 ++-- lib/audiodev/XAudio2.cpp | 14 ++--- lib/graphicsdev/D3D11.cpp | 18 +++--- lib/graphicsdev/D3D12.cpp | 30 ++++----- lib/graphicsdev/GL.cpp | 26 ++++---- lib/graphicsdev/GLX.cpp | 8 +-- lib/graphicsdev/Vulkan.cpp | 40 ++++++------ lib/win/ApplicationWin32.cpp | 42 ++++++------- lib/win/WindowWin32.cpp | 42 ++++++------- lib/x11/ApplicationXlib.hpp | 18 +++--- lib/x11/WindowXlib.cpp | 62 +++++++++---------- log-visor | 1 - logvisor | 1 + test/CMakeLists.txt | 2 +- test/main.cpp | 8 +-- 19 files changed, 181 insertions(+), 181 deletions(-) delete mode 160000 log-visor create mode 160000 logvisor diff --git a/.gitmodules b/.gitmodules index a42a362..a77cd6a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "glslang"] path = glslang url = https://github.com/AxioDL/glslang.git -[submodule "log-visor"] - path = log-visor - url = https://github.com/AxioDL/log-visor.git +[submodule "logvisor"] + path = logvisor + url = https://github.com/AxioDL/logvisor.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 944eeeb..1f4f570 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,17 @@ cmake_minimum_required(VERSION 3.0) -project(libBoo) +project(boo) if (NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") endif() -if (NOT TARGET LogVisor) - add_subdirectory(LogVisor) +if (NOT TARGET logvisor) + add_subdirectory(logvisor) endif() -set(BOO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE PATH "libBoo include path" FORCE) +set(BOO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE PATH "boo include path" FORCE) -include_directories(include ${LOG_VISOR_INCLUDE_DIR}) +include_directories(include ${LOGVISOR_INCLUDE_DIR}) if(NOT GEKKO AND NOT CAFE) list(APPEND PLAT_SRCS @@ -120,7 +120,7 @@ else(NOT GEKKO) lib64) if(DBUS_INCLUDE_DIR-NOTFOUND) - message(FATAL_ERROR "Unix build of libBoo requires dbus") + message(FATAL_ERROR "Unix build of boo requires dbus") endif() include_directories(${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR}) @@ -158,13 +158,13 @@ add_subdirectory(glslang/OGLCompilersDLL) add_subdirectory(glslang/SPIRV) list(APPEND _BOO_SYS_LIBS glslang OSDependent OGLCompiler SPIRV) -set(BOO_SYS_LIBS ${_BOO_SYS_LIBS} CACHE PATH "Boo System Libraries" FORCE) -set(BOO_SYS_DEFINES ${_BOO_SYS_DEFINES} CACHE PATH "Boo System Defines" FORCE) +set(BOO_SYS_LIBS ${_BOO_SYS_LIBS} CACHE PATH "boo system libraries" FORCE) +set(BOO_SYS_DEFINES ${_BOO_SYS_DEFINES} CACHE PATH "boo system defines" FORCE) add_definitions(${_BOO_SYS_DEFINES}) include_directories(include glslang) -add_library(Boo +add_library(boo lib/inputdev/CafeProPad.cpp include/boo/inputdev/CafeProPad.hpp lib/inputdev/RevolutionPad.cpp include/boo/inputdev/RevolutionPad.hpp lib/inputdev/DolphinSmashAdapter.cpp include/boo/inputdev/DolphinSmashAdapter.hpp diff --git a/include/boo/audiodev/IAudioVoiceAllocator.hpp b/include/boo/audiodev/IAudioVoiceAllocator.hpp index 7f83a3c..f279b11 100644 --- a/include/boo/audiodev/IAudioVoiceAllocator.hpp +++ b/include/boo/audiodev/IAudioVoiceAllocator.hpp @@ -9,7 +9,7 @@ namespace boo struct IAudioVoiceCallback { - /** Boo calls this on behalf of the audio platform to request more audio + /** boo calls this on behalf of the audio platform to request more audio * frames from the client */ virtual void needsNextBuffer(IAudioVoice* voice, size_t frames)=0; }; diff --git a/lib/audiodev/ALSA.cpp b/lib/audiodev/ALSA.cpp index 181dce4..7067453 100644 --- a/lib/audiodev/ALSA.cpp +++ b/lib/audiodev/ALSA.cpp @@ -1,11 +1,11 @@ #include "boo/audiodev/IAudioVoiceAllocator.hpp" -#include +#include "logvisor/logvisor.hpp" #include namespace boo { -static LogVisor::LogModule Log("boo::ALSA"); +static logvisor::Module Log("boo::ALSA"); struct ALSAAudioVoice : IAudioVoice { @@ -29,7 +29,7 @@ struct ALSAAudioVoice : IAudioVoice { if (snd_pcm_open(&m_pcm, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_ASYNC) < 0) { - Log.report(LogVisor::Error, "unable to allocate ALSA voice"); + Log.report(logvisor::Error, "unable to allocate ALSA voice"); return; } @@ -47,7 +47,7 @@ struct ALSAAudioVoice : IAudioVoice { snd_pcm_close(m_pcm); m_pcm = nullptr; - Log.report(LogVisor::Error, "unable to set ALSA voice params"); + Log.report(logvisor::Error, "unable to set ALSA voice params"); return; } @@ -56,7 +56,7 @@ struct ALSAAudioVoice : IAudioVoice { snd_pcm_close(m_pcm); m_pcm = nullptr; - Log.report(LogVisor::Error, "unable to query ALSA voice chmaps"); + Log.report(logvisor::Error, "unable to query ALSA voice chmaps"); return; } snd_pcm_chmap_t* foundChmap = nullptr; @@ -119,7 +119,7 @@ struct ALSAAudioVoice : IAudioVoice snd_pcm_close(m_pcm); m_pcm = nullptr; snd_pcm_free_chmaps(chmaps); - Log.report(LogVisor::Error, "unable to find matching ALSA voice chmap"); + Log.report(logvisor::Error, "unable to find matching ALSA voice chmap"); return; } m_map.m_channelCount = chCount; diff --git a/lib/audiodev/AQS.cpp b/lib/audiodev/AQS.cpp index f638745..a5ba772 100644 --- a/lib/audiodev/AQS.cpp +++ b/lib/audiodev/AQS.cpp @@ -1,11 +1,11 @@ #include "boo/audiodev/IAudioVoiceAllocator.hpp" -#include +#include "logvisor/logvisor.hpp" #include namespace boo { -static LogVisor::LogModule Log("boo::AQS"); +static logvisor::Module Log("boo::AQS"); static AudioChannel AQSChannelToBooChannel(AudioChannelLabel ch) { @@ -80,7 +80,7 @@ struct AQSAudioVoice : IAudioVoice } if (err) { - Log.report(LogVisor::Error, "unable to create output audio queue"); + Log.report(logvisor::Error, "unable to create output audio queue"); return; } @@ -88,7 +88,7 @@ struct AQSAudioVoice : IAudioVoice UInt32 layoutSz = sizeof(layout); if (AudioQueueGetProperty(m_queue, kAudioQueueProperty_ChannelLayout, &layout, &layoutSz)) { - Log.report(LogVisor::Error, "unable to get channel layout from audio queue"); + Log.report(logvisor::Error, "unable to get channel layout from audio queue"); return; } @@ -142,7 +142,7 @@ struct AQSAudioVoice : IAudioVoice m_map.m_channels[4] = AudioChannel::FrontCenter; break; default: - Log.report(LogVisor::Error, "unknown channel layout %u; using stereo", layout.mChannelLayoutTag); + Log.report(logvisor::Error, "unknown channel layout %u; using stereo", layout.mChannelLayoutTag); m_map.m_channelCount = 2; m_map.m_channels[0] = AudioChannel::FrontLeft; m_map.m_channels[1] = AudioChannel::FrontRight; @@ -155,7 +155,7 @@ struct AQSAudioVoice : IAudioVoice for (int i=0 ; i<3 ; ++i) if (AudioQueueAllocateBuffer(m_queue, m_bufferFrames * chCount * 2, &m_buffers[i])) { - Log.report(LogVisor::Error, "unable to create audio queue buffer"); + Log.report(logvisor::Error, "unable to create audio queue buffer"); AudioQueueDispose(m_queue, false); m_queue = nullptr; return; diff --git a/lib/audiodev/XAudio2.cpp b/lib/audiodev/XAudio2.cpp index cf4e435..3f9e6bd 100644 --- a/lib/audiodev/XAudio2.cpp +++ b/lib/audiodev/XAudio2.cpp @@ -1,12 +1,12 @@ #include "../win/Win32Common.hpp" #include "boo/audiodev/IAudioVoiceAllocator.hpp" -#include +#include "logvisor/logvisor.hpp" #include namespace boo { -static LogVisor::LogModule Log("boo::XAudio2"); +static logvisor::Module Log("boo::XAudio2"); struct XA2AudioVoice : IAudioVoice { @@ -52,7 +52,7 @@ struct XA2AudioVoice : IAudioVoice if FAILED(xa2.CreateSourceVoice(&m_voiceQueue, &desc, 0, XAUDIO2_DEFAULT_FREQ_RATIO, &m_xaCb)) { - Log.report(LogVisor::Error, "unable to create source voice"); + Log.report(logvisor::Error, "unable to create source voice"); return; } @@ -101,7 +101,7 @@ struct XA2AudioVoice : IAudioVoice m_map.m_channels[7] = AudioChannel::SideRight; break; default: - Log.report(LogVisor::Error, "unknown channel layout %u; using stereo", voxDetails.InputChannels); + Log.report(logvisor::Error, "unknown channel layout %u; using stereo", voxDetails.InputChannels); m_map.m_channelCount = 2; m_map.m_channels[0] = AudioChannel::FrontLeft; m_map.m_channels[1] = AudioChannel::FrontRight; @@ -153,18 +153,18 @@ struct XA2AudioVoiceAllocator : IAudioVoiceAllocator { if (FAILED(XAudio2Create(&m_xa2))) { - Log.report(LogVisor::Error, "Unable to initialize XAudio2"); + Log.report(logvisor::Error, "Unable to initialize XAudio2"); return; } if (FAILED(m_xa2->CreateMasteringVoice(&m_masterVoice))) { - Log.report(LogVisor::Error, "Unable to initialize XAudio2 mastering voice"); + Log.report(logvisor::Error, "Unable to initialize XAudio2 mastering voice"); return; } DWORD channelMask; if (FAILED(m_masterVoice->GetChannelMask(&channelMask))) { - Log.report(LogVisor::Error, "Unable to get mastering voice's channel mask"); + Log.report(logvisor::Error, "Unable to get mastering voice's channel mask"); return; } if ((channelMask & (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT)) == (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT)) diff --git a/lib/graphicsdev/D3D11.cpp b/lib/graphicsdev/D3D11.cpp index acb7a77..2cb0efe 100644 --- a/lib/graphicsdev/D3D11.cpp +++ b/lib/graphicsdev/D3D11.cpp @@ -1,5 +1,5 @@ #include "../win/Win32Common.hpp" -#include +#include "logvisor/logvisor.hpp" #include "boo/graphicsdev/D3D.hpp" #include "boo/IGraphicsContext.hpp" #include @@ -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; } } diff --git a/lib/graphicsdev/D3D12.cpp b/lib/graphicsdev/D3D12.cpp index 89ba5f6..f03e366 100644 --- a/lib/graphicsdev/D3D12.cpp +++ b/lib/graphicsdev/D3D12.cpp @@ -1,6 +1,6 @@ #include "../win/Win32Common.hpp" #if _WIN32_WINNT_WIN10 -#include +#include "logvisor/logvisor.hpp" #include "boo/graphicsdev/D3D.hpp" #include "boo/IGraphicsContext.hpp" #include @@ -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 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; } } diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index 5412b42..e5ed840 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -7,14 +7,14 @@ #include #include -#include +#include "logvisor/logvisor.hpp" #undef min #undef max namespace boo { -static LogVisor::LogModule Log("boo::GL"); +static logvisor::Module Log("boo::GL"); ThreadLocalPtr 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 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]); diff --git a/lib/graphicsdev/GLX.cpp b/lib/graphicsdev/GLX.cpp index 345c0e1..7191805 100644 --- a/lib/graphicsdev/GLX.cpp +++ b/lib/graphicsdev/GLX.cpp @@ -1,16 +1,16 @@ #include "boo/graphicsdev/glxew.h" -#include +#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) diff --git a/lib/graphicsdev/Vulkan.cpp b/lib/graphicsdev/Vulkan.cpp index 7be6086..96fffdf 100644 --- a/lib/graphicsdev/Vulkan.cpp +++ b/lib/graphicsdev/Vulkan.cpp @@ -12,7 +12,7 @@ #include #include "boo/graphicsdev/GLSLMacros.hpp" -#include +#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& } } 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& 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); diff --git a/lib/win/ApplicationWin32.cpp b/lib/win/ApplicationWin32.cpp index 566321b..7539da7 100644 --- a/lib/win/ApplicationWin32.cpp +++ b/lib/win/ApplicationWin32.cpp @@ -16,7 +16,7 @@ #include "boo/IApplication.hpp" #include "boo/inputdev/DeviceFinder.hpp" #include "boo/graphicsdev/D3D.hpp" -#include +#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 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(&m_3dCtx.m_ctx11.m_dev); tempCtx.As(&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 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; } diff --git a/lib/win/WindowWin32.cpp b/lib/win/WindowWin32.cpp index 35aa43b..1854cc4 100644 --- a/lib/win/WindowWin32.cpp +++ b/lib/win/WindowWin32.cpp @@ -2,7 +2,7 @@ #include #include "boo/IWindow.hpp" #include "boo/IGraphicsContext.hpp" -#include +#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(&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(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); diff --git a/lib/x11/ApplicationXlib.hpp b/lib/x11/ApplicationXlib.hpp index 467a4b9..77ea15b 100644 --- a/lib/x11/ApplicationXlib.hpp +++ b/lib/x11/ApplicationXlib.hpp @@ -14,7 +14,7 @@ #include DBusConnection* RegisterDBus(const char* appName, bool& isFirst); -#include +#include "logvisor/logvisor.hpp" #include #include @@ -31,7 +31,7 @@ DBusConnection* RegisterDBus(const char* appName, bool& isFirst); namespace boo { -static LogVisor::LogModule Log("boo::ApplicationXlib"); +static logvisor::Module Log("boo::ApplicationXlib"); XlibCursors X_CURSORS; int XINPUT_OPCODE = 0; @@ -245,13 +245,13 @@ public: if (!XInitThreads()) { - Log.report(LogVisor::FatalError, "X doesn't support multithreading"); + Log.report(logvisor::Fatal, "X doesn't support multithreading"); return; } if (setlocale(LC_ALL, "") == nullptr) { - Log.report(LogVisor::FatalError, "Can't setlocale"); + Log.report(logvisor::Fatal, "Can't setlocale"); return; } @@ -259,7 +259,7 @@ public: m_xDisp = XOpenDisplay(0); if (!m_xDisp) { - Log.report(LogVisor::FatalError, "Can't open X display"); + Log.report(logvisor::Fatal, "Can't open X display"); return; } @@ -268,19 +268,19 @@ public: m_xcbConn = XGetXCBConnection(m_xDisp); if (!m_xcbConn) { - Log.report(LogVisor::FatalError, "Can't cast Display to XCB connection for Vulkan"); + Log.report(logvisor::Fatal, "Can't cast Display to XCB connection for Vulkan"); return; } #endif /* Configure locale */ if (!XSupportsLocale()) { - Log.report(LogVisor::FatalError, "X does not support locale %s.", + Log.report(logvisor::Fatal, "X does not support locale %s.", setlocale(LC_ALL, nullptr)); return; } if (XSetLocaleModifiers("") == nullptr) - Log.report(LogVisor::Warning, "Cannot set locale modifiers."); + Log.report(logvisor::Warning, "Cannot set locale modifiers."); if ((m_xIM = XOpenIM(m_xDisp, nullptr, nullptr, nullptr))) { @@ -313,7 +313,7 @@ public: /* if we couldn't support any of them, print an error and exit */ if (m_bestStyle == 0) { - Log.report(LogVisor::FatalError, "interaction style not supported."); + Log.report(logvisor::Fatal, "interaction style not supported."); return; } XFree(im_supported_styles); diff --git a/lib/x11/WindowXlib.cpp b/lib/x11/WindowXlib.cpp index b5b257c..25e3b4c 100644 --- a/lib/x11/WindowXlib.cpp +++ b/lib/x11/WindowXlib.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include "logvisor/logvisor.hpp" #include "XlibCommon.hpp" @@ -111,7 +111,7 @@ const size_t MAINICON_NETWM_SZ __attribute__ ((weak)) = 0; namespace boo { -static LogVisor::LogModule Log("boo::WindowXlib"); +static logvisor::Module Log("boo::WindowXlib"); IGraphicsCommandQueue* _NewGLCommandQueue(IGraphicsContext* parent); #if BOO_HAS_VULKAN IGraphicsCommandQueue* _NewVulkanCommandQueue(VulkanContext* ctx, @@ -332,7 +332,7 @@ public: fbConfigs = glXGetFBConfigs(display, defaultScreen, &numFBConfigs); if (!fbConfigs || numFBConfigs == 0) { - Log.report(LogVisor::FatalError, "glXGetFBConfigs failed"); + Log.report(logvisor::Fatal, "glXGetFBConfigs failed"); return; } @@ -378,7 +378,7 @@ public: if (!m_fbconfig) { - Log.report(LogVisor::FatalError, "unable to find suitable pixel format"); + Log.report(logvisor::Fatal, "unable to find suitable pixel format"); return; } @@ -440,14 +440,14 @@ public: glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB((const GLubyte*)"glXCreateContextAttribsARB"); if (!glXCreateContextAttribsARB) - Log.report(LogVisor::FatalError, "unable to resolve glXCreateContextAttribsARB"); + Log.report(logvisor::Fatal, "unable to resolve glXCreateContextAttribsARB"); } if (!glXWaitVideoSyncSGI) { glXWaitVideoSyncSGI = (glXWaitVideoSyncSGIProc) glXGetProcAddressARB((const GLubyte*)"glXWaitVideoSyncSGI"); if (!glXWaitVideoSyncSGI) - Log.report(LogVisor::FatalError, "unable to resolve glXWaitVideoSyncSGI"); + Log.report(logvisor::Fatal, "unable to resolve glXWaitVideoSyncSGI"); } s_glxError = false; @@ -460,10 +460,10 @@ public: } XSetErrorHandler(oldHandler); if (!m_glxCtx) - Log.report(LogVisor::FatalError, "unable to make new GLX context"); + Log.report(logvisor::Fatal, "unable to make new GLX context"); m_glxWindow = glXCreateWindow(m_xDisp, m_fbconfig, m_parentWindow->getPlatformHandle(), nullptr); if (!m_glxWindow) - Log.report(LogVisor::FatalError, "unable to make new GLX window"); + Log.report(logvisor::Fatal, "unable to make new GLX window"); _XlibUpdateLastGlxCtx(m_glxCtx); /* Spawn vsync thread */ @@ -480,7 +480,7 @@ public: vsyncDisp = XOpenDisplay(0); if (!vsyncDisp) - Log.report(LogVisor::FatalError, "unable to open new vsync display"); + Log.report(logvisor::Fatal, "unable to open new vsync display"); XLockDisplay(vsyncDisp); static int attributeList[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, 0 }; @@ -488,10 +488,10 @@ public: vsyncCtx = glXCreateContext(vsyncDisp, vi, nullptr, True); if (!vsyncCtx) - Log.report(LogVisor::FatalError, "unable to make new vsync GLX context"); + Log.report(logvisor::Fatal, "unable to make new vsync GLX context"); if (!glXMakeCurrent(vsyncDisp, DefaultRootWindow(vsyncDisp), vsyncCtx)) - Log.report(LogVisor::FatalError, "unable to make vsync context current"); + Log.report(logvisor::Fatal, "unable to make vsync context current"); } initcv.notify_one(); @@ -500,7 +500,7 @@ public: unsigned int sync; int err = glXWaitVideoSyncSGI(1, 0, &sync); if (err) - Log.report(LogVisor::FatalError, "wait err"); + Log.report(logvisor::Fatal, "wait err"); m_vsynccv.notify_one(); } @@ -520,7 +520,7 @@ public: { XLockDisplay(m_xDisp); if (!glXMakeContextCurrent(m_xDisp, m_glxWindow, m_glxWindow, m_glxCtx)) - Log.report(LogVisor::FatalError, "unable to make GLX context current"); + Log.report(logvisor::Fatal, "unable to make GLX context current"); XUnlockDisplay(m_xDisp); } @@ -557,10 +557,10 @@ public: } XSetErrorHandler(oldHandler); if (!m_mainCtx) - Log.report(LogVisor::FatalError, "unable to make main GLX context"); + Log.report(logvisor::Fatal, "unable to make main GLX context"); } if (!glXMakeContextCurrent(m_xDisp, m_glxWindow, m_glxWindow, m_mainCtx)) - Log.report(LogVisor::FatalError, "unable to make main GLX context current"); + Log.report(logvisor::Fatal, "unable to make main GLX context current"); XUnlockDisplay(m_xDisp); return getDataFactory(); } @@ -580,10 +580,10 @@ public: } XSetErrorHandler(oldHandler); if (!m_loadCtx) - Log.report(LogVisor::FatalError, "unable to make load GLX context"); + Log.report(logvisor::Fatal, "unable to make load GLX context"); } if (!glXMakeContextCurrent(m_xDisp, m_glxWindow, m_glxWindow, m_loadCtx)) - Log.report(LogVisor::FatalError, "unable to make load GLX context current"); + Log.report(logvisor::Fatal, "unable to make load GLX context current"); XUnlockDisplay(m_xDisp); return getDataFactory(); } @@ -613,7 +613,7 @@ struct GraphicsContextXlibVulkan : GraphicsContextXlib static void ThrowIfFailed(VkResult res) { if (res != VK_SUCCESS) - Log.report(LogVisor::FatalError, "%d\n", res); + Log.report(logvisor::Fatal, "%d\n", res); } public: @@ -631,7 +631,7 @@ public: fbConfigs = glXGetFBConfigs(display, defaultScreen, &numFBConfigs); if (!fbConfigs || numFBConfigs == 0) { - Log.report(LogVisor::FatalError, "glXGetFBConfigs failed"); + Log.report(logvisor::Fatal, "glXGetFBConfigs failed"); return; } @@ -677,7 +677,7 @@ public: if (!m_fbconfig) { - Log.report(LogVisor::FatalError, "unable to find suitable pixel format"); + Log.report(logvisor::Fatal, "unable to find suitable pixel format"); return; } @@ -731,7 +731,7 @@ public: glXWaitVideoSyncSGI = (glXWaitVideoSyncSGIProc) glXGetProcAddressARB((const GLubyte*)"glXWaitVideoSyncSGI"); if (!glXWaitVideoSyncSGI) - Log.report(LogVisor::FatalError, "unable to resolve glXWaitVideoSyncSGI"); + Log.report(logvisor::Fatal, "unable to resolve glXWaitVideoSyncSGI"); } if (m_ctx->m_instance == VK_NULL_HANDLE) @@ -772,7 +772,7 @@ 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::FatalError, + Log.report(logvisor::Fatal, "Could not find a queue that supports both graphics and present"); m_ctx->initDevice(); @@ -781,13 +781,13 @@ public: { /* Subsequent window, verify present */ if (supportsPresent[m_ctx->m_graphicsQueueFamilyIndex] == VK_FALSE) - Log.report(LogVisor::FatalError, "subsequent surface doesn't support present"); + Log.report(logvisor::Fatal, "subsequent surface doesn't support present"); } free(supportsPresent); if (!vkGetPhysicalDeviceXcbPresentationSupportKHR(m_ctx->m_gpus[0], m_ctx->m_graphicsQueueFamilyIndex, m_xcbConn, m_visualid)) { - Log.report(LogVisor::FatalError, "XCB visual doesn't support vulkan present"); + Log.report(logvisor::Fatal, "XCB visual doesn't support vulkan present"); return; } @@ -809,7 +809,7 @@ public: m_format = surfFormats[0].format; } else - Log.report(LogVisor::FatalError, "no surface formats available for Vulkan swapchain"); + Log.report(logvisor::Fatal, "no surface formats available for Vulkan swapchain"); m_ctx->initSwapChain(m_windowCtx, m_surface, m_format); @@ -827,7 +827,7 @@ public: vsyncDisp = XOpenDisplay(0); if (!vsyncDisp) - Log.report(LogVisor::FatalError, "unable to open new vsync display"); + Log.report(logvisor::Fatal, "unable to open new vsync display"); XLockDisplay(vsyncDisp); static int attributeList[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, 0 }; @@ -835,10 +835,10 @@ public: vsyncCtx = glXCreateContext(vsyncDisp, vi, nullptr, True); if (!vsyncCtx) - Log.report(LogVisor::FatalError, "unable to make new vsync GLX context"); + Log.report(logvisor::Fatal, "unable to make new vsync GLX context"); if (!glXMakeCurrent(vsyncDisp, DefaultRootWindow(vsyncDisp), vsyncCtx)) - Log.report(LogVisor::FatalError, "unable to make vsync context current"); + Log.report(logvisor::Fatal, "unable to make vsync context current"); } initcv.notify_one(); @@ -847,7 +847,7 @@ public: unsigned int sync; int err = glXWaitVideoSyncSGI(1, 0, &sync); if (err) - Log.report(LogVisor::FatalError, "wait err"); + Log.report(logvisor::Fatal, "wait err"); m_vsynccv.notify_one(); } @@ -1372,14 +1372,14 @@ public: if (XGetWindowProperty(m_xDisp, m_windowId, S_ATOMS->m_clipdata, 0, 32, False, AnyPropertyType, &type, &format, &nitems, &rem, &data)) { - Log.report(LogVisor::FatalError, "Clipboard allocation failed"); + Log.report(logvisor::Fatal, "Clipboard allocation failed"); XUnlockDisplay(m_xDisp); return {}; } if (rem != 0) { - Log.report(LogVisor::FatalError, "partial clipboard read"); + Log.report(logvisor::Fatal, "partial clipboard read"); XUnlockDisplay(m_xDisp); return {}; } diff --git a/log-visor b/log-visor deleted file mode 160000 index 55b81ec..0000000 --- a/log-visor +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 55b81ec091e9f0e57bd7d092a396916234b1ada5 diff --git a/logvisor b/logvisor new file mode 160000 index 0000000..db41551 --- /dev/null +++ b/logvisor @@ -0,0 +1 @@ +Subproject commit db415516f6742bd3fe4d2616d478b232cc33ab34 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 19c0fb4..a6bee3f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(booTest WIN32 main.cpp) -target_link_libraries(booTest Boo LogVisor ${BOO_SYS_LIBS}) +target_link_libraries(booTest boo logvisor ${BOO_SYS_LIBS}) diff --git a/test/main.cpp b/test/main.cpp index 756bd36..246d653 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include "logvisor/logvisor.hpp" #if _WIN32 #include @@ -490,10 +490,10 @@ int wmain(int argc, const boo::SystemChar** argv) int main(int argc, const boo::SystemChar** argv) #endif { - LogVisor::RegisterConsoleLogger(); + logvisor::RegisterConsoleLogger(); boo::TestApplicationCallback appCb; int ret = ApplicationRun(boo::IApplication::EPlatformType::Auto, - appCb, _S("boo"), _S("Boo"), argc, argv); + appCb, _S("boo"), _S("boo"), argc, argv); printf("IM DYING!!\n"); return ret; } @@ -510,7 +510,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) for (int i=0 ; i