[idd] logging: suppress duplicate pipeline initialization

This commit is contained in:
Geoffrey McRae
2026-08-14 02:17:01 +10:00
parent 8c21f61e91
commit 91c501d602
6 changed files with 59 additions and 32 deletions

View File

@@ -137,8 +137,8 @@ bool CSwapChainProcessor::InitializePipeline()
DEBUG_INFO("Software render adapter: post-processing disabled");
bool initialized = true;
for (CPostProcessor& postProcessor : m_postProcessors)
if (!postProcessor.Init(m_dx12Device, enableEffects))
for (unsigned i = 0; i < ARRAYSIZE(m_postProcessors); ++i)
if (!m_postProcessors[i].Init(m_dx12Device, enableEffects, i == 0))
{
initialized = false;
break;
@@ -153,12 +153,15 @@ bool CSwapChainProcessor::InitializePipeline()
break;
}
if (initialized)
m_postProcessors[0].LogEffects();
if (!initialized)
{
for (CPostProcessor& postProcessor : m_postProcessors)
{
postProcessor.Reset();
if (!postProcessor.Init(m_dx12Device, false))
if (!postProcessor.Init(m_dx12Device, false, false))
DEBUG_ERROR("Failed to initialize post processor copy support");
}
DEBUG_WARN(
@@ -680,17 +683,21 @@ bool CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
}
bool configurationStable = false;
bool configured = false;
for (unsigned pass = 0; pass < 2 && !configurationStable; ++pass)
{
for (unsigned i = 0; i < ARRAYSIZE(m_postProcessors); ++i)
{
bool formatChanged = false;
if (!m_postProcessors[i].Configure(srcFormat, &formatChanged))
bool changed = false;
if (!m_postProcessors[i].Configure(
srcFormat, &formatChanged, &changed))
{
m_frameProcessor->SetFullDamage();
return false;
}
configured |= changed;
if (i == 0)
postProcessFormatChanged |= formatChanged;
}
@@ -711,6 +718,9 @@ bool CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
return false;
}
if (configured)
m_postProcessors[0].LogActiveEffects();
if (postProcessFormatChanged)
m_frameProcessor->Invalidate();
else if (frameMetadataChanged)

View File

@@ -123,7 +123,6 @@ bool CD3D12CommandSlot::Init(ID3D12Device3 * device,
return false;
}
DEBUG_INFO("Created CD3D12CommandSlot(%ls)", name);
return true;
}

View File

@@ -31,7 +31,7 @@
#include <utility>
bool CPostProcessor::Init(std::shared_ptr<CD3D12Device> dx12Device,
bool enableEffects)
bool enableEffects, bool report)
{
m_dx12Device = dx12Device;
m_device = dx12Device->GetDevice();
@@ -42,39 +42,48 @@ bool CPostProcessor::Init(std::shared_ptr<CD3D12Device> dx12Device,
std::unique_ptr<CColorTransformEffect> colorTransform(new CColorTransformEffect());
if (colorTransform->Init(m_device))
{
DEBUG_INFO("Created post-processing effect: %s", colorTransform->GetName());
m_effects.push_back(std::move(colorTransform));
}
else
{
DEBUG_ERROR("Failed to create post-processing effect: %s",
colorTransform->GetName());
return false;
}
std::unique_ptr<CDownsampleEffect> downsample(new CDownsampleEffect());
if (downsample->Init(m_device))
{
DEBUG_INFO("Created post-processing effect: %s", downsample->GetName());
if (downsample->Init(m_device, report))
m_effects.push_back(std::move(downsample));
}
std::unique_ptr<CHDR16to10Effect> hdr16to10(new CHDR16to10Effect());
if (hdr16to10->Init(m_device))
{
DEBUG_INFO("Created post-processing effect: %s", hdr16to10->GetName());
m_effects.push_back(std::move(hdr16to10));
}
else
{
DEBUG_ERROR("Failed to create post-processing effect: %s",
hdr16to10->GetName());
return false;
}
std::unique_ptr<CRGB24Effect> rgb24(new CRGB24Effect());
if (rgb24->Init(m_device))
{
DEBUG_INFO("Created post-processing effect: %s", rgb24->GetName());
m_effects.push_back(std::move(rgb24));
}
return true;
}
void CPostProcessor::LogEffects() const
{
for (const std::unique_ptr<CPostProcessEffect>& effect : m_effects)
DEBUG_INFO("Created post-processing effect: %s", effect->GetName());
}
void CPostProcessor::LogActiveEffects() const
{
for (const std::unique_ptr<CPostProcessEffect>& effect : m_effects)
if (effect->Enabled)
DEBUG_INFO("Post-processing effect active: %s", effect->GetName());
}
void CPostProcessor::Reset()
{
m_effects.clear();
@@ -151,10 +160,12 @@ bool CPostProcessor::RequiresFullDamage() const
}
bool CPostProcessor::Configure(const D12FrameFormat& srcFormat,
bool * formatChanged)
bool * formatChanged, bool * configured)
{
if (formatChanged)
*formatChanged = false;
if (configured)
*configured = false;
if (!NeedsReconfigure(srcFormat))
{
@@ -165,6 +176,9 @@ bool CPostProcessor::Configure(const D12FrameFormat& srcFormat,
return true;
}
if (configured)
*configured = true;
D12FrameFormat oldDst = m_dstFormat;
D12FrameFormat cur = srcFormat;
CPostProcessEffect * outputEffect = nullptr;
@@ -180,7 +194,6 @@ bool CPostProcessor::Configure(const D12FrameFormat& srcFormat,
effectsActive = true;
cur = dst;
outputEffect = effect.get();
DEBUG_INFO("Post-processing effect active: %s", effect->GetName());
break;
case PostProcessStatus::BYPASS_EFFECT:

View File

@@ -116,7 +116,9 @@ private:
public:
bool Init(std::shared_ptr<CD3D12Device> dx12Device,
bool enableEffects);
bool enableEffects, bool report);
void LogEffects() const;
void LogActiveEffects() const;
void Reset();
bool HasSameEffectChain(const CPostProcessor& other) const;
@@ -124,7 +126,8 @@ public:
void Update(const D12FrameFormat& srcFormat);
bool NeedsReconfigure(const D12FrameFormat& srcFormat) const;
bool RequiresFullDamage() const;
bool Configure(const D12FrameFormat& srcFormat, bool * formatChanged);
bool Configure(const D12FrameFormat& srcFormat, bool * formatChanged,
bool * configured);
void AdjustFrameDamage(RECT dirtyRects[], unsigned * nbDirtyRects);
ComPtr<ID3D12Resource> Run(
const ComPtr<ID3D12GraphicsCommandList>& commandList,

View File

@@ -30,7 +30,7 @@
using namespace PostProcessUtil;
bool CDownsampleEffect::ParseRules(const std::wstring& value)
bool CDownsampleEffect::ParseRules(const std::wstring& value, bool report)
{
m_rules.clear();
if (value.empty())
@@ -61,11 +61,13 @@ bool CDownsampleEffect::ParseRules(const std::wstring& value)
if (swscanf_s(start, L"%ux%u:%ux%u",
&rule.x, &rule.y, &rule.targetX, &rule.targetY) != 4)
{
if (report)
DEBUG_ERROR("Unable to parse IDD downsample rule");
m_rules.clear();
return false;
}
if (report)
DEBUG_INFO("idd:downsample rule: %ux%u -> %ux%u%s",
rule.x, rule.y, rule.targetX, rule.targetY,
rule.greater ? " (greater-than)" : "");
@@ -92,9 +94,9 @@ const CDownsampleEffect::Rule * CDownsampleEffect::MatchRule(
return match;
}
bool CDownsampleEffect::Init(const ComPtr<ID3D12Device3>& device)
bool CDownsampleEffect::Init(const ComPtr<ID3D12Device3>& device, bool report)
{
if (!ParseRules(g_settings.ReadStringValue(L"Downsample")))
if (!ParseRules(g_settings.ReadStringValue(L"Downsample"), report))
return false;
D3D12_STATIC_SAMPLER_DESC sampler = {};

View File

@@ -51,13 +51,13 @@ private:
unsigned m_width = 0;
unsigned m_height = 0;
bool ParseRules(const std::wstring& value);
bool ParseRules(const std::wstring& value, bool report);
const Rule * MatchRule(unsigned width, unsigned height) const;
public:
const char * GetName() const override { return "Downsample"; }
bool Init(const ComPtr<ID3D12Device3>& device);
bool Init(const ComPtr<ID3D12Device3>& device, bool report = true);
PostProcessStatus SetFormat(const ComPtr<ID3D12Device3>& device,
const D12FrameFormat& src, D12FrameFormat& dst) override;