Skip to content

Commit

Permalink
VideoCommon: Migrate over to fmt
Browse files Browse the repository at this point in the history
Migrates off the printf-based formatting where applicable.
  • Loading branch information
lioncash committed Nov 18, 2020
1 parent 8a621c2 commit 3d9b2aa
Show file tree
Hide file tree
Showing 32 changed files with 310 additions and 281 deletions.
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/AbstractTexture.cpp
Expand Up @@ -126,7 +126,7 @@ u32 AbstractTexture::CalculateStrideForFormat(AbstractTextureFormat format, u32
case AbstractTextureFormat::D32F_S8:
return static_cast<size_t>(row_length) * 8;
default:
PanicAlert("Unhandled texture format.");
PanicAlertFmt("Unhandled texture format.");
return 0;
}
}
Expand All @@ -153,7 +153,7 @@ u32 AbstractTexture::GetTexelSizeForFormat(AbstractTextureFormat format)
case AbstractTextureFormat::D32F_S8:
return 8;
default:
PanicAlert("Unhandled texture format.");
PanicAlertFmt("Unhandled texture format.");
return 0;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/VideoCommon/AsyncShaderCompiler.cpp
Expand Up @@ -122,7 +122,7 @@ bool AsyncShaderCompiler::StartWorkerThreads(u32 num_worker_threads)
void* thread_param = nullptr;
if (!WorkerThreadInitMainThread(&thread_param))
{
WARN_LOG(VIDEO, "Failed to initialize shader compiler worker thread.");
WARN_LOG_FMT(VIDEO, "Failed to initialize shader compiler worker thread.");
break;
}

Expand All @@ -133,7 +133,7 @@ bool AsyncShaderCompiler::StartWorkerThreads(u32 num_worker_threads)

if (!m_worker_thread_start_result.load())
{
WARN_LOG(VIDEO, "Failed to start shader compiler worker thread.");
WARN_LOG_FMT(VIDEO, "Failed to start shader compiler worker thread.");
thr.join();
break;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ void AsyncShaderCompiler::WorkerThreadEntryPoint(void* param)
// Initialize worker thread with backend-specific method.
if (!WorkerThreadInitWorkerThread(param))
{
WARN_LOG(VIDEO, "Failed to initialize shader compiler worker.");
WARN_LOG_FMT(VIDEO, "Failed to initialize shader compiler worker.");
m_worker_thread_start_result.store(false);
m_init_event.Set();
return;
Expand Down
27 changes: 14 additions & 13 deletions Source/Core/VideoCommon/BPFunctions.cpp
Expand Up @@ -5,6 +5,7 @@
#include "VideoCommon/BPFunctions.h"

#include <algorithm>
#include <string_view>

#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
Expand Down Expand Up @@ -223,12 +224,12 @@ void OnPixelFormatChange()
if (!g_ActiveConfig.bEFBEmulateFormatChanges)
return;

auto old_format = g_renderer->GetPrevPixelFormat();
auto new_format = bpmem.zcontrol.pixel_format;
const auto old_format = g_renderer->GetPrevPixelFormat();
const auto new_format = bpmem.zcontrol.pixel_format;
g_renderer->StorePixelFormat(new_format);

DEBUG_LOG(VIDEO, "pixelfmt: pixel=%d, zc=%d", static_cast<int>(new_format),
static_cast<int>(bpmem.zcontrol.zformat));
DEBUG_LOG_FMT(VIDEO, "pixelfmt: pixel={}, zc={}", static_cast<int>(new_format),
static_cast<int>(bpmem.zcontrol.zformat));

// no need to reinterpret pixel data in these cases
if (new_format == old_format || old_format == PEControl::INVALID_FMT)
Expand Down Expand Up @@ -291,8 +292,8 @@ void OnPixelFormatChange()
break;
}

ERROR_LOG(VIDEO, "Unhandled EFB format change: %d to %d", static_cast<int>(old_format),
static_cast<int>(new_format));
ERROR_LOG_FMT(VIDEO, "Unhandled EFB format change: {} to {}", static_cast<int>(old_format),
static_cast<int>(new_format));
}

void SetInterlacingMode(const BPCmd& bp)
Expand All @@ -304,21 +305,21 @@ void SetInterlacingMode(const BPCmd& bp)
{
// SDK always sets bpmem.lineptwidth.lineaspect via BPMEM_LINEPTWIDTH
// just before this cmd
const char* action[] = {"don't adjust", "adjust"};
DEBUG_LOG(VIDEO, "BPMEM_FIELDMODE texLOD:%s lineaspect:%s", action[bpmem.fieldmode.texLOD],
action[bpmem.lineptwidth.lineaspect]);
static constexpr std::string_view action[] = {"don't adjust", "adjust"};
DEBUG_LOG_FMT(VIDEO, "BPMEM_FIELDMODE texLOD:{} lineaspect:{}", action[bpmem.fieldmode.texLOD],
action[bpmem.lineptwidth.lineaspect]);
}
break;
case BPMEM_FIELDMASK:
{
// Determines if fields will be written to EFB (always computed)
const char* action[] = {"skip", "write"};
DEBUG_LOG(VIDEO, "BPMEM_FIELDMASK even:%s odd:%s", action[bpmem.fieldmask.even],
action[bpmem.fieldmask.odd]);
static constexpr std::string_view action[] = {"skip", "write"};
DEBUG_LOG_FMT(VIDEO, "BPMEM_FIELDMASK even:{} odd:{}", action[bpmem.fieldmask.even],
action[bpmem.fieldmask.odd]);
}
break;
default:
ERROR_LOG(VIDEO, "SetInterlacingMode default");
ERROR_LOG_FMT(VIDEO, "SetInterlacingMode default");
break;
}
}
Expand Down
56 changes: 29 additions & 27 deletions Source/Core/VideoCommon/BPStructs.cpp
Expand Up @@ -90,11 +90,11 @@ static void BPWritten(const BPCmd& bp)
switch (bp.address)
{
case BPMEM_GENMODE: // Set the Generation Mode
PRIM_LOG("genmode: texgen=%d, col=%d, multisampling=%d, tev=%d, cullmode=%d, ind=%d, zfeeze=%d",
(u32)bpmem.genMode.numtexgens, (u32)bpmem.genMode.numcolchans,
(u32)bpmem.genMode.multisampling, (u32)bpmem.genMode.numtevstages + 1,
(u32)bpmem.genMode.cullmode, (u32)bpmem.genMode.numindstages,
(u32)bpmem.genMode.zfreeze);
PRIM_LOG("genmode: texgen={}, col={}, multisampling={}, tev={}, cullmode={}, ind={}, zfeeze={}",
bpmem.genMode.numtexgens.Value(), bpmem.genMode.numcolchans.Value(),
bpmem.genMode.multisampling.Value(), bpmem.genMode.numtevstages.Value() + 1,
static_cast<u32>(bpmem.genMode.cullmode), bpmem.genMode.numindstages.Value(),
bpmem.genMode.zfreeze.Value());

if (bp.changes)
PixelShaderManager::SetGenModeChanged();
Expand Down Expand Up @@ -138,15 +138,15 @@ static void BPWritten(const BPCmd& bp)
GeometryShaderManager::SetLinePtWidthChanged();
return;
case BPMEM_ZMODE: // Depth Control
PRIM_LOG("zmode: test=%u, func=%u, upd=%u", bpmem.zmode.testenable.Value(),
PRIM_LOG("zmode: test={}, func={}, upd={}", bpmem.zmode.testenable.Value(),
bpmem.zmode.func.Value(), bpmem.zmode.updateenable.Value());
SetDepthMode();
PixelShaderManager::SetZModeControl();
return;
case BPMEM_BLENDMODE: // Blending Control
if (bp.changes & 0xFFFF)
{
PRIM_LOG("blendmode: en=%u, open=%u, colupd=%u, alphaupd=%u, dst=%u, src=%u, sub=%u, mode=%u",
PRIM_LOG("blendmode: en={}, open={}, colupd={}, alphaupd={}, dst={}, src={}, sub={}, mode={}",
bpmem.blendmode.blendenable.Value(), bpmem.blendmode.logicopenable.Value(),
bpmem.blendmode.colorupdate.Value(), bpmem.blendmode.alphaupdate.Value(),
bpmem.blendmode.dstfactor.Value(), bpmem.blendmode.srcfactor.Value(),
Expand All @@ -158,7 +158,7 @@ static void BPWritten(const BPCmd& bp)
}
return;
case BPMEM_CONSTANTALPHA: // Set Destination Alpha
PRIM_LOG("constalpha: alp=%d, en=%d", bpmem.dstalpha.alpha.Value(),
PRIM_LOG("constalpha: alp={}, en={}", bpmem.dstalpha.alpha.Value(),
bpmem.dstalpha.enable.Value());
if (bp.changes)
{
Expand All @@ -181,11 +181,11 @@ static void BPWritten(const BPCmd& bp)
g_framebuffer_manager->InvalidatePeekCache(false);
if (!Fifo::UseDeterministicGPUThread())
PixelEngine::SetFinish(); // may generate interrupt
DEBUG_LOG(VIDEO, "GXSetDrawDone SetPEFinish (value: 0x%02X)", (bp.newvalue & 0xFFFF));
DEBUG_LOG_FMT(VIDEO, "GXSetDrawDone SetPEFinish (value: {:#04X})", bp.newvalue & 0xFFFF);
return;

default:
WARN_LOG(VIDEO, "GXSetDrawDone ??? (value 0x%02X)", (bp.newvalue & 0xFFFF));
WARN_LOG_FMT(VIDEO, "GXSetDrawDone ??? (value {:#04X})", bp.newvalue & 0xFFFF);
return;
}
return;
Expand All @@ -194,14 +194,14 @@ static void BPWritten(const BPCmd& bp)
g_framebuffer_manager->InvalidatePeekCache(false);
if (!Fifo::UseDeterministicGPUThread())
PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), false);
DEBUG_LOG(VIDEO, "SetPEToken 0x%04x", (bp.newvalue & 0xFFFF));
DEBUG_LOG_FMT(VIDEO, "SetPEToken {:#06X}", bp.newvalue & 0xFFFF);
return;
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
g_texture_cache->FlushEFBCopies();
g_framebuffer_manager->InvalidatePeekCache(false);
if (!Fifo::UseDeterministicGPUThread())
PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), true);
DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bp.newvalue & 0xFFFF));
DEBUG_LOG_FMT(VIDEO, "SetPEToken + INT {:#06X}", bp.newvalue & 0xFFFF);
return;

// ------------------------
Expand Down Expand Up @@ -243,8 +243,8 @@ static void BPWritten(const BPCmd& bp)
int copy_height = srcRect.GetHeight();
if (srcRect.right > s32(EFB_WIDTH) || srcRect.bottom > s32(EFB_HEIGHT))
{
WARN_LOG(VIDEO, "Oversized EFB copy: %dx%d (offset %d,%d stride %u)", copy_width, copy_height,
srcRect.left, srcRect.top, destStride);
WARN_LOG_FMT(VIDEO, "Oversized EFB copy: {}x{} (offset {},{} stride {})", copy_width,
copy_height, srcRect.left, srcRect.top, destStride);

// Adjust the copy size to fit within the EFB. So that we don't end up with a stretched image,
// instead of clamping the source rectangle, we reduce it by the over-sized amount.
Expand Down Expand Up @@ -291,11 +291,11 @@ static void BPWritten(const BPCmd& bp)

u32 height = static_cast<u32>(num_xfb_lines);

DEBUG_LOG(VIDEO,
"RenderToXFB: destAddr: %08x | srcRect {%d %d %d %d} | fbWidth: %u | "
"fbStride: %u | fbHeight: %u | yScale: %f",
destAddr, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom,
bpmem.copyTexSrcWH.x + 1, destStride, height, yScale);
DEBUG_LOG_FMT(VIDEO,
"RenderToXFB: destAddr: {:08x} | srcRect [{} {} {} {}] | fbWidth: {} | "
"fbStride: {} | fbHeight: {} | yScale: {}",
destAddr, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom,
bpmem.copyTexSrcWH.x + 1, destStride, height, yScale);

bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24;
g_texture_cache->CopyRenderTargetToTexture(
Expand Down Expand Up @@ -370,9 +370,10 @@ static void BPWritten(const BPCmd& bp)
PixelShaderManager::SetFogColorChanged();
return;
case BPMEM_ALPHACOMPARE: // Compare Alpha Values
PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d", (int)bpmem.alpha_test.ref0,
(int)bpmem.alpha_test.ref1, (int)bpmem.alpha_test.comp0, (int)bpmem.alpha_test.comp1,
(int)bpmem.alpha_test.logic);
PRIM_LOG("alphacmp: ref0={}, ref1={}, comp0={}, comp1={}, logic={}",
bpmem.alpha_test.ref0.Value(), bpmem.alpha_test.ref1.Value(),
static_cast<int>(bpmem.alpha_test.comp0), static_cast<int>(bpmem.alpha_test.comp1),
static_cast<int>(bpmem.alpha_test.logic));
if (bp.changes & 0xFFFF)
PixelShaderManager::SetAlpha();
if (bp.changes)
Expand All @@ -382,7 +383,7 @@ static void BPWritten(const BPCmd& bp)
}
return;
case BPMEM_BIAS: // BIAS
PRIM_LOG("ztex bias=0x%x", bpmem.ztex1.bias.Value());
PRIM_LOG("ztex bias={:#x}", bpmem.ztex1.bias.Value());
if (bp.changes)
PixelShaderManager::SetZTextureBias();
return;
Expand All @@ -393,9 +394,9 @@ static void BPWritten(const BPCmd& bp)
if (bp.changes & 12)
PixelShaderManager::SetZTextureOpChanged();
#if defined(_DEBUG) || defined(DEBUGFAST)
const char* pzop[] = {"DISABLE", "ADD", "REPLACE", "?"};
const char* pztype[] = {"Z8", "Z16", "Z24", "?"};
PRIM_LOG("ztex op=%s, type=%s", pzop[bpmem.ztex2.op], pztype[bpmem.ztex2.type]);
static constexpr std::string_view pzop[] = {"DISABLE", "ADD", "REPLACE", "?"};
static constexpr std::string_view pztype[] = {"Z8", "Z16", "Z24", "?"};
PRIM_LOG("ztex op={}, type={}", pzop[bpmem.ztex2.op], pztype[bpmem.ztex2.type]);
#endif
}
return;
Expand Down Expand Up @@ -711,7 +712,8 @@ static void BPWritten(const BPCmd& bp)
break;
}

WARN_LOG(VIDEO, "Unknown BP opcode: address = 0x%08x value = 0x%08x", bp.address, bp.newvalue);
WARN_LOG_FMT(VIDEO, "Unknown BP opcode: address = {:#010x} value = {:#010x}", bp.address,
bp.newvalue);
}

// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg()
Expand Down

0 comments on commit 3d9b2aa

Please sign in to comment.