Skip to content

Commit

Permalink
WaitForGpu should be no except
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Jan 7, 2016
1 parent a3f25ef commit 85da981
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
Binary file modified VSIX/Direct3DUWPGame.vsix
Binary file not shown.
30 changes: 17 additions & 13 deletions d3d12game_uwp_dr/DeviceResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,20 +415,24 @@ void DX::DeviceResources::Present()
}

// Wait for pending GPU work to complete.
void DX::DeviceResources::WaitForGpu()
void DX::DeviceResources::WaitForGpu() noexcept
{
if (!m_fence)
return;

// Schedule a Signal command in the GPU queue.
DX::ThrowIfFailed(m_commandQueue->Signal(m_fence.Get(), m_fenceValues[m_backBufferIndex]));

// Wait until the Signal has been processed.
DX::ThrowIfFailed(m_fence->SetEventOnCompletion(m_fenceValues[m_backBufferIndex], m_fenceEvent.Get()));
WaitForSingleObjectEx(m_fenceEvent.Get(), INFINITE, FALSE);

// Increment the fence value for the current frame.
m_fenceValues[m_backBufferIndex]++;
if (m_commandQueue && m_fence && m_fenceEvent.IsValid())
{
// Schedule a Signal command in the GPU queue.
UINT64 fenceValue = m_fenceValues[m_backBufferIndex];
if (SUCCEEDED(m_commandQueue->Signal(m_fence.Get(), fenceValue)))
{
// Wait until the Signal has been processed.
if (SUCCEEDED(m_fence->SetEventOnCompletion(fenceValue, m_fenceEvent.Get())))
{
WaitForSingleObjectEx(m_fenceEvent.Get(), INFINITE, FALSE);

// Increment the fence value for the current frame.
m_fenceValues[m_backBufferIndex]++;
}
}
}
}

// Prepare to render the next frame.
Expand Down
2 changes: 1 addition & 1 deletion d3d12game_uwp_dr/DeviceResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace DX
void RegisterDeviceNotify(IDeviceNotify* deviceNotify) { m_deviceNotify = deviceNotify; }
void Prepare();
void Present();
void WaitForGpu();
void WaitForGpu() noexcept;

// Device Accessors.
RECT GetOutputSize() const { return m_outputSize; }
Expand Down
30 changes: 17 additions & 13 deletions d3d12game_win32_dr/DeviceResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,20 +374,24 @@ void DX::DeviceResources::Present()
}

// Wait for pending GPU work to complete.
void DX::DeviceResources::WaitForGpu()
void DX::DeviceResources::WaitForGpu() noexcept
{
if (!m_fence)
return;

// Schedule a Signal command in the GPU queue.
DX::ThrowIfFailed(m_commandQueue->Signal(m_fence.Get(), m_fenceValues[m_backBufferIndex]));

// Wait until the Signal has been processed.
DX::ThrowIfFailed(m_fence->SetEventOnCompletion(m_fenceValues[m_backBufferIndex], m_fenceEvent.Get()));
WaitForSingleObjectEx(m_fenceEvent.Get(), INFINITE, FALSE);

// Increment the fence value for the current frame.
m_fenceValues[m_backBufferIndex]++;
if (m_commandQueue && m_fence && m_fenceEvent.IsValid())
{
// Schedule a Signal command in the GPU queue.
UINT64 fenceValue = m_fenceValues[m_backBufferIndex];
if (SUCCEEDED(m_commandQueue->Signal(m_fence.Get(), fenceValue)))
{
// Wait until the Signal has been processed.
if (SUCCEEDED(m_fence->SetEventOnCompletion(fenceValue, m_fenceEvent.Get())))
{
WaitForSingleObjectEx(m_fenceEvent.Get(), INFINITE, FALSE);

// Increment the fence value for the current frame.
m_fenceValues[m_backBufferIndex]++;
}
}
}
}

// Prepare to render the next frame.
Expand Down
2 changes: 1 addition & 1 deletion d3d12game_win32_dr/DeviceResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace DX
void RegisterDeviceNotify(IDeviceNotify* deviceNotify) { m_deviceNotify = deviceNotify; }
void Prepare();
void Present();
void WaitForGpu();
void WaitForGpu() noexcept;

// Device Accessors.
RECT GetOutputSize() const { return m_outputSize; }
Expand Down

0 comments on commit 85da981

Please sign in to comment.