From 7b6d8a3148e1279efa7fac40870557a5ca77d7dc Mon Sep 17 00:00:00 2001 From: jbauman Date: Fri, 19 May 2017 15:51:15 -0700 Subject: [PATCH] Wait for GPU to finish before committing first video overlay frame. 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} --- gpu/ipc/service/direct_composition_surface_win.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gpu/ipc/service/direct_composition_surface_win.cc b/gpu/ipc/service/direct_composition_surface_win.cc index b0a2af8ef4f683..921f0a30459877 100644 --- a/gpu/ipc/service/direct_composition_surface_win.cc +++ b/gpu/ipc/service/direct_composition_surface_win.cc @@ -689,6 +689,17 @@ void DCLayerTree::SwapChainPresenter::PresentToSwapChain( base::win::ScopedComPtr 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 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);