[idd] capture: add direct full-copy workaround

This commit is contained in:
Geoffrey McRae
2026-08-17 04:42:30 +10:00
parent 4e15f3b68b
commit 96c3056cc9
9 changed files with 88 additions and 8 deletions

View File

@@ -19,6 +19,8 @@
*/
#include "capture/CHardwareFrameProcessor.h"
#include "config/CSettings.h"
#include "capture/CFrameProcessorUtil.h"
#include "transport/IFrameTransport.h"
#include "CSRWLock.h"
@@ -76,11 +78,15 @@ CHardwareFrameProcessor::CHardwareFrameProcessor(
CSRWLock * pipelineLock, HANDLE terminateEvent, bool useCadence) :
CFrameProcessor(transport, std::move(dx12), postProcessors,
pipelineLock, terminateEvent),
m_useCadence(useCadence)
m_useCadence(useCadence),
m_forceFullDirectCopy(CSettings::ShouldForceFullDirectCopy())
{
m_candidateAvailableEvent.Attach(
CreateEvent(nullptr, FALSE, FALSE, nullptr));
m_copySubmitEvent.Attach(CreateEvent(nullptr, TRUE, TRUE, nullptr));
if (m_forceFullDirectCopy)
DEBUG_INFO("Forcing full copies to direct transport memory");
}
bool CHardwareFrameProcessor::IsValid() const
@@ -668,12 +674,17 @@ bool CHardwareFrameProcessor::Publish(
RECT copyDirtyRects[LG_MAX_DIRTY_RECTS * 2] = {};
unsigned nbCopyDirtyRects = 0;
const bool fullCopy = CFrameProcessorUtil::BuildCopyDamage(
postProcessor, prepared.targets[i].fullCopy,
previousDirtyRects, nbPreviousDirtyRects,
candidate.dirtyRects, candidate.nbDirtyRects,
candidate.dstFormat.width, candidate.dstFormat.height,
copyDirtyRects, &nbCopyDirtyRects);
// Some GPUs corrupt fragmented writes to the external transport heap.
// An unmapped target is a direct D3D12 transport resource; readback
// targets remain mapped and continue using normal damage copies.
const bool fullCopy =
(m_forceFullDirectCopy && !fbRes->GetMap()) ||
CFrameProcessorUtil::BuildCopyDamage(
postProcessor, prepared.targets[i].fullCopy,
previousDirtyRects, nbPreviousDirtyRects,
candidate.dirtyRects, candidate.nbDirtyRects,
candidate.dstFormat.width, candidate.dstFormat.height,
copyDirtyRects, &nbCopyDirtyRects);
fbRes->SetTiming(
candidate.captureTime, candidate.postProcessStart, publishStart);
fbRes->SetCandidateIndex(candidateIndex);

View File

@@ -73,6 +73,7 @@ private:
CSRWLock m_copySubmitLock;
bool m_publishPending = false;
bool m_useCadence = true;
bool m_forceFullDirectCopy = false;
Wrappers::Event m_candidateAvailableEvent;
Wrappers::Event m_copySubmitEvent;

View File

@@ -96,6 +96,11 @@ class CSettings
return ReadBoolValue(L"LogStatistics");
}
static bool ShouldForceFullDirectCopy()
{
return ReadBoolValue(L"ForceFullDirectCopy");
}
private:
static const wchar_t * RegistryKey()
{