GPUDevice: Move debug messages over to fmt

This commit is contained in:
Stenzek 2023-09-21 00:42:27 +10:00
parent 184b0a1a52
commit b678fcd874
16 changed files with 68 additions and 102 deletions

View file

@ -1608,15 +1608,15 @@ bool GPU::CompileDisplayPipeline()
if (!vso || !fso)
return false;
GL_OBJECT_NAME(vso, "Display Vertex Shader");
GL_OBJECT_NAME(fso, "Display Fragment Shader [%s]", Settings::GetDisplayScalingName(g_settings.display_scaling));
GL_OBJECT_NAME_FMT(fso, "Display Fragment Shader [{}]", Settings::GetDisplayScalingName(g_settings.display_scaling));
plconfig.vertex_shader = vso.get();
plconfig.fragment_shader = fso.get();
plconfig.geometry_shader = nullptr;
if (!(m_display_pipeline = g_gpu_device->CreatePipeline(plconfig)))
return false;
GL_OBJECT_NAME(m_display_pipeline, "Display Pipeline [%s]",
Settings::GetDisplayScalingName(g_settings.display_scaling));
GL_OBJECT_NAME_FMT(m_display_pipeline, "Display Pipeline [{}]",
Settings::GetDisplayScalingName(g_settings.display_scaling));
return true;
}
@ -1672,7 +1672,7 @@ bool GPU::PresentDisplay()
bool GPU::RenderDisplay(GPUFramebuffer* target, const Common::Rectangle<s32>& draw_rect, bool postfx)
{
GL_SCOPE("RenderDisplay: %dx%d at %d,%d", draw_rect.left, draw_rect.top, draw_rect.GetWidth(), draw_rect.GetHeight());
GL_SCOPE_FMT("RenderDisplay: {}x{} at {},{}", draw_rect.left, draw_rect.top, draw_rect.GetWidth(), draw_rect.GetHeight());
if (m_display_texture)
m_display_texture->MakeReadyForSampling();

View file

@ -979,7 +979,7 @@ bool GPU_HW::CompilePipelines()
if (!(m_vram_copy_pipelines[depth_test] = g_gpu_device->CreatePipeline(plconfig)))
return false;
GL_OBJECT_NAME(m_vram_copy_pipelines[depth_test], "VRAM Write Pipeline, depth=%u", depth_test);
GL_OBJECT_NAME_FMT(m_vram_copy_pipelines[depth_test], "VRAM Write Pipeline, depth={}", depth_test);
progress.Increment();
}
@ -1004,7 +1004,7 @@ bool GPU_HW::CompilePipelines()
if (!(m_vram_write_pipelines[depth_test] = g_gpu_device->CreatePipeline(plconfig)))
return false;
GL_OBJECT_NAME(m_vram_write_pipelines[depth_test], "VRAM Write Pipeline, depth=%u", depth_test);
GL_OBJECT_NAME_FMT(m_vram_write_pipelines[depth_test], "VRAM Write Pipeline, depth={}", depth_test);
progress.Increment();
}
@ -2547,7 +2547,7 @@ void GPU_HW::FlushRender()
return;
#ifdef _DEBUG
GL_SCOPE("Hardware Draw %u", ++s_draw_number);
GL_SCOPE_FMT("Hardware Draw {}", ++s_draw_number);
#endif
if (m_batch_ubo_dirty)
@ -2682,7 +2682,7 @@ void GPU_HW::DownsampleFramebuffer(GPUTexture* source, u32 left, u32 top, u32 wi
void GPU_HW::DownsampleFramebufferAdaptive(GPUTexture* source, u32 left, u32 top, u32 width, u32 height)
{
GL_PUSH("DownsampleFramebufferAdaptive (%u,%u => %u,%d)", left, top, left + width, left + height);
GL_PUSH_FMT("DownsampleFramebufferAdaptive ({},{} => {},{})", left, top, left + width, left + height);
struct SmoothingUBOData
{
@ -2701,7 +2701,7 @@ void GPU_HW::DownsampleFramebufferAdaptive(GPUTexture* source, u32 left, u32 top
// create mip chain
for (u32 level = 1; level < levels; level++)
{
GL_SCOPE("Create miplevel %u", level);
GL_SCOPE_FMT("Create miplevel {}", level);
const u32 level_width = width >> level;
const u32 level_height = height >> level;

View file

@ -781,18 +781,13 @@ float D3D11Device::GetAndResetAccumulatedGPUTime()
return value;
}
void D3D11Device::PushDebugGroup(const char* fmt, ...)
void D3D11Device::PushDebugGroup(const char* name)
{
#ifdef _DEBUG
if (!m_annotation)
return;
std::va_list ap;
va_start(ap, fmt);
std::string str(StringUtil::StdStringFromFormatV(fmt, ap));
va_end(ap);
m_annotation->BeginEvent(StringUtil::UTF8StringToWideString(str).c_str());
m_annotation->BeginEvent(StringUtil::UTF8StringToWideString(name).c_str());
#endif
}
@ -806,18 +801,13 @@ void D3D11Device::PopDebugGroup()
#endif
}
void D3D11Device::InsertDebugMessage(const char* fmt, ...)
void D3D11Device::InsertDebugMessage(const char* msg)
{
#ifdef _DEBUG
if (!m_annotation)
return;
std::va_list ap;
va_start(ap, fmt);
std::string str(StringUtil::StdStringFromFormatV(fmt, ap));
va_end(ap);
m_annotation->SetMarker(StringUtil::UTF8StringToWideString(str).c_str());
m_annotation->SetMarker(StringUtil::UTF8StringToWideString(msg).c_str());
#endif
}

View file

@ -73,9 +73,9 @@ public:
const char* entry_point, DynamicHeapArray<u8>* binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
void PushDebugGroup(const char* fmt, ...) override;
void PushDebugGroup(const char* name) override;
void PopDebugGroup() override;
void InsertDebugMessage(const char* fmt, ...) override;
void InsertDebugMessage(const char* msg) override;
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
u32* map_base_vertex) override;

View file

@ -1125,20 +1125,15 @@ static UINT64 Palette(float phase, const std::array<float, 3>& a, const std::arr
}
#endif
void D3D12Device::PushDebugGroup(const char* fmt, ...)
void D3D12Device::PushDebugGroup(const char* name)
{
#ifdef _DEBUG
if (!m_debug_device)
return;
std::va_list ap;
va_start(ap, fmt);
const std::string buf(StringUtil::StdStringFromFormatV(fmt, ap));
va_end(ap);
const UINT64 color = Palette(static_cast<float>(++s_debug_scope_depth), {0.5f, 0.5f, 0.5f}, {0.5f, 0.5f, 0.5f},
{1.0f, 1.0f, 0.5f}, {0.8f, 0.90f, 0.30f});
PIXBeginEvent(GetCommandList(), color, "%s", buf.c_str());
PIXBeginEvent(GetCommandList(), color, "%s", name);
#endif
}
@ -1153,21 +1148,13 @@ void D3D12Device::PopDebugGroup()
#endif
}
void D3D12Device::InsertDebugMessage(const char* fmt, ...)
void D3D12Device::InsertDebugMessage(const char* msg)
{
#ifdef _DEBUG
if (!m_debug_device)
return;
std::va_list ap;
va_start(ap, fmt);
const std::string buf(StringUtil::StdStringFromFormatV(fmt, ap));
va_end(ap);
if (buf.empty())
return;
PIXSetMarker(GetCommandList(), PIX_COLOR(0, 0, 0), "%s", buf.c_str());
PIXSetMarker(GetCommandList(), PIX_COLOR(0, 0, 0), "%s", msg);
#endif
}

View file

@ -93,9 +93,9 @@ public:
const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
void PushDebugGroup(const char* fmt, ...) override;
void PushDebugGroup(const char* name) override;
void PopDebugGroup() override;
void InsertDebugMessage(const char* fmt, ...) override;
void InsertDebugMessage(const char* msg) override;
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
u32* map_base_vertex) override;

View file

@ -10,6 +10,7 @@
#include "common/bitfield.h"
#include "common/heap_array.h"
#include "common/rectangle.h"
#include "common/small_string.h"
#include "common/types.h"
#include <memory>
@ -564,9 +565,9 @@ public:
virtual std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) = 0;
/// Debug messaging.
virtual void PushDebugGroup(const char* fmt, ...) = 0;
virtual void PushDebugGroup(const char* name) = 0;
virtual void PopDebugGroup() = 0;
virtual void InsertDebugMessage(const char* fmt, ...) = 0;
virtual void InsertDebugMessage(const char* msg) = 0;
/// Vertex/index buffer abstraction.
virtual void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
@ -694,15 +695,25 @@ struct GLAutoPop
~GLAutoPop() { g_gpu_device->PopDebugGroup(); }
};
#define GL_SCOPE(...) GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(__VA_ARGS__), 0))
#define GL_PUSH(...) g_gpu_device->PushDebugGroup(__VA_ARGS__)
#define GL_SCOPE(name) GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(name), 0))
#define GL_PUSH(name) g_gpu_device->PushDebugGroup(name)
#define GL_POP() g_gpu_device->PopDebugGroup()
#define GL_INS(...) g_gpu_device->InsertDebugMessage(__VA_ARGS__)
#define GL_OBJECT_NAME(obj, ...) (obj)->SetDebugName(StringUtil::StdStringFromFormat(__VA_ARGS__))
#define GL_INS(msg) g_gpu_device->InsertDebugMessage(msg)
#define GL_OBJECT_NAME(obj, name) (obj)->SetDebugName(name)
#define GL_SCOPE_FMT(...) GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(SmallString::from_fmt(__VA_ARGS__)), 0))
#define GL_PUSH_FMT(...) g_gpu_device->PushDebugGroup(SmallString::from_fmt(__VA_ARGS__))
#define GL_INS_FMT(...) g_gpu_device->InsertDebugMessage(SmallString::from_fmt(__VA_ARGS__))
#define GL_OBJECT_NAME_FMT(obj, ...) (obj)->SetDebugName(SmallString::from_fmt(__VA_ARGS__))
#else
#define GL_SCOPE(...) (void)0
#define GL_PUSH(...) (void)0
#define GL_SCOPE(name) (void)0
#define GL_PUSH(name) (void)0
#define GL_POP() (void)0
#define GL_INS(...) (void)0
#define GL_OBJECT_NAME(...) (void)0
#define GL_INS(msg) (void)0
#define GL_OBJECT_NAME(obj, name) (void)0
#define GL_SCOPE_FMT(...) (void)0
#define GL_PUSH_FMT(...) (void)0
#define GL_INS_FMT(...) (void)0
#define GL_OBJECT_NAME_FMT(obj, ...) (void)0
#endif

View file

@ -230,9 +230,9 @@ public:
DynamicHeapArray<u8>* out_binary = nullptr) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
void PushDebugGroup(const char* fmt, ...) override;
void PushDebugGroup(const char* name) override;
void PopDebugGroup() override;
void InsertDebugMessage(const char* fmt, ...) override;
void InsertDebugMessage(const char* msg) override;
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
u32* map_base_vertex) override;

View file

@ -1602,7 +1602,7 @@ std::unique_ptr<GPUTextureBuffer> MetalDevice::CreateTextureBuffer(GPUTextureBuf
return tb;
}
void MetalDevice::PushDebugGroup(const char* fmt, ...)
void MetalDevice::PushDebugGroup(const char* name)
{
}
@ -1610,7 +1610,7 @@ void MetalDevice::PopDebugGroup()
{
}
void MetalDevice::InsertDebugMessage(const char* fmt, ...)
void MetalDevice::InsertDebugMessage(const char* msg)
{
}

View file

@ -210,17 +210,13 @@ void OpenGLDevice::InvalidateRenderTarget(GPUTexture* t)
CommitClear(m_current_framebuffer);
}
void OpenGLDevice::PushDebugGroup(const char* fmt, ...)
void OpenGLDevice::PushDebugGroup(const char* name)
{
#ifdef _DEBUG
if (!glPushDebugGroup)
return;
std::va_list ap;
va_start(ap, fmt);
const std::string buf(StringUtil::StdStringFromFormatV(fmt, ap));
va_end(ap);
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, static_cast<GLsizei>(buf.size()), buf.c_str());
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, static_cast<GLsizei>(std::strlen(name)), name);
#endif
}
@ -234,20 +230,16 @@ void OpenGLDevice::PopDebugGroup()
#endif
}
void OpenGLDevice::InsertDebugMessage(const char* fmt, ...)
void OpenGLDevice::InsertDebugMessage(const char* msg)
{
#ifdef _DEBUG
if (!glDebugMessageInsert)
return;
std::va_list ap;
va_start(ap, fmt);
const std::string buf(StringUtil::StdStringFromFormatV(fmt, ap));
va_end(ap);
if (!buf.empty())
if (msg[0] != '\0')
{
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 0, GL_DEBUG_SEVERITY_NOTIFICATION,
static_cast<GLsizei>(buf.size()), buf.c_str());
static_cast<GLsizei>(std::strlen(msg)), msg);
}
#endif
}
@ -349,7 +341,7 @@ bool OpenGLDevice::CheckFeatures(bool* buggy_pbo)
const bool is_gles = m_gl_context->IsGLES();
bool vendor_id_amd = false;
//bool vendor_id_nvidia = false;
// bool vendor_id_nvidia = false;
bool vendor_id_intel = false;
bool vendor_id_arm = false;
bool vendor_id_qualcomm = false;

View file

@ -73,9 +73,9 @@ public:
const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
void PushDebugGroup(const char* fmt, ...) override;
void PushDebugGroup(const char* name) override;
void PopDebugGroup() override;
void InsertDebugMessage(const char* fmt, ...) override;
void InsertDebugMessage(const char* msg) override;
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
u32* map_base_vertex) override;

View file

@ -203,7 +203,7 @@ bool OpenGLTexture::Update(u32 x, u32 y, u32 width, u32 height, const void* data
if (!sb || map_size > sb->GetChunkSize())
{
GL_INS("Not using PBO for map size %u", map_size);
GL_INS_FMT("Not using PBO for map size {}", map_size);
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch / GetPixelSize());
glTexSubImage2D(target, layer, x, y, width, height, gl_format, gl_type, data);
}

View file

@ -612,7 +612,7 @@ bool PostProcessing::ReShadeFXShader::CreateOptions(const reshadefx::module& mod
}
m_uniforms_size = mod.total_uniform_size;
Log_DevPrintf("%s: %zu options", m_filename.c_str(), m_options.size());
Log_DevFmt("{}: {} options", m_filename, m_options.size());
return true;
}
@ -1136,7 +1136,7 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUFramebuffer* f
s32 final_top, s32 final_width, s32 final_height, s32 orig_width,
s32 orig_height, u32 target_width, u32 target_height)
{
GL_PUSH("PostProcessingShaderFX %s", m_name.c_str());
GL_PUSH_FMT("PostProcessingShaderFX {}", m_name);
m_frame_count++;
@ -1145,7 +1145,7 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUFramebuffer* f
if (m_uniforms_size > 0)
{
GL_SCOPE("Uniforms: %u bytes", m_uniforms_size);
GL_SCOPE_FMT("Uniforms: {} bytes", m_uniforms_size);
u8* uniforms = static_cast<u8*>(g_gpu_device->MapUniformBuffer(m_uniforms_size));
for (const ShaderOption& opt : m_options)
@ -1280,9 +1280,9 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUFramebuffer* f
for (const Pass& pass : m_passes)
{
GL_SCOPE("Draw pass %s", pass.name.c_str());
GL_SCOPE_FMT("Draw pass {}", pass.name.c_str());
GL_INS("Render Target: ID %d [%s]", pass.render_target, GetTextureNameForID(pass.render_target));
GL_INS_FMT("Render Target: ID {} [{}]", pass.render_target, GetTextureNameForID(pass.render_target));
GPUFramebuffer* output_fb = GetFramebufferByID(pass.render_target, input, final_target);
g_gpu_device->SetFramebuffer(output_fb);
g_gpu_device->SetPipeline(pass.pipeline.get());
@ -1291,7 +1291,7 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUFramebuffer* f
std::bitset<GPUDevice::MAX_TEXTURE_SAMPLERS> bound_textures = {};
for (const Sampler& sampler : pass.samplers)
{
GL_INS("Texture Sampler %u: ID %d [%s]", sampler.slot, sampler.texture_id,
GL_INS_FMT("Texture Sampler {}: ID {} [{}]", sampler.slot, sampler.texture_id,
GetTextureNameForID(sampler.texture_id));
g_gpu_device->SetTextureSampler(sampler.slot, GetTextureByID(sampler.texture_id, input, final_target),
sampler.sampler);

View file

@ -160,7 +160,7 @@ bool PostProcessing::GLSLShader::Apply(GPUTexture* input, GPUFramebuffer* final_
s32 final_width, s32 final_height, s32 orig_width, s32 orig_height,
u32 target_width, u32 target_height)
{
GL_SCOPE("GLSL Shader %s", m_name.c_str());
GL_SCOPE_FMT("GLSL Shader {}", m_name);
// Assumes final stage has been cleared already.
if (!final_target)

View file

@ -2109,24 +2109,19 @@ static std::array<float, 3> Palette(float phase, const std::array<float, 3>& a,
}
#endif
void VulkanDevice::PushDebugGroup(const char* fmt, ...)
void VulkanDevice::PushDebugGroup(const char* name)
{
#ifdef _DEBUG
if (!vkCmdBeginDebugUtilsLabelEXT || !m_debug_device)
return;
std::va_list ap;
va_start(ap, fmt);
const std::string buf(StringUtil::StdStringFromFormatV(fmt, ap));
va_end(ap);
const std::array<float, 3> color = Palette(static_cast<float>(++s_debug_scope_depth), {0.5f, 0.5f, 0.5f},
{0.5f, 0.5f, 0.5f}, {1.0f, 1.0f, 0.5f}, {0.8f, 0.90f, 0.30f});
const VkDebugUtilsLabelEXT label = {
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
nullptr,
buf.c_str(),
name,
{color[0], color[1], color[2], 1.0f},
};
vkCmdBeginDebugUtilsLabelEXT(GetCurrentCommandBuffer(), &label);
@ -2145,22 +2140,13 @@ void VulkanDevice::PopDebugGroup()
#endif
}
void VulkanDevice::InsertDebugMessage(const char* fmt, ...)
void VulkanDevice::InsertDebugMessage(const char* msg)
{
#ifdef _DEBUG
if (!vkCmdInsertDebugUtilsLabelEXT || !m_debug_device)
return;
std::va_list ap;
va_start(ap, fmt);
const std::string buf(StringUtil::StdStringFromFormatV(fmt, ap));
va_end(ap);
if (buf.empty())
return;
const VkDebugUtilsLabelEXT label = {
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, nullptr, buf.c_str(), {0.0f, 0.0f, 0.0f, 1.0f}};
const VkDebugUtilsLabelEXT label = {VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, nullptr, msg, {0.0f, 0.0f, 0.0f, 1.0f}};
vkCmdInsertDebugUtilsLabelEXT(GetCurrentCommandBuffer(), &label);
#endif
}

View file

@ -94,9 +94,9 @@ public:
const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
void PushDebugGroup(const char* fmt, ...) override;
void PushDebugGroup(const char* name) override;
void PopDebugGroup() override;
void InsertDebugMessage(const char* fmt, ...) override;
void InsertDebugMessage(const char* msg) override;
void MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_ptr, u32* map_space,
u32* map_base_vertex) override;