OLD | NEW |
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 "media/gpu/dxva_video_decode_accelerator_win.h" | 5 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #if !defined(OS_WIN) | 9 #if !defined(OS_WIN) |
10 #error This file should only be built on Windows. | 10 #error This file should only be built on Windows. |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 template <class T> | 378 template <class T> |
379 base::win::ScopedComPtr<T> QueryDeviceObjectFromANGLE(int object_type) { | 379 base::win::ScopedComPtr<T> QueryDeviceObjectFromANGLE(int object_type) { |
380 base::win::ScopedComPtr<T> device_object; | 380 base::win::ScopedComPtr<T> device_object; |
381 | 381 |
382 EGLDisplay egl_display = nullptr; | 382 EGLDisplay egl_display = nullptr; |
383 intptr_t egl_device = 0; | 383 intptr_t egl_device = 0; |
384 intptr_t device = 0; | 384 intptr_t device = 0; |
385 | 385 |
386 { | 386 { |
387 TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. GetHardwareDisplay"); | 387 TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. GetHardwareDisplay"); |
388 egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay(); | 388 egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
389 } | 389 } |
390 | 390 |
391 RETURN_ON_FAILURE(gfx::GLSurfaceEGL::HasEGLExtension("EGL_EXT_device_query"), | 391 RETURN_ON_FAILURE(gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_device_query"), |
392 "EGL_EXT_device_query missing", device_object); | 392 "EGL_EXT_device_query missing", device_object); |
393 | 393 |
394 PFNEGLQUERYDISPLAYATTRIBEXTPROC QueryDisplayAttribEXT = nullptr; | 394 PFNEGLQUERYDISPLAYATTRIBEXTPROC QueryDisplayAttribEXT = nullptr; |
395 | 395 |
396 { | 396 { |
397 TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. eglGetProcAddress"); | 397 TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. eglGetProcAddress"); |
398 | 398 |
399 QueryDisplayAttribEXT = reinterpret_cast<PFNEGLQUERYDISPLAYATTRIBEXTPROC>( | 399 QueryDisplayAttribEXT = reinterpret_cast<PFNEGLQUERYDISPLAYATTRIBEXTPROC>( |
400 eglGetProcAddress("eglQueryDisplayAttribEXT")); | 400 eglGetProcAddress("eglQueryDisplayAttribEXT")); |
401 | 401 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 } | 658 } |
659 #endif | 659 #endif |
660 // If we don't find the MFCreateDXGIDeviceManager API we fallback to D3D9 | 660 // If we don't find the MFCreateDXGIDeviceManager API we fallback to D3D9 |
661 // decoding. | 661 // decoding. |
662 if (dxgi_manager_dll && !create_dxgi_device_manager_) { | 662 if (dxgi_manager_dll && !create_dxgi_device_manager_) { |
663 create_dxgi_device_manager_ = reinterpret_cast<CreateDXGIDeviceManager>( | 663 create_dxgi_device_manager_ = reinterpret_cast<CreateDXGIDeviceManager>( |
664 ::GetProcAddress(dxgi_manager_dll, "MFCreateDXGIDeviceManager")); | 664 ::GetProcAddress(dxgi_manager_dll, "MFCreateDXGIDeviceManager")); |
665 } | 665 } |
666 | 666 |
667 RETURN_AND_NOTIFY_ON_FAILURE( | 667 RETURN_AND_NOTIFY_ON_FAILURE( |
668 gfx::g_driver_egl.ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle, | 668 gl::g_driver_egl.ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle, |
669 "EGL_ANGLE_surface_d3d_texture_2d_share_handle unavailable", | 669 "EGL_ANGLE_surface_d3d_texture_2d_share_handle unavailable", |
670 PLATFORM_FAILURE, false); | 670 PLATFORM_FAILURE, false); |
671 | 671 |
672 RETURN_AND_NOTIFY_ON_FAILURE(gfx::GLFence::IsSupported(), | 672 RETURN_AND_NOTIFY_ON_FAILURE(gl::GLFence::IsSupported(), |
673 "GL fences are unsupported", PLATFORM_FAILURE, | 673 "GL fences are unsupported", PLATFORM_FAILURE, |
674 false); | 674 false); |
675 | 675 |
676 State state = GetState(); | 676 State state = GetState(); |
677 RETURN_AND_NOTIFY_ON_FAILURE((state == kUninitialized), | 677 RETURN_AND_NOTIFY_ON_FAILURE((state == kUninitialized), |
678 "Initialize: invalid state: " << state, | 678 "Initialize: invalid state: " << state, |
679 ILLEGAL_STATE, false); | 679 ILLEGAL_STATE, false); |
680 | 680 |
681 media::InitializeMediaFoundation(); | 681 media::InitializeMediaFoundation(); |
682 | 682 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 988 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
989 OutputBuffers::iterator it = output_picture_buffers_.find(picture_buffer_id); | 989 OutputBuffers::iterator it = output_picture_buffers_.find(picture_buffer_id); |
990 if (it == output_picture_buffers_.end()) | 990 if (it == output_picture_buffers_.end()) |
991 return; | 991 return; |
992 | 992 |
993 DXVAPictureBuffer* picture_buffer = it->second.get(); | 993 DXVAPictureBuffer* picture_buffer = it->second.get(); |
994 | 994 |
995 DCHECK(!picture_buffer->available()); | 995 DCHECK(!picture_buffer->available()); |
996 DCHECK(picture_buffer->waiting_to_reuse()); | 996 DCHECK(picture_buffer->waiting_to_reuse()); |
997 | 997 |
998 gfx::GLFence* fence = picture_buffer->reuse_fence(); | 998 gl::GLFence* fence = picture_buffer->reuse_fence(); |
999 RETURN_AND_NOTIFY_ON_FAILURE(make_context_current_cb_.Run(), | 999 RETURN_AND_NOTIFY_ON_FAILURE(make_context_current_cb_.Run(), |
1000 "Failed to make context current", | 1000 "Failed to make context current", |
1001 PLATFORM_FAILURE, ); | 1001 PLATFORM_FAILURE, ); |
1002 if (count <= kMaxIterationsForANGLEReuseFlush && !fence->HasCompleted()) { | 1002 if (count <= kMaxIterationsForANGLEReuseFlush && !fence->HasCompleted()) { |
1003 main_thread_task_runner_->PostDelayedTask( | 1003 main_thread_task_runner_->PostDelayedTask( |
1004 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::WaitForOutputBuffer, | 1004 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::WaitForOutputBuffer, |
1005 weak_this_factory_.GetWeakPtr(), | 1005 weak_this_factory_.GetWeakPtr(), |
1006 picture_buffer_id, count + 1), | 1006 picture_buffer_id, count + 1), |
1007 base::TimeDelta::FromMilliseconds(kFlushDecoderSurfaceTimeoutMs)); | 1007 base::TimeDelta::FromMilliseconds(kFlushDecoderSurfaceTimeoutMs)); |
1008 return; | 1008 return; |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 } | 1420 } |
1421 | 1421 |
1422 hr = decoder_->ProcessMessage(MFT_MESSAGE_SET_D3D_MANAGER, | 1422 hr = decoder_->ProcessMessage(MFT_MESSAGE_SET_D3D_MANAGER, |
1423 device_manager_to_use); | 1423 device_manager_to_use); |
1424 if (use_dx11_) { | 1424 if (use_dx11_) { |
1425 RETURN_ON_HR_FAILURE(hr, "Failed to pass DX11 manager to decoder", false); | 1425 RETURN_ON_HR_FAILURE(hr, "Failed to pass DX11 manager to decoder", false); |
1426 } else { | 1426 } else { |
1427 RETURN_ON_HR_FAILURE(hr, "Failed to pass D3D manager to decoder", false); | 1427 RETURN_ON_HR_FAILURE(hr, "Failed to pass D3D manager to decoder", false); |
1428 } | 1428 } |
1429 | 1429 |
1430 EGLDisplay egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay(); | 1430 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
1431 | 1431 |
1432 EGLint config_attribs[] = {EGL_BUFFER_SIZE, 32, | 1432 EGLint config_attribs[] = {EGL_BUFFER_SIZE, 32, |
1433 EGL_RED_SIZE, 8, | 1433 EGL_RED_SIZE, 8, |
1434 EGL_GREEN_SIZE, 8, | 1434 EGL_GREEN_SIZE, 8, |
1435 EGL_BLUE_SIZE, 8, | 1435 EGL_BLUE_SIZE, 8, |
1436 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, | 1436 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
1437 EGL_ALPHA_SIZE, 0, | 1437 EGL_ALPHA_SIZE, 0, |
1438 EGL_NONE}; | 1438 EGL_NONE}; |
1439 | 1439 |
1440 EGLint num_configs; | 1440 EGLint num_configs; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 // this. This should always be true for Windows 8+. | 1476 // this. This should always be true for Windows 8+. |
1477 // 3. ANGLE is using DX11. | 1477 // 3. ANGLE is using DX11. |
1478 if (create_dxgi_device_manager_ && | 1478 if (create_dxgi_device_manager_ && |
1479 (gl_context->GetGLRenderer().find("Direct3D11") != std::string::npos)) { | 1479 (gl_context->GetGLRenderer().find("Direct3D11") != std::string::npos)) { |
1480 UINT32 dx11_aware = 0; | 1480 UINT32 dx11_aware = 0; |
1481 attributes->GetUINT32(MF_SA_D3D11_AWARE, &dx11_aware); | 1481 attributes->GetUINT32(MF_SA_D3D11_AWARE, &dx11_aware); |
1482 use_dx11_ = !!dx11_aware; | 1482 use_dx11_ = !!dx11_aware; |
1483 } | 1483 } |
1484 | 1484 |
1485 use_keyed_mutex_ = | 1485 use_keyed_mutex_ = |
1486 use_dx11_ && gfx::GLSurfaceEGL::HasEGLExtension("EGL_ANGLE_keyed_mutex"); | 1486 use_dx11_ && gl::GLSurfaceEGL::HasEGLExtension("EGL_ANGLE_keyed_mutex"); |
1487 | 1487 |
1488 if (!use_dx11_ || | 1488 if (!use_dx11_ || |
1489 !gfx::g_driver_egl.ext.b_EGL_ANGLE_stream_producer_d3d_texture_nv12 || | 1489 !gl::g_driver_egl.ext.b_EGL_ANGLE_stream_producer_d3d_texture_nv12 || |
1490 !gfx::g_driver_egl.ext.b_EGL_KHR_stream || | 1490 !gl::g_driver_egl.ext.b_EGL_KHR_stream || |
1491 !gfx::g_driver_egl.ext.b_EGL_KHR_stream_consumer_gltexture || | 1491 !gl::g_driver_egl.ext.b_EGL_KHR_stream_consumer_gltexture || |
1492 !gfx::g_driver_egl.ext.b_EGL_NV_stream_consumer_gltexture_yuv) { | 1492 !gl::g_driver_egl.ext.b_EGL_NV_stream_consumer_gltexture_yuv) { |
1493 share_nv12_textures_ = false; | 1493 share_nv12_textures_ = false; |
1494 } | 1494 } |
1495 | 1495 |
1496 return true; | 1496 return true; |
1497 } | 1497 } |
1498 | 1498 |
1499 bool DXVAVideoDecodeAccelerator::SetDecoderMediaTypes() { | 1499 bool DXVAVideoDecodeAccelerator::SetDecoderMediaTypes() { |
1500 RETURN_ON_FAILURE(SetDecoderInputMediaType(), | 1500 RETURN_ON_FAILURE(SetDecoderInputMediaType(), |
1501 "Failed to set decoder input media type", false); | 1501 "Failed to set decoder input media type", false); |
1502 return SetDecoderOutputMediaType(MFVideoFormat_NV12); | 1502 return SetDecoderOutputMediaType(MFVideoFormat_NV12); |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 DismissStaleBuffers(true); | 2645 DismissStaleBuffers(true); |
2646 Invalidate(); | 2646 Invalidate(); |
2647 Initialize(config_, client_); | 2647 Initialize(config_, client_); |
2648 decoder_thread_task_runner_->PostTask( | 2648 decoder_thread_task_runner_->PostTask( |
2649 FROM_HERE, | 2649 FROM_HERE, |
2650 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2650 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
2651 base::Unretained(this))); | 2651 base::Unretained(this))); |
2652 } | 2652 } |
2653 | 2653 |
2654 } // namespace media | 2654 } // namespace media |
OLD | NEW |