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_, |