Skip to content

Commit

Permalink
Wait for GPU to finish before committing first video overlay frame.
Browse files Browse the repository at this point in the history
The current code to do CopyResource helps in some cases, but with 4k
videos it still may flicker black before the first frame. Waiting for
the GPU commands to execute before the commit seems to help.

BUG=654631
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2892123002
Cr-Commit-Position: refs/heads/master@{#473373}
  • Loading branch information
jbauman2 authored and Commit bot committed May 19, 2017
1 parent 6ae7018 commit 7b6d8a3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gpu/ipc/service/direct_composition_surface_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,17 @@ void DCLayerTree::SwapChainPresenter::PresentToSwapChain(
base::win::ScopedComPtr<ID3D11DeviceContext> context;
d3d11_device_->GetImmediateContext(context.GetAddressOf());
context->CopyResource(dest_texture.Get(), src_texture.Get());

// Additionally wait for the GPU to finish executing its commands, or
// there still may be a black flicker when presenting expensive content
// (e.g. 4k video).
base::win::ScopedComPtr<IDXGIDevice2> dxgi_device2;
hr = d3d11_device_.CopyTo(dxgi_device2.GetAddressOf());
DCHECK(SUCCEEDED(hr));
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
dxgi_device2->EnqueueSetEvent(event.handle());
event.Wait();
}

swap_chain_->Present(1, 0);
Expand Down

0 comments on commit 7b6d8a3

Please sign in to comment.