Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2348)

Unified Diff: content/common/gpu/media/dxva_video_decode_accelerator.cc

Issue 11369229: Don't wait endlessly for flushing the batched queries sent to the GPU driver during H/W decode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/dxva_video_decode_accelerator.cc
===================================================================
--- content/common/gpu/media/dxva_video_decode_accelerator.cc (revision 167469)
+++ content/common/gpu/media/dxva_video_decode_accelerator.cc (working copy)
@@ -384,7 +384,17 @@
base::win::ScopedComPtr<IDirect3DSurface9> d3d_surface;
HRESULT hr = decoding_texture_->GetSurfaceLevel(0, d3d_surface.Receive());
RETURN_ON_HR_FAILURE(hr, "Failed to get surface from texture", false);
+
+ // Ideally, this should be done immediately before the draw call that uses
+ // the texture. Flush it once here though.
+ hr = query_->Issue(D3DISSUE_END);
ananta 2012/11/14 03:06:48 Issuing the query upfront causes the loop below to
+ RETURN_ON_HR_FAILURE(hr, "Failed to issue END", false);
+ // The BeginScene/EndScene calls below indicate the start/end of rendering.
+ // It is an effort to ensure that pending rendering operations are flushed.
+ hr = device_->BeginScene();
+ RETURN_ON_HR_FAILURE(hr, "BeginScene failed", false);
+
hr = device_->StretchRect(dest_surface,
NULL,
d3d_surface,
@@ -392,15 +402,21 @@
D3DTEXF_NONE);
RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed",
false);
- // Ideally, this should be done immediately before the draw call that uses
- // the texture. Flush it once here though.
- hr = query_->Issue(D3DISSUE_END);
- RETURN_ON_HR_FAILURE(hr, "Failed to issue END", false);
- do {
- hr = query_->GetData(NULL, 0, D3DGETDATA_FLUSH);
- if (hr == S_FALSE)
- Sleep(1); // Poor-man's Yield().
- } while (hr == S_FALSE);
+
+ hr = device_->EndScene();
+ RETURN_ON_HR_FAILURE(hr, "EndScene failed", false);
+
+ // The DXVA decoder has its own device which it uses for decoding. ANGLE
+ // has its own device which we don't have access to.
+ // The above code attempts to copy the decoded picture into a surface
+ // which is owned by ANGLE. As there are multiple devices involved in
+ // this, the StretchRect call above is not synchronous.
+ // We attempt to flush the batched operations to ensure that the picture is
+ // copied to the surface owned by ANGLE.
+ // We need to do this in a loop and call flush multiple times.
+ while (query_->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) {
+ Sleep(1); // Poor-man's Yield().
+ }
eglBindTexImage(
static_cast<EGLDisplay*>(eglGetDisplay(EGL_DEFAULT_DISPLAY)),
decoding_surface_,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698