mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-04-25 08:06:30 +00:00
[idd] driver: report we are finished with the frame earlier
`IddCxSwapChainFinishedProcessingFrame` must be called after every frame, but we should do it as early as possible once all commands are queued that use the frame.
This commit is contained in:
parent
6dad0de8b8
commit
5b07286c65
@ -134,12 +134,9 @@ void CSwapChainProcessor::SwapChainThreadCore()
|
|||||||
if (buffer.MetaData.PresentationFrameNumber != lastFrameNumber)
|
if (buffer.MetaData.PresentationFrameNumber != lastFrameNumber)
|
||||||
{
|
{
|
||||||
lastFrameNumber = buffer.MetaData.PresentationFrameNumber;
|
lastFrameNumber = buffer.MetaData.PresentationFrameNumber;
|
||||||
SwapChainNewFrame(buffer.MetaData.pSurface);
|
if (!SwapChainNewFrame(buffer.MetaData.pSurface))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IddCxSwapChainFinishedProcessingFrame(m_hSwapChain);
|
|
||||||
if (FAILED(hr))
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -148,21 +145,21 @@ void CSwapChainProcessor::SwapChainThreadCore()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer)
|
bool CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer)
|
||||||
{
|
{
|
||||||
ComPtr<ID3D11Texture2D> texture;
|
ComPtr<ID3D11Texture2D> texture;
|
||||||
HRESULT hr = acquiredBuffer.As(&texture);
|
HRESULT hr = acquiredBuffer.As(&texture);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
DEBUG_ERROR_HR(hr, "Failed to obtain the ID3D11Texture2D from the acquiredBuffer");
|
DEBUG_ERROR_HR(hr, "Failed to obtain the ID3D11Texture2D from the acquiredBuffer");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInteropResource * srcRes = m_resPool.Get(texture);
|
CInteropResource * srcRes = m_resPool.Get(texture);
|
||||||
if (!srcRes)
|
if (!srcRes)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to get a CInteropResource from the pool");
|
DEBUG_ERROR("Failed to get a CInteropResource from the pool");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,7 +179,7 @@ void CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
|
|||||||
srcRes->GetFormat().Format);
|
srcRes->GetFormat().Format);
|
||||||
|
|
||||||
if (!buffer.mem)
|
if (!buffer.mem)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
CFrameBufferResource * fbRes = m_fbPool.Get(buffer,
|
CFrameBufferResource * fbRes = m_fbPool.Get(buffer,
|
||||||
((size_t)srcRes->GetFormat().Width * 4) * srcRes->GetFormat().Height);
|
((size_t)srcRes->GetFormat().Width * 4) * srcRes->GetFormat().Height);
|
||||||
@ -190,7 +187,7 @@ void CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
|
|||||||
if (!fbRes)
|
if (!fbRes)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to get a CFrameBufferResource from the pool");
|
DEBUG_ERROR("Failed to get a CFrameBufferResource from the pool");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_TEXTURE_COPY_LOCATION srcLoc = {};
|
D3D12_TEXTURE_COPY_LOCATION srcLoc = {};
|
||||||
@ -213,12 +210,25 @@ void CSwapChainProcessor::SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer
|
|||||||
&dstLoc, 0, 0, 0, &srcLoc, NULL);
|
&dstLoc, 0, 0, 0, &srcLoc, NULL);
|
||||||
|
|
||||||
m_dx12Device->GetCopyQueue().Execute();
|
m_dx12Device->GetCopyQueue().Execute();
|
||||||
|
|
||||||
|
// report that all GPU processing for this frame has been queued
|
||||||
|
hr = IddCxSwapChainFinishedProcessingFrame(m_hSwapChain);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
DEBUG_ERROR_HR(hr, "IddCxSwapChainFinishedProcessingFrame Failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for the completion
|
||||||
m_dx12Device->GetCopyQueue().Wait();
|
m_dx12Device->GetCopyQueue().Wait();
|
||||||
m_dx12Device->GetCopyQueue().Reset();
|
m_dx12Device->GetCopyQueue().Reset();
|
||||||
|
|
||||||
|
// copy/finialize
|
||||||
if (m_dx12Device->IsIndirectCopy())
|
if (m_dx12Device->IsIndirectCopy())
|
||||||
m_devContext->WriteFrameBuffer(
|
m_devContext->WriteFrameBuffer(
|
||||||
fbRes->GetMap(), 0, fbRes->GetFrameSize(), true);
|
fbRes->GetMap(), 0, fbRes->GetFrameSize(), true);
|
||||||
else
|
else
|
||||||
m_devContext->FinalizeFrameBuffer();
|
m_devContext->FinalizeFrameBuffer();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ private:
|
|||||||
|
|
||||||
void SwapChainThread();
|
void SwapChainThread();
|
||||||
void SwapChainThreadCore();
|
void SwapChainThreadCore();
|
||||||
void SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer);
|
bool SwapChainNewFrame(ComPtr<IDXGIResource> acquiredBuffer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSwapChainProcessor(CIndirectDeviceContext * devContext, IDDCX_SWAPCHAIN hSwapChain,
|
CSwapChainProcessor(CIndirectDeviceContext * devContext, IDDCX_SWAPCHAIN hSwapChain,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user