/**
***************************************************************************************************
*   DX12CmdListProfiler::WaitForFence
*
*   @brief
*       Wait for a fence to come back.
***************************************************************************************************
*/
void DX12CmdListProfiler::WaitForFence(UINT64 fenceValue)
{
    if (IsFenceComplete(fenceValue) == false)
    {
        m_pFence->SetEventOnCompletion(fenceValue, m_fenceEvent);
        WaitForSingleObject(m_fenceEvent, INFINITE);
        m_lastCompletedFenceValue = fenceValue;
    }
}
void RenderDeviceD3D12Impl::WaitForFence(Uint64 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<std::mutex> LockGuard(m_EventMutex);

		m_pFence->SetEventOnCompletion(FenceValue, m_FenceEventHandle);
		WaitForSingleObject(m_FenceEventHandle, INFINITE);
		m_LastCompletedFenceValue = FenceValue;
	}
}