Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions framework/cauldron/framework/src/render/dx12/swapchain_dx12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,14 @@ namespace cauldron
CD3DX12_TEXTURE_COPY_LOCATION copySrc(m_pRenderTarget->GetCurrentResource()->GetImpl()->DX12Resource(), 0);
pCmdList->GetImpl()->DX12CmdList()->CopyTextureRegion(&copyDest, 0, 0, 0, &copySrc, nullptr);

ID3D12Fence* pFence;
CauldronThrowOnFail(GetDevice()->GetImpl()->DX12Device()->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&pFence)));
CauldronThrowOnFail(GetDevice()->GetImpl()->DX12CmdQueue(CommandQueue::Graphics)->Signal(pFence, 1));
CauldronThrowOnFail(pCmdList->GetImpl()->DX12CmdList()->Close());
barrier = Barrier::Transition(m_pRenderTarget->GetCurrentResource(), ResourceState::CopySource, ResourceState::Present);
ResourceBarrier(pCmdList, 1, &barrier);

ID3D12CommandList* CmdListList[] = { pCmdList->GetImpl()->DX12CmdList() };
GetDevice()->GetImpl()->DX12CmdQueue(CommandQueue::Graphics)->ExecuteCommandLists(1, CmdListList);
CauldronThrowOnFail(pCmdList->GetImpl()->DX12CmdList()->Close());

// Wait for fence
HANDLE mHandleFenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
pFence->SetEventOnCompletion(1, mHandleFenceEvent);
WaitForSingleObject(mHandleFenceEvent, INFINITE);
CloseHandle(mHandleFenceEvent);
pFence->Release();
std::vector<CommandList*> lists(1);
lists[0] = pCmdList;
GetDevice()->ExecuteCommandListsImmediate(lists, CommandQueue::Graphics);

UINT64* pTimingsBuffer = NULL;
D3D12_RANGE range;
Expand All @@ -243,8 +237,6 @@ namespace cauldron
stbi_write_jpg(WStringToString(filePath.c_str()).c_str(), (int)fromDesc.Width, (int)fromDesc.Height, 4, pTimingsBuffer, 100);
pResourceReadBack->Unmap(0, NULL);

GetDevice()->FlushAllCommandQueues();

// Release
pResourceReadBack->Release();
pResourceReadBack = nullptr;
Expand Down