From 6337007f89fc3db716913498bea98933dc9baf03 Mon Sep 17 00:00:00 2001 From: Jay Nakum Date: Sat, 12 Apr 2025 13:44:02 +0530 Subject: [PATCH] Addressing the Fence todo. --- MiniEngine/Core/CommandListManager.cpp | 18 ++---------------- MiniEngine/Core/CommandListManager.h | 1 - 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/MiniEngine/Core/CommandListManager.cpp b/MiniEngine/Core/CommandListManager.cpp index dbd509010..609f8bc33 100644 --- a/MiniEngine/Core/CommandListManager.cpp +++ b/MiniEngine/Core/CommandListManager.cpp @@ -36,8 +36,6 @@ void CommandQueue::Shutdown() m_AllocatorPool.Shutdown(); - CloseHandle(m_FenceEventHandle); - m_pFence->Release(); m_pFence = nullptr; @@ -81,9 +79,6 @@ void CommandQueue::Create(ID3D12Device* pDevice) m_pFence->SetName(L"CommandListManager::m_pFence"); m_pFence->Signal((uint64_t)m_Type << 56); - m_FenceEventHandle = CreateEvent(nullptr, false, false, nullptr); - ASSERT(m_FenceEventHandle != NULL); - m_AllocatorPool.Create(pDevice); ASSERT(IsReady()); @@ -171,17 +166,8 @@ void CommandQueue::WaitForFence(uint64_t FenceValue) if (IsFenceComplete(FenceValue)) return; - // TODO: Think about how this might affect a multi-threaded situation. Suppose thread A - // wants to wait for fence 100, then thread B comes along and wants to wait for 99. If - // the fence can only have one event set on completion, then thread B has to wait for - // 100 before it knows 99 is ready. Maybe insert sequential events? - { - std::lock_guard LockGuard(m_EventMutex); - - m_pFence->SetEventOnCompletion(FenceValue, m_FenceEventHandle); - WaitForSingleObject(m_FenceEventHandle, INFINITE); - m_LastCompletedFenceValue = FenceValue; - } + m_pFence->SetEventOnCompletion(FenceValue, NULL); + m_LastCompletedFenceValue = FenceValue; } void CommandListManager::WaitForFence(uint64_t FenceValue) diff --git a/MiniEngine/Core/CommandListManager.h b/MiniEngine/Core/CommandListManager.h index 2802c2b44..a5dd05079 100644 --- a/MiniEngine/Core/CommandListManager.h +++ b/MiniEngine/Core/CommandListManager.h @@ -65,7 +65,6 @@ class CommandQueue ID3D12Fence* m_pFence; uint64_t m_NextFenceValue; uint64_t m_LastCompletedFenceValue; - HANDLE m_FenceEventHandle; };