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

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)
@@ -73,6 +73,10 @@
log << ", HRESULT: 0x" << std::hex << result, \
error_code, ret);
+// Maximum number of iterations we allow before aborting the attempt to flush
+// the batched queries to the driver.
+enum { kMaxIterationsForD3DFlush = 10 };
+
static IMFSample* CreateEmptySample() {
base::win::ScopedComPtr<IMFSample> sample;
HRESULT hr = MFCreateSample(sample.Receive());
@@ -396,11 +400,42 @@
// 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);
+
+ // 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.
+ // However we have seen the GetData call for flushing the operations fail
+ // to return success on some intel/ATI GPU drivers thus resulting in an
+ // infinite loop.
+ // Workaround is to have a limit of 10 on the number of iterations for
+ // flushing and if we reach the upper limit, we force a readback from
+ // the ANGLE surface to a temporary surface created in system memory which
+ // ensures that the pending operations on the ANGLE surface complete.
Ami GONE FROM CHROMIUM 2012/11/14 01:26:07 s/complete/completes/
ananta 2012/11/14 03:05:42 Rephrased
+ int iterations = 0;
+ while ((query_->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) &&
+ ++iterations < kMaxIterationsForD3DFlush) {
+ Sleep(1); // Poor-man's Yield().
+ }
+
+ if (iterations > kMaxIterationsForD3DFlush) {
Ami GONE FROM CHROMIUM 2012/11/14 01:26:07 This can never be true.
ananta 2012/11/14 03:05:42 This code has been removed in favor of the BeginFr
+ base::win::ScopedComPtr<IDirect3DSurface9> temp_surface;
+ hr = device_->CreateOffscreenPlainSurface(surface_desc.Width,
Ami GONE FROM CHROMIUM 2012/11/14 01:26:07 IIUC systems that have this problem exhibit it for
ananta 2012/11/14 03:05:42 Removed.
+ surface_desc.Height,
+ D3DFMT_X8R8G8B8,
+ D3DPOOL_SYSTEMMEM,
+ temp_surface.Receive(),
+ NULL);
+ RETURN_ON_HR_FAILURE(hr, "Failed to create system offscreen surface",
+ false);
+ hr = device_->GetRenderTargetData(d3d_surface, temp_surface);
apatrick_chromium 2012/11/14 01:27:49 This call could be asynchronous as well (don't kno
ananta 2012/11/14 03:05:42 Code has been removed.
+ RETURN_ON_HR_FAILURE(hr, "Failed to render decoded data to system memory",
+ false);
+ }
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