diff --git a/WickedEngine/wiGraphicsDevice_DX12.cpp b/WickedEngine/wiGraphicsDevice_DX12.cpp index 6e006e524..549501b69 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.cpp +++ b/WickedEngine/wiGraphicsDevice_DX12.cpp @@ -1638,10 +1638,8 @@ using namespace dx12_internal; { if (freelist[i].uploadbuffer.desc.size >= staging_size) { - if (freelist[i].fence->GetCompletedValue() == 1) + if (freelist[i].IsCompleted()) { - HRESULT hr = freelist[i].fence->Signal(0); - assert(SUCCEEDED(hr)); cmd = std::move(freelist[i]); std::swap(freelist[i], freelist.back()); freelist.pop_back(); @@ -1685,26 +1683,27 @@ using namespace dx12_internal; { HRESULT hr; + locker.lock(); + cmd.fenceValueSignaled++; + freelist.push_back(cmd); + locker.unlock(); + cmd.commandList->Close(); ID3D12CommandList* commandlists[] = { cmd.commandList.Get() }; device->queues[QUEUE_COPY].queue->ExecuteCommandLists(1, commandlists); - hr = device->queues[QUEUE_COPY].queue->Signal(cmd.fence.Get(), 1); + hr = device->queues[QUEUE_COPY].queue->Signal(cmd.fence.Get(), cmd.fenceValueSignaled); assert(SUCCEEDED(hr)); - hr = device->queues[QUEUE_GRAPHICS].queue->Wait(cmd.fence.Get(), 1); + hr = device->queues[QUEUE_GRAPHICS].queue->Wait(cmd.fence.Get(), cmd.fenceValueSignaled); assert(SUCCEEDED(hr)); - hr = device->queues[QUEUE_COMPUTE].queue->Wait(cmd.fence.Get(), 1); + hr = device->queues[QUEUE_COMPUTE].queue->Wait(cmd.fence.Get(), cmd.fenceValueSignaled); assert(SUCCEEDED(hr)); if (device->queues[QUEUE_VIDEO_DECODE].queue) { - hr = device->queues[QUEUE_VIDEO_DECODE].queue->Wait(cmd.fence.Get(), 1); + hr = device->queues[QUEUE_VIDEO_DECODE].queue->Wait(cmd.fence.Get(), cmd.fenceValueSignaled); assert(SUCCEEDED(hr)); } - - locker.lock(); - freelist.push_back(cmd); - locker.unlock(); } void GraphicsDevice_DX12::DescriptorBinder::init(GraphicsDevice_DX12* device) diff --git a/WickedEngine/wiGraphicsDevice_DX12.h b/WickedEngine/wiGraphicsDevice_DX12.h index e790b7d2e..e45aa781f 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.h +++ b/WickedEngine/wiGraphicsDevice_DX12.h @@ -84,8 +84,10 @@ namespace wi::graphics Microsoft::WRL::ComPtr commandAllocator; Microsoft::WRL::ComPtr commandList; Microsoft::WRL::ComPtr fence; + uint64_t fenceValueSignaled = 0; GPUBuffer uploadbuffer; inline bool IsValid() const { return commandList != nullptr; } + inline bool IsCompleted() const { return fence->GetCompletedValue() >= fenceValueSignaled; } }; wi::vector freelist; diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 3ed561942..2980bf22d 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 269; + const int revision = 270; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);