| 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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 } | 840 } |
| 841 #endif | 841 #endif |
| 842 if (!d3d11_device_context_) { | 842 if (!d3d11_device_context_) { |
| 843 hr = D3D11CreateDevice( | 843 hr = D3D11CreateDevice( |
| 844 NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, feature_levels, | 844 NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, feature_levels, |
| 845 arraysize(feature_levels), D3D11_SDK_VERSION, d3d11_device_.Receive(), | 845 arraysize(feature_levels), D3D11_SDK_VERSION, d3d11_device_.Receive(), |
| 846 &feature_level_out, d3d11_device_context_.Receive()); | 846 &feature_level_out, d3d11_device_context_.Receive()); |
| 847 RETURN_ON_HR_FAILURE(hr, "Failed to create DX11 device", false); | 847 RETURN_ON_HR_FAILURE(hr, "Failed to create DX11 device", false); |
| 848 } | 848 } |
| 849 | 849 |
| 850 hr = d3d11_device_.QueryInterface(video_device_.Receive()); | 850 hr = d3d11_device_.CopyTo(video_device_.Receive()); |
| 851 RETURN_ON_HR_FAILURE(hr, "Failed to get video device", false); | 851 RETURN_ON_HR_FAILURE(hr, "Failed to get video device", false); |
| 852 | 852 |
| 853 hr = d3d11_device_context_.QueryInterface(video_context_.Receive()); | 853 hr = d3d11_device_context_.CopyTo(video_context_.Receive()); |
| 854 RETURN_ON_HR_FAILURE(hr, "Failed to get video context", false); | 854 RETURN_ON_HR_FAILURE(hr, "Failed to get video context", false); |
| 855 } | 855 } |
| 856 | 856 |
| 857 D3D11_FEATURE_DATA_D3D11_OPTIONS options; | 857 D3D11_FEATURE_DATA_D3D11_OPTIONS options; |
| 858 hr = D3D11Device()->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &options, | 858 hr = D3D11Device()->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &options, |
| 859 sizeof(options)); | 859 sizeof(options)); |
| 860 RETURN_ON_HR_FAILURE(hr, "Failed to retrieve D3D11 options", false); | 860 RETURN_ON_HR_FAILURE(hr, "Failed to retrieve D3D11 options", false); |
| 861 | 861 |
| 862 // Need extended resource sharing so we can share the NV12 texture between | 862 // Need extended resource sharing so we can share the NV12 texture between |
| 863 // ANGLE and the decoder context. | 863 // ANGLE and the decoder context. |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 { | 1302 { |
| 1303 TRACE_EVENT0("gpu,startup", | 1303 TRACE_EVENT0("gpu,startup", |
| 1304 "GetMaxH264Resolution. QueryDeviceObjectFromANGLE"); | 1304 "GetMaxH264Resolution. QueryDeviceObjectFromANGLE"); |
| 1305 | 1305 |
| 1306 device = gl::QueryD3D11DeviceObjectFromANGLE(); | 1306 device = gl::QueryD3D11DeviceObjectFromANGLE(); |
| 1307 if (!device.Get()) | 1307 if (!device.Get()) |
| 1308 return max_resolution; | 1308 return max_resolution; |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 base::win::ScopedComPtr<ID3D11VideoDevice> video_device; | 1311 base::win::ScopedComPtr<ID3D11VideoDevice> video_device; |
| 1312 hr = device.QueryInterface(IID_PPV_ARGS(&video_device)); | 1312 hr = device.CopyTo(IID_PPV_ARGS(&video_device)); |
| 1313 if (FAILED(hr)) | 1313 if (FAILED(hr)) |
| 1314 return max_resolution; | 1314 return max_resolution; |
| 1315 | 1315 |
| 1316 GUID decoder_guid = {}; | 1316 GUID decoder_guid = {}; |
| 1317 | 1317 |
| 1318 { | 1318 { |
| 1319 TRACE_EVENT0("gpu,startup", | 1319 TRACE_EVENT0("gpu,startup", |
| 1320 "GetMaxH264Resolution. H.264 guid search begin"); | 1320 "GetMaxH264Resolution. H.264 guid search begin"); |
| 1321 // Enumerate supported video profiles and look for the H264 profile. | 1321 // Enumerate supported video profiles and look for the H264 profile. |
| 1322 bool found = false; | 1322 bool found = false; |
| (...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2850 video_context_->VideoProcessorSetOutputColorSpace(d3d11_processor_.Get(), | 2850 video_context_->VideoProcessorSetOutputColorSpace(d3d11_processor_.Get(), |
| 2851 &d3d11_color_space); | 2851 &d3d11_color_space); |
| 2852 | 2852 |
| 2853 video_context_->VideoProcessorSetStreamColorSpace(d3d11_processor_.Get(), 0, | 2853 video_context_->VideoProcessorSetStreamColorSpace(d3d11_processor_.Get(), 0, |
| 2854 &d3d11_color_space); | 2854 &d3d11_color_space); |
| 2855 dx11_converter_output_color_space_ = color_space; | 2855 dx11_converter_output_color_space_ = color_space; |
| 2856 } else { | 2856 } else { |
| 2857 dx11_converter_output_color_space_ = gfx::ColorSpace::CreateSRGB(); | 2857 dx11_converter_output_color_space_ = gfx::ColorSpace::CreateSRGB(); |
| 2858 if (use_color_info_ || use_fp16_) { | 2858 if (use_color_info_ || use_fp16_) { |
| 2859 base::win::ScopedComPtr<ID3D11VideoContext1> video_context1; | 2859 base::win::ScopedComPtr<ID3D11VideoContext1> video_context1; |
| 2860 HRESULT hr = video_context_.QueryInterface(video_context1.Receive()); | 2860 HRESULT hr = video_context_.CopyTo(video_context1.Receive()); |
| 2861 if (SUCCEEDED(hr)) { | 2861 if (SUCCEEDED(hr)) { |
| 2862 if (use_fp16_ && | 2862 if (use_fp16_ && |
| 2863 base::CommandLine::ForCurrentProcess()->HasSwitch( | 2863 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2864 switches::kEnableHDR) && | 2864 switches::kEnableHDR) && |
| 2865 color_space.IsHDR()) { | 2865 color_space.IsHDR()) { |
| 2866 // Note, we only use the SCRGBLinear output color space when | 2866 // Note, we only use the SCRGBLinear output color space when |
| 2867 // the input is PQ, because nvidia drivers will not convert | 2867 // the input is PQ, because nvidia drivers will not convert |
| 2868 // G22 to G10 for some reason. | 2868 // G22 to G10 for some reason. |
| 2869 dx11_converter_output_color_space_ = | 2869 dx11_converter_output_color_space_ = |
| 2870 gfx::ColorSpace::CreateSCRGBLinear(); | 2870 gfx::ColorSpace::CreateSCRGBLinear(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3017 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { | 3017 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { |
| 3018 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; | 3018 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; |
| 3019 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; | 3019 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; |
| 3020 } | 3020 } |
| 3021 | 3021 |
| 3022 ID3D11Device* DXVAVideoDecodeAccelerator::D3D11Device() const { | 3022 ID3D11Device* DXVAVideoDecodeAccelerator::D3D11Device() const { |
| 3023 return share_nv12_textures_ ? angle_device_.Get() : d3d11_device_.Get(); | 3023 return share_nv12_textures_ ? angle_device_.Get() : d3d11_device_.Get(); |
| 3024 } | 3024 } |
| 3025 | 3025 |
| 3026 } // namespace media | 3026 } // namespace media |
| OLD | NEW |