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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" 5 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
6 6
7 #if !defined(OS_WIN) 7 #if !defined(OS_WIN)
8 #error This file should only be built on Windows. 8 #error This file should only be built on Windows.
9 #endif // !defined(OS_WIN) 9 #endif // !defined(OS_WIN)
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 StopOnError(error_code); \ 66 StopOnError(error_code); \
67 return ret; \ 67 return ret; \
68 } \ 68 } \
69 } while (0) 69 } while (0)
70 70
71 #define RETURN_AND_NOTIFY_ON_HR_FAILURE(result, log, error_code, ret) \ 71 #define RETURN_AND_NOTIFY_ON_HR_FAILURE(result, log, error_code, ret) \
72 RETURN_AND_NOTIFY_ON_FAILURE(SUCCEEDED(result), \ 72 RETURN_AND_NOTIFY_ON_FAILURE(SUCCEEDED(result), \
73 log << ", HRESULT: 0x" << std::hex << result, \ 73 log << ", HRESULT: 0x" << std::hex << result, \
74 error_code, ret); 74 error_code, ret);
75 75
76 // Maximum number of iterations we allow before aborting the attempt to flush
77 // the batched queries to the driver.
78 enum { kMaxiterationsForD3dFlush = 10 };
Ami GONE FROM CHROMIUM 2012/11/13 23:31:25 s/xi/xI/
ananta 2012/11/14 01:06:47 Done.
79
76 static IMFSample* CreateEmptySample() { 80 static IMFSample* CreateEmptySample() {
77 base::win::ScopedComPtr<IMFSample> sample; 81 base::win::ScopedComPtr<IMFSample> sample;
78 HRESULT hr = MFCreateSample(sample.Receive()); 82 HRESULT hr = MFCreateSample(sample.Receive());
79 RETURN_ON_HR_FAILURE(hr, "MFCreateSample failed", NULL); 83 RETURN_ON_HR_FAILURE(hr, "MFCreateSample failed", NULL);
80 return sample.Detach(); 84 return sample.Detach();
81 } 85 }
82 86
83 // Creates a Media Foundation sample with one buffer of length |buffer_length| 87 // Creates a Media Foundation sample with one buffer of length |buffer_length|
84 // on a |align|-byte boundary. Alignment must be a perfect power of 2 or 0. 88 // on a |align|-byte boundary. Alignment must be a perfect power of 2 or 0.
85 static IMFSample* CreateEmptySampleWithBuffer(int buffer_length, int align) { 89 static IMFSample* CreateEmptySampleWithBuffer(int buffer_length, int align) {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 NULL, 393 NULL,
390 d3d_surface, 394 d3d_surface,
391 NULL, 395 NULL,
392 D3DTEXF_NONE); 396 D3DTEXF_NONE);
393 RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed", 397 RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed",
394 false); 398 false);
395 // Ideally, this should be done immediately before the draw call that uses 399 // Ideally, this should be done immediately before the draw call that uses
396 // the texture. Flush it once here though. 400 // the texture. Flush it once here though.
397 hr = query_->Issue(D3DISSUE_END); 401 hr = query_->Issue(D3DISSUE_END);
398 RETURN_ON_HR_FAILURE(hr, "Failed to issue END", false); 402 RETURN_ON_HR_FAILURE(hr, "Failed to issue END", false);
399 do { 403
400 hr = query_->GetData(NULL, 0, D3DGETDATA_FLUSH); 404 // The loop below attempts to flush the batched queries to the driver. We
401 if (hr == S_FALSE) 405 // don't want to loop endlessly waiting for the driver to return success.
402 Sleep(1); // Poor-man's Yield(). 406 // The current workaround is to allow a max of kMaxiterationsForD3dFlush
403 } while (hr == S_FALSE); 407 // iterations.
Ami GONE FROM CHROMIUM 2012/11/13 23:31:25 This comment is useless; it restates in English wh
ananta 2012/11/14 01:06:47 Rephrased. There is also some new code which addre
408 int iterations = 0;
409 while ((query_->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE) &&
410 ++iterations < kMaxiterationsForD3dFlush) {
411 Sleep(1); // Poor-man's Yield().
412 }
404 eglBindTexImage( 413 eglBindTexImage(
405 static_cast<EGLDisplay*>(eglGetDisplay(EGL_DEFAULT_DISPLAY)), 414 static_cast<EGLDisplay*>(eglGetDisplay(EGL_DEFAULT_DISPLAY)),
406 decoding_surface_, 415 decoding_surface_,
407 EGL_BACK_BUFFER); 416 EGL_BACK_BUFFER);
408 } else { 417 } else {
409 scoped_array<char> bits; 418 scoped_array<char> bits;
410 RETURN_ON_FAILURE(GetBitmapFromSurface(DXVAVideoDecodeAccelerator::device_, 419 RETURN_ON_FAILURE(GetBitmapFromSurface(DXVAVideoDecodeAccelerator::device_,
411 dest_surface, &bits), 420 dest_surface, &bits),
412 "Failed to get bitmap from surface for rendering", 421 "Failed to get bitmap from surface for rendering",
413 false); 422 false);
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 return; 1147 return;
1139 } 1148 }
1140 1149
1141 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 1150 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
1142 &DXVAVideoDecodeAccelerator::NotifyFlushDone, base::AsWeakPtr(this))); 1151 &DXVAVideoDecodeAccelerator::NotifyFlushDone, base::AsWeakPtr(this)));
1143 1152
1144 state_ = kNormal; 1153 state_ = kNormal;
1145 } 1154 }
1146 1155
1147 } // namespace content 1156 } // namespace content
OLDNEW
« 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