mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-09 00:31:31 +00:00
[idd] capture: retain frames in linear buffers
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
build / client-tests (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client-tests (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client-tests (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client-tests (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client-tests (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client-tests (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client-tests (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client-tests (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
build / client-tests (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client-tests (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client-tests (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client-tests (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client-tests (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client-tests (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client-tests (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client-tests (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
Store retained frame candidates in the final linear transport layout. Prepare texture output in local DEFAULT buffers before cadence holding. Then publish full frames with a single buffer copy. Keep partial damage on matching pitched layouts and leave effect-owned buffer copies unchanged. This moves detiling out of the deadline-critical IVSHMEM or readback transfer.
This commit is contained in:
@@ -351,15 +351,14 @@ bool CPostProcessor::ShouldCopyFully(
|
||||
m_copyEffect->ShouldCopyFully(dirtyRects, nbDirtyRects);
|
||||
}
|
||||
|
||||
void CPostProcessor::CopyFrame(
|
||||
void CPostProcessor::CopyToCandidate(
|
||||
const ComPtr<ID3D12GraphicsCommandList>& commandList,
|
||||
ID3D12Resource * dst, ID3D12Resource * src,
|
||||
const RECT dirtyRects[], unsigned nbDirtyRects, bool fullCopy) const
|
||||
ID3D12Resource * dst, ID3D12Resource * src) const
|
||||
{
|
||||
if (m_copyEffect)
|
||||
{
|
||||
m_copyEffect->CopyFrame(
|
||||
commandList, dst, src, dirtyRects, nbDirtyRects, fullCopy);
|
||||
commandList, dst, src, nullptr, 0, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -373,10 +372,36 @@ void CPostProcessor::CopyFrame(
|
||||
dstLoc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||
dstLoc.PlacedFootprint = m_copyLayout;
|
||||
|
||||
commandList->CopyTextureRegion(
|
||||
&dstLoc, 0, 0, 0, &srcLoc, nullptr);
|
||||
}
|
||||
|
||||
void CPostProcessor::CopyFromCandidate(
|
||||
const ComPtr<ID3D12GraphicsCommandList>& commandList,
|
||||
ID3D12Resource * dst, ID3D12Resource * src,
|
||||
const RECT dirtyRects[], unsigned nbDirtyRects, bool fullCopy) const
|
||||
{
|
||||
if (m_copyEffect)
|
||||
{
|
||||
m_copyEffect->CopyFrame(
|
||||
commandList, dst, src, dirtyRects, nbDirtyRects, fullCopy);
|
||||
return;
|
||||
}
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION srcLoc = {};
|
||||
srcLoc.pResource = src;
|
||||
srcLoc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||
srcLoc.PlacedFootprint = m_copyLayout;
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION dstLoc = {};
|
||||
dstLoc.pResource = dst;
|
||||
dstLoc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||
dstLoc.PlacedFootprint = m_copyLayout;
|
||||
|
||||
if (fullCopy)
|
||||
{
|
||||
commandList->CopyTextureRegion(
|
||||
&dstLoc, 0, 0, 0, &srcLoc, nullptr);
|
||||
commandList->CopyBufferRegion(
|
||||
dst, 0, src, 0, m_frameSize);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +183,10 @@ public:
|
||||
size_t GetOutputSize () const { return m_frameSize; }
|
||||
bool ShouldCopyFully(
|
||||
const RECT dirtyRects[], unsigned nbDirtyRects) const;
|
||||
void CopyFrame(
|
||||
void CopyToCandidate(
|
||||
const ComPtr<ID3D12GraphicsCommandList>& commandList,
|
||||
ID3D12Resource * dst, ID3D12Resource * src) const;
|
||||
void CopyFromCandidate(
|
||||
const ComPtr<ID3D12GraphicsCommandList>& commandList,
|
||||
ID3D12Resource * dst, ID3D12Resource * src,
|
||||
const RECT dirtyRects[], unsigned nbDirtyRects, bool fullCopy) const;
|
||||
|
||||
@@ -970,14 +970,23 @@ static bool ResourceDescMatches(
|
||||
}
|
||||
|
||||
bool CSwapChainProcessor::EnsureCandidateResource(
|
||||
unsigned candidateIndex, ID3D12Resource * source)
|
||||
unsigned candidateIndex, size_t frameSize)
|
||||
{
|
||||
FrameCandidate& candidate = m_candidates[candidateIndex];
|
||||
D3D12_RESOURCE_DESC desc = source->GetDesc();
|
||||
desc.Alignment = 0;
|
||||
desc.Flags = static_cast<D3D12_RESOURCE_FLAGS>(
|
||||
static_cast<UINT>(desc.Flags) &
|
||||
~static_cast<UINT>(D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER));
|
||||
|
||||
// Keep the transport layout in local GPU memory so publication does not
|
||||
// combine texture detiling with the IVSHMEM or readback transfer.
|
||||
D3D12_RESOURCE_DESC desc = {};
|
||||
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
desc.Width = frameSize;
|
||||
desc.Height = 1;
|
||||
desc.DepthOrArraySize = 1;
|
||||
desc.MipLevels = 1;
|
||||
desc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||
|
||||
if (candidate.resource &&
|
||||
ResourceDescMatches(candidate.resource->GetDesc(), desc))
|
||||
@@ -1178,7 +1187,7 @@ bool CSwapChainProcessor::PublishNewestCandidate(
|
||||
copySlot->SetCompletionCallback(&CompletionFunction, this, fbRes);
|
||||
|
||||
copySlot->BeginTiming();
|
||||
postProcessor.CopyFrame(
|
||||
postProcessor.CopyFromCandidate(
|
||||
copySlot->GetGfxList(), fbRes->Get().Get(), candidate.resource.Get(),
|
||||
copyDirtyRects, nbCopyDirtyRects, fullCopy);
|
||||
copySlot->EndTiming();
|
||||
@@ -1682,7 +1691,8 @@ bool CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
|
||||
ClipDirtyRects(currentDirtyRects, &nbDirtyRects,
|
||||
dstFormat.width, dstFormat.height);
|
||||
|
||||
if (!EnsureCandidateResource(candidateIndex, copySrcResource.Get()))
|
||||
const size_t frameSize = postProcessor.GetOutputSize();
|
||||
if (!EnsureCandidateResource(candidateIndex, frameSize))
|
||||
{
|
||||
copySlot->Cancel();
|
||||
if (computeSlot)
|
||||
@@ -1696,7 +1706,7 @@ bool CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
|
||||
candidate.dstFormat = dstFormat;
|
||||
candidate.nbDirtyRects = nbDirtyRects;
|
||||
candidate.pitch = postProcessor.GetOutputPitch();
|
||||
candidate.frameSize = postProcessor.GetOutputSize();
|
||||
candidate.frameSize = frameSize;
|
||||
candidate.captureTime = captureTime;
|
||||
candidate.postProcessStart = postProcessStart;
|
||||
candidate.prepareCopyStart = CFrameScheduler::Nanotime();
|
||||
@@ -1714,26 +1724,9 @@ bool CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
|
||||
copySlot->SetCompletionCallback(
|
||||
&CandidateCompletionFunction, this, &candidate);
|
||||
copySlot->BeginTiming();
|
||||
const D3D12_RESOURCE_DESC copySrcDesc = copySrcResource->GetDesc();
|
||||
if (copySrcDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
copySlot->GetGfxList()->CopyBufferRegion(
|
||||
candidate.resource.Get(), 0, copySrcResource.Get(), 0,
|
||||
copySrcDesc.Width);
|
||||
else
|
||||
{
|
||||
D3D12_TEXTURE_COPY_LOCATION srcLocation = {};
|
||||
srcLocation.pResource = copySrcResource.Get();
|
||||
srcLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
srcLocation.SubresourceIndex = 0;
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION dstLocation = {};
|
||||
dstLocation.pResource = candidate.resource.Get();
|
||||
dstLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
dstLocation.SubresourceIndex = 0;
|
||||
|
||||
copySlot->GetGfxList()->CopyTextureRegion(
|
||||
&dstLocation, 0, 0, 0, &srcLocation, nullptr);
|
||||
}
|
||||
postProcessor.CopyToCandidate(
|
||||
copySlot->GetGfxList(), candidate.resource.Get(),
|
||||
copySrcResource.Get());
|
||||
copySlot->EndTiming();
|
||||
|
||||
if (!copySlot->Execute())
|
||||
|
||||
@@ -149,8 +149,8 @@ private:
|
||||
bool HasReadyCandidate();
|
||||
int AcquireCandidate(bool exclusiveSample);
|
||||
void ReleaseCandidate(unsigned candidateIndex);
|
||||
bool EnsureCandidateResource(unsigned candidateIndex,
|
||||
ID3D12Resource * source);
|
||||
bool EnsureCandidateResource(
|
||||
unsigned candidateIndex, size_t frameSize);
|
||||
void ResetCandidates();
|
||||
void SignalCandidateState();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user