Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9236 from lioncash/log-backend
VideoBackends: Migrate logging over to fmt
  • Loading branch information
leoetlino committed Nov 12, 2020
2 parents ec5313f + 21dd7a8 commit 8a621c2
Show file tree
Hide file tree
Showing 31 changed files with 174 additions and 157 deletions.
10 changes: 5 additions & 5 deletions Source/Core/VideoBackends/D3D/D3DBase.cpp
Expand Up @@ -67,7 +67,7 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
HRESULT hr = dxgi_factory->EnumAdapters(adapter_index, adapter.GetAddressOf());
if (FAILED(hr))
{
WARN_LOG(VIDEO, "Adapter %u not found, using default", adapter_index);
WARN_LOG_FMT(VIDEO, "Adapter {} not found, using default", adapter_index);
adapter = nullptr;
}

Expand Down Expand Up @@ -99,7 +99,7 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
}
else
{
WARN_LOG(VIDEO, "Debug layer requested but not available.");
WARN_LOG_FMT(VIDEO, "Debug layer requested but not available.");
}
}

Expand All @@ -124,7 +124,7 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
hr = device.As(&device1);
if (FAILED(hr))
{
WARN_LOG(VIDEO, "Missing Direct3D 11.1 support. Logical operations will not be supported.");
WARN_LOG_FMT(VIDEO, "Missing Direct3D 11.1 support. Logical operations will not be supported.");
}

stateman = std::make_unique<StateManager>();
Expand Down Expand Up @@ -156,9 +156,9 @@ void Destroy()
}

if (remaining_references)
ERROR_LOG(VIDEO, "Unreleased references: %i.", remaining_references);
ERROR_LOG_FMT(VIDEO, "Unreleased references: {}.", remaining_references);
else
NOTICE_LOG(VIDEO, "Successfully released all device references!");
NOTICE_LOG_FMT(VIDEO, "Successfully released all device references!");

dxgi_factory.Reset();
D3DCommon::UnloadLibraries();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D/D3DState.cpp
Expand Up @@ -386,7 +386,7 @@ ID3D11BlendState* StateCache::Get(BlendingState state)
{
return m_blend.emplace(state.hex, std::move(res)).first->second.Get();
}
WARN_LOG(VIDEO, "Creating D3D blend state failed with an error: %x", hr);
WARN_LOG_FMT(VIDEO, "Creating D3D blend state failed with an error: {:08X}", hr);
}

D3D11_BLEND_DESC desc = {};
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D/PerfQuery.cpp
Expand Up @@ -35,7 +35,7 @@ void PerfQuery::EnableQuery(PerfQueryGroup type)
{
// TODO
FlushOne();
ERROR_LOG(VIDEO, "Flushed query buffer early!");
ERROR_LOG_FMT(VIDEO, "Flushed query buffer early!");
}

// start query
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D12/BoundingBox.cpp
Expand Up @@ -148,7 +148,7 @@ void BoundingBox::Flush()
const u32 copy_size = (end - start) * sizeof(ValueType);
if (!m_upload_buffer.ReserveMemory(copy_size, sizeof(ValueType)))
{
WARN_LOG(VIDEO, "Executing command list while waiting for space in bbox stream buffer");
WARN_LOG_FMT(VIDEO, "Executing command list while waiting for space in bbox stream buffer");
Renderer::GetInstance()->ExecuteCommandList(false);
if (!m_upload_buffer.ReserveMemory(copy_size, sizeof(ValueType)))
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3D12/DXContext.cpp
Expand Up @@ -152,7 +152,7 @@ bool DXContext::CreateDevice(u32 adapter_index, bool enable_debug_layer)
HRESULT hr = m_dxgi_factory->EnumAdapters(adapter_index, &adapter);
if (FAILED(hr))
{
ERROR_LOG(VIDEO, "Adapter %u not found, using default", adapter_index);
ERROR_LOG_FMT(VIDEO, "Adapter {} not found, using default", adapter_index);
adapter = nullptr;
}

Expand All @@ -166,7 +166,7 @@ bool DXContext::CreateDevice(u32 adapter_index, bool enable_debug_layer)
}
else
{
ERROR_LOG(VIDEO, "Debug layer requested but not available.");
ERROR_LOG_FMT(VIDEO, "Debug layer requested but not available.");
enable_debug_layer = false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/VideoBackends/D3D12/DXPipeline.cpp
Expand Up @@ -210,8 +210,8 @@ std::unique_ptr<DXPipeline> DXPipeline::Create(const AbstractPipelineConfig& con
HRESULT hr = g_dx_context->GetDevice()->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso));
if (FAILED(hr))
{
WARN_LOG(VIDEO, "CreateGraphicsPipelineState() %sfailed with HRESULT %08X",
cache_data ? "with cache data " : "", hr);
WARN_LOG_FMT(VIDEO, "CreateGraphicsPipelineState() {}failed with HRESULT {:08X}",
cache_data ? "with cache data " : "", hr);
return nullptr;
}

Expand All @@ -227,7 +227,7 @@ AbstractPipeline::CacheData DXPipeline::GetCacheData() const
HRESULT hr = m_pipeline->GetCachedBlob(&blob);
if (FAILED(hr))
{
WARN_LOG(VIDEO, "ID3D12Pipeline::GetCachedBlob() failed with HRESULT %08X", hr);
WARN_LOG_FMT(VIDEO, "ID3D12Pipeline::GetCachedBlob() failed with HRESULT {:08X}", hr);
return {};
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoBackends/D3D12/DXTexture.cpp
Expand Up @@ -239,7 +239,8 @@ void DXTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8*
if (!g_dx_context->GetTextureUploadBuffer().ReserveMemory(
upload_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT))
{
WARN_LOG(VIDEO, "Executing command list while waiting for space in texture upload buffer");
WARN_LOG_FMT(VIDEO,
"Executing command list while waiting for space in texture upload buffer");
Renderer::GetInstance()->ExecuteCommandList(false);
if (!g_dx_context->GetTextureUploadBuffer().ReserveMemory(
upload_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT))
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D12/DescriptorHeapManager.cpp
Expand Up @@ -148,7 +148,7 @@ bool SamplerHeapManager::Lookup(const SamplerState& ss, D3D12_CPU_DESCRIPTOR_HAN
{
// We can clear at any time because the descriptors are copied prior to execution.
// It's still not free, since we have to recreate all our samplers again.
WARN_LOG(VIDEO, "Out of samplers, resetting CPU heap");
WARN_LOG_FMT(VIDEO, "Out of samplers, resetting CPU heap");
Clear();
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3D12/Renderer.cpp
Expand Up @@ -653,8 +653,8 @@ void Renderer::UpdateDescriptorTables()
const bool uav_update_failed = (m_dirty_bits & DirtyState_PS_UAV) && !UpdateUAVDescriptorTable();
if (texture_update_failed || sampler_update_failed || uav_update_failed)
{
WARN_LOG(VIDEO, "Executing command list while waiting for temporary %s",
texture_update_failed ? "descriptors" : "samplers");
WARN_LOG_FMT(VIDEO, "Executing command list while waiting for temporary {}",
texture_update_failed ? "descriptors" : "samplers");
ExecuteCommandList(false);
SetRootSignatures();
SetDescriptorHeaps();
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/VideoBackends/D3D12/VertexManager.cpp
Expand Up @@ -80,7 +80,7 @@ void VertexManager::ResetBuffer(u32 vertex_stride)
if (!has_vbuffer_allocation || !has_ibuffer_allocation)
{
// Flush any pending commands first, so that we can wait on the fences
WARN_LOG(VIDEO, "Executing command list while waiting for space in vertex/index buffer");
WARN_LOG_FMT(VIDEO, "Executing command list while waiting for space in vertex/index buffer");
Renderer::GetInstance()->ExecuteCommandList(false);

// Attempt to allocate again, this may cause a fence wait
Expand Down Expand Up @@ -182,7 +182,7 @@ bool VertexManager::ReserveConstantStorage()
}

// The only places that call constant updates are safe to have state restored.
WARN_LOG(VIDEO, "Executing command list while waiting for space in uniform buffer");
WARN_LOG_FMT(VIDEO, "Executing command list while waiting for space in uniform buffer");
Renderer::GetInstance()->ExecuteCommandList(false);

// Since we are on a new command buffer, all constants have been invalidated, and we need
Expand Down Expand Up @@ -244,7 +244,7 @@ void VertexManager::UploadUtilityUniforms(const void* data, u32 data_size)
if (!m_uniform_stream_buffer.ReserveMemory(data_size,
D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT))
{
WARN_LOG(VIDEO, "Executing command buffer while waiting for ext space in uniform buffer");
WARN_LOG_FMT(VIDEO, "Executing command buffer while waiting for ext space in uniform buffer");
Renderer::GetInstance()->ExecuteCommandList(false);
}

Expand All @@ -266,7 +266,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
if (!m_texel_stream_buffer.ReserveMemory(data_size, elem_size))
{
// Try submitting cmdbuffer.
WARN_LOG(VIDEO, "Submitting command buffer while waiting for space in texel buffer");
WARN_LOG_FMT(VIDEO, "Submitting command buffer while waiting for space in texel buffer");
Renderer::GetInstance()->ExecuteCommandList(false);
if (!m_texel_stream_buffer.ReserveMemory(data_size, elem_size))
{
Expand Down Expand Up @@ -296,7 +296,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
if (!m_texel_stream_buffer.ReserveMemory(reserve_size, elem_size))
{
// Try submitting cmdbuffer.
WARN_LOG(VIDEO, "Submitting command buffer while waiting for space in texel buffer");
WARN_LOG_FMT(VIDEO, "Submitting command buffer while waiting for space in texel buffer");
Renderer::GetInstance()->ExecuteCommandList(false);
if (!m_texel_stream_buffer.ReserveMemory(reserve_size, elem_size))
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3DCommon/Shader.cpp
Expand Up @@ -126,8 +126,8 @@ std::optional<Shader::BinaryData> Shader::CompileShader(D3D_FEATURE_LEVEL featur

if (errors && errors->GetBufferSize() > 0)
{
WARN_LOG(VIDEO, "%s compilation succeeded with warnings:\n%s", target,
static_cast<const char*>(errors->GetBufferPointer()));
WARN_LOG_FMT(VIDEO, "{} compilation succeeded with warnings:\n{}", target,
static_cast<const char*>(errors->GetBufferPointer()));
}

return CreateByteCode(code->GetBufferPointer(), code->GetBufferSize());
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/VideoBackends/D3DCommon/SwapChain.cpp
Expand Up @@ -134,7 +134,7 @@ bool SwapChain::CreateSwapChain(bool stereo)
hr = m_dxgi_factory->MakeWindowAssociation(static_cast<HWND>(m_wsi.render_surface),
DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER);
if (FAILED(hr))
WARN_LOG(VIDEO, "MakeWindowAssociation() failed with HRESULT %08X", hr);
WARN_LOG_FMT(VIDEO, "MakeWindowAssociation() failed with HRESULT {:08X}", hr);

m_stereo = stereo;
if (!CreateSwapChainBuffers())
Expand Down Expand Up @@ -167,7 +167,7 @@ bool SwapChain::ResizeSwapChain()
GetDXGIFormatForAbstractFormat(m_texture_format, false),
GetSwapChainFlags());
if (FAILED(hr))
WARN_LOG(VIDEO, "ResizeBuffers() failed with HRESULT %08X", hr);
WARN_LOG_FMT(VIDEO, "ResizeBuffers() failed with HRESULT {:08X}", hr);

DXGI_SWAP_CHAIN_DESC desc;
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)))
Expand Down Expand Up @@ -237,7 +237,7 @@ bool SwapChain::Present()
HRESULT hr = m_swap_chain->Present(static_cast<UINT>(g_ActiveConfig.bVSyncActive), present_flags);
if (FAILED(hr))
{
WARN_LOG(VIDEO, "Swap chain present failed with HRESULT %08X", hr);
WARN_LOG_FMT(VIDEO, "Swap chain present failed with HRESULT {:08X}", hr);
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/OGL/PerfQuery.cpp
Expand Up @@ -104,7 +104,7 @@ void PerfQueryGL::EnableQuery(PerfQueryGroup type)
if (m_query_buffer.size() == m_query_count)
{
FlushOne();
// ERROR_LOG(VIDEO, "Flushed query buffer early!");
// ERROR_LOG_FMT(VIDEO, "Flushed query buffer early!");
}

// start query
Expand Down Expand Up @@ -198,7 +198,7 @@ void PerfQueryGLESNV::EnableQuery(PerfQueryGroup type)
if (m_query_buffer.size() == m_query_count)
{
FlushOne();
// ERROR_LOG(VIDEO, "Flushed query buffer early!");
// ERROR_LOG_FMT(VIDEO, "Flushed query buffer early!");
}

// start query
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
Expand Up @@ -357,7 +357,7 @@ bool ProgramShaderCache::CheckShaderCompileResult(GLuint id, GLenum type, std::s

if (compileStatus != GL_TRUE)
{
ERROR_LOG(VIDEO, "%s failed compilation:\n%s", prefix, info_log.c_str());
ERROR_LOG_FMT(VIDEO, "{} failed compilation:\n{}", prefix, info_log);

std::string filename = VideoBackendBase::BadShaderFilename(prefix, num_failures++);
std::ofstream file;
Expand All @@ -376,7 +376,7 @@ bool ProgramShaderCache::CheckShaderCompileResult(GLuint id, GLenum type, std::s
return false;
}

WARN_LOG(VIDEO, "%s compiled with warnings:\n%s", prefix, info_log.c_str());
WARN_LOG_FMT(VIDEO, "{} compiled with warnings:\n{}", prefix, info_log);
}

return true;
Expand All @@ -396,7 +396,7 @@ bool ProgramShaderCache::CheckProgramLinkResult(GLuint id, std::string_view vcod
glGetProgramInfoLog(id, length, &length, &info_log[0]);
if (linkStatus != GL_TRUE)
{
ERROR_LOG(VIDEO, "Program failed linking:\n%s", info_log.c_str());
ERROR_LOG_FMT(VIDEO, "Program failed linking:\n{}", info_log);
std::string filename = VideoBackendBase::BadShaderFilename("p", num_failures++);
std::ofstream file;
File::OpenFStream(file, filename, std::ios_base::out);
Expand All @@ -421,7 +421,7 @@ bool ProgramShaderCache::CheckProgramLinkResult(GLuint id, std::string_view vcod
return false;
}

WARN_LOG(VIDEO, "Program linked with warnings:\n%s", info_log.c_str());
WARN_LOG_FMT(VIDEO, "Program linked with warnings:\n{}", info_log);
}

return true;
Expand Down Expand Up @@ -554,7 +554,7 @@ PipelineProgram* ProgramShaderCache::GetPipelineProgram(const GLVertexFormat* ve
glGetProgramiv(prog->shader.glprogid, GL_LINK_STATUS, &link_status);
if (link_status != GL_TRUE)
{
WARN_LOG(VIDEO, "Failed to create GL program from program binary.");
WARN_LOG_FMT(VIDEO, "Failed to create GL program from program binary.");
prog->shader.Destroy();
return nullptr;
}
Expand Down
49 changes: 25 additions & 24 deletions Source/Core/VideoBackends/OGL/Render.cpp
Expand Up @@ -105,19 +105,19 @@ static void APIENTRY ErrorCallback(GLenum source, GLenum type, GLuint id, GLenum
switch (severity)
{
case GL_DEBUG_SEVERITY_HIGH_ARB:
ERROR_LOG(HOST_GPU, "id: %x, source: %s, type: %s - %s", id, s_source, s_type, message);
ERROR_LOG_FMT(HOST_GPU, "id: {:x}, source: {}, type: {} - {}", id, s_source, s_type, message);
break;
case GL_DEBUG_SEVERITY_MEDIUM_ARB:
WARN_LOG(HOST_GPU, "id: %x, source: %s, type: %s - %s", id, s_source, s_type, message);
WARN_LOG_FMT(HOST_GPU, "id: {:x}, source: {}, type: {} - {}", id, s_source, s_type, message);
break;
case GL_DEBUG_SEVERITY_LOW_ARB:
DEBUG_LOG(HOST_GPU, "id: %x, source: %s, type: %s - %s", id, s_source, s_type, message);
DEBUG_LOG_FMT(HOST_GPU, "id: {:x}, source: {}, type: {} - {}", id, s_source, s_type, message);
break;
case GL_DEBUG_SEVERITY_NOTIFICATION:
DEBUG_LOG(HOST_GPU, "id: %x, source: %s, type: %s - %s", id, s_source, s_type, message);
DEBUG_LOG_FMT(HOST_GPU, "id: {:x}, source: {}, type: {} - {}", id, s_source, s_type, message);
break;
default:
ERROR_LOG(HOST_GPU, "id: %x, source: %s, type: %s - %s", id, s_source, s_type, message);
ERROR_LOG_FMT(HOST_GPU, "id: {:x}, source: {}, type: {} - {}", id, s_source, s_type, message);
break;
}
}
Expand Down Expand Up @@ -307,7 +307,7 @@ static void InitDriverInfo()
version = 100 * major + minor;
if (change >= change_scale)
{
ERROR_LOG(VIDEO, "Version changeID overflow - change:%d scale:%f", change, change_scale);
ERROR_LOG_FMT(VIDEO, "Version changeID overflow - change:{} scale:{}", change, change_scale);
}
else
{
Expand Down Expand Up @@ -734,33 +734,34 @@ Renderer::Renderer(std::unique_ptr<GLContext> main_gl_context, float backbuffer_
g_Config.VerifyValidity();
UpdateActiveConfig();

OSD::AddMessage(StringFromFormat("Video Info: %s, %s, %s", g_ogl_config.gl_vendor,
g_ogl_config.gl_renderer, g_ogl_config.gl_version),
OSD::AddMessage(fmt::format("Video Info: {}, {}, {}", g_ogl_config.gl_vendor,
g_ogl_config.gl_renderer, g_ogl_config.gl_version),
5000);

if (!g_ogl_config.bSupportsGLBufferStorage && !g_ogl_config.bSupportsGLPinnedMemory)
{
OSD::AddMessage(StringFromFormat("Your OpenGL driver does not support %s_buffer_storage.",
m_main_gl_context->IsGLES() ? "EXT" : "ARB"),
OSD::AddMessage(fmt::format("Your OpenGL driver does not support {}_buffer_storage.",
m_main_gl_context->IsGLES() ? "EXT" : "ARB"),
60000);
OSD::AddMessage("This device's performance will be terrible.", 60000);
OSD::AddMessage("Please ask your device vendor for an updated OpenGL driver.", 60000);
}

WARN_LOG(VIDEO, "Missing OGL Extensions: %s%s%s%s%s%s%s%s%s%s%s%s%s%s",
g_ActiveConfig.backend_info.bSupportsDualSourceBlend ? "" : "DualSourceBlend ",
g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? "" : "PrimitiveRestart ",
g_ActiveConfig.backend_info.bSupportsEarlyZ ? "" : "EarlyZ ",
g_ogl_config.bSupportsGLPinnedMemory ? "" : "PinnedMemory ",
supports_glsl_cache ? "" : "ShaderCache ",
g_ogl_config.bSupportsGLBaseVertex ? "" : "BaseVertex ",
g_ogl_config.bSupportsGLBufferStorage ? "" : "BufferStorage ",
g_ogl_config.bSupportsGLSync ? "" : "Sync ", g_ogl_config.bSupportsMSAA ? "" : "MSAA ",
g_ActiveConfig.backend_info.bSupportsSSAA ? "" : "SSAA ",
g_ActiveConfig.backend_info.bSupportsGSInstancing ? "" : "GSInstancing ",
g_ActiveConfig.backend_info.bSupportsClipControl ? "" : "ClipControl ",
g_ogl_config.bSupportsCopySubImage ? "" : "CopyImageSubData ",
g_ActiveConfig.backend_info.bSupportsDepthClamp ? "" : "DepthClamp ");
WARN_LOG_FMT(VIDEO, "Missing OGL Extensions: {}{}{}{}{}{}{}{}{}{}{}{}{}{}",
g_ActiveConfig.backend_info.bSupportsDualSourceBlend ? "" : "DualSourceBlend ",
g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? "" : "PrimitiveRestart ",
g_ActiveConfig.backend_info.bSupportsEarlyZ ? "" : "EarlyZ ",
g_ogl_config.bSupportsGLPinnedMemory ? "" : "PinnedMemory ",
supports_glsl_cache ? "" : "ShaderCache ",
g_ogl_config.bSupportsGLBaseVertex ? "" : "BaseVertex ",
g_ogl_config.bSupportsGLBufferStorage ? "" : "BufferStorage ",
g_ogl_config.bSupportsGLSync ? "" : "Sync ",
g_ogl_config.bSupportsMSAA ? "" : "MSAA ",
g_ActiveConfig.backend_info.bSupportsSSAA ? "" : "SSAA ",
g_ActiveConfig.backend_info.bSupportsGSInstancing ? "" : "GSInstancing ",
g_ActiveConfig.backend_info.bSupportsClipControl ? "" : "ClipControl ",
g_ogl_config.bSupportsCopySubImage ? "" : "CopyImageSubData ",
g_ActiveConfig.backend_info.bSupportsDepthClamp ? "" : "DepthClamp ");

// Handle VSync on/off
if (!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_VSYNC))
Expand Down

0 comments on commit 8a621c2

Please sign in to comment.