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

Side by Side Diff: media/gpu/dxva_video_decode_accelerator_win.cc

Issue 2827793004: Fix fp16 mode on intel gpus. (Closed)
Patch Set: oops, had an extra file Created 3 years, 8 months 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
« no previous file with comments | « media/gpu/dxva_video_decode_accelerator_win.h ('k') | 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 "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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 processor_->GetProcAmpRange(DXVA2_ProcAmp_Saturation, &range); 791 processor_->GetProcAmpRange(DXVA2_ProcAmp_Saturation, &range);
792 default_procamp_values_.Saturation = range.DefaultValue; 792 default_procamp_values_.Saturation = range.DefaultValue;
793 793
794 return true; 794 return true;
795 } 795 }
796 return false; 796 return false;
797 } 797 }
798 798
799 bool DXVAVideoDecodeAccelerator::CreateDX11DevManager() { 799 bool DXVAVideoDecodeAccelerator::CreateDX11DevManager() {
800 // The device may exist if the last state was a config change. 800 // The device may exist if the last state was a config change.
801 if (d3d11_device_.Get()) 801 if (D3D11Device())
802 return true; 802 return true;
803 HRESULT hr = create_dxgi_device_manager_(&dx11_dev_manager_reset_token_, 803 HRESULT hr = create_dxgi_device_manager_(&dx11_dev_manager_reset_token_,
804 d3d11_device_manager_.Receive()); 804 d3d11_device_manager_.Receive());
805 RETURN_ON_HR_FAILURE(hr, "MFCreateDXGIDeviceManager failed", false); 805 RETURN_ON_HR_FAILURE(hr, "MFCreateDXGIDeviceManager failed", false);
806 806
807 angle_device_ = gl::QueryD3D11DeviceObjectFromANGLE(); 807 angle_device_ = gl::QueryD3D11DeviceObjectFromANGLE();
808 if (!angle_device_) 808 if (!angle_device_)
809 copy_nv12_textures_ = false; 809 copy_nv12_textures_ = false;
810 if (share_nv12_textures_) { 810 if (share_nv12_textures_) {
811 RETURN_ON_FAILURE(angle_device_.Get(), "Failed to get d3d11 device", false); 811 RETURN_ON_FAILURE(angle_device_.Get(), "Failed to get d3d11 device", false);
812 812
813 using_angle_device_ = true; 813 using_angle_device_ = true;
814 d3d11_device_ = angle_device_; 814 }
815 } else { 815
816 if (use_fp16_ || !share_nv12_textures_) {
816 // This array defines the set of DirectX hardware feature levels we support. 817 // This array defines the set of DirectX hardware feature levels we support.
817 // The ordering MUST be preserved. All applications are assumed to support 818 // The ordering MUST be preserved. All applications are assumed to support
818 // 9.1 unless otherwise stated by the application. 819 // 9.1 unless otherwise stated by the application.
819 D3D_FEATURE_LEVEL feature_levels[] = { 820 D3D_FEATURE_LEVEL feature_levels[] = {
820 D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, 821 D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1,
821 D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2, 822 D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2,
822 D3D_FEATURE_LEVEL_9_1}; 823 D3D_FEATURE_LEVEL_9_1};
823 824
824 UINT flags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT; 825 UINT flags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT;
825 826
(...skipping 22 matching lines...) Expand all
848 } 849 }
849 850
850 hr = d3d11_device_.QueryInterface(video_device_.Receive()); 851 hr = d3d11_device_.QueryInterface(video_device_.Receive());
851 RETURN_ON_HR_FAILURE(hr, "Failed to get video device", false); 852 RETURN_ON_HR_FAILURE(hr, "Failed to get video device", false);
852 853
853 hr = d3d11_device_context_.QueryInterface(video_context_.Receive()); 854 hr = d3d11_device_context_.QueryInterface(video_context_.Receive());
854 RETURN_ON_HR_FAILURE(hr, "Failed to get video context", false); 855 RETURN_ON_HR_FAILURE(hr, "Failed to get video context", false);
855 } 856 }
856 857
857 D3D11_FEATURE_DATA_D3D11_OPTIONS options; 858 D3D11_FEATURE_DATA_D3D11_OPTIONS options;
858 hr = d3d11_device_->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &options, 859 hr = D3D11Device()->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &options,
859 sizeof(options)); 860 sizeof(options));
860 RETURN_ON_HR_FAILURE(hr, "Failed to retrieve D3D11 options", false); 861 RETURN_ON_HR_FAILURE(hr, "Failed to retrieve D3D11 options", false);
861 862
862 // Need extended resource sharing so we can share the NV12 texture between 863 // Need extended resource sharing so we can share the NV12 texture between
863 // ANGLE and the decoder context. 864 // ANGLE and the decoder context.
864 if (!options.ExtendedResourceSharing) 865 if (!options.ExtendedResourceSharing)
865 copy_nv12_textures_ = false; 866 copy_nv12_textures_ = false;
866 867
867 UINT nv12_format_support = 0; 868 UINT nv12_format_support = 0;
868 hr = 869 hr =
869 d3d11_device_->CheckFormatSupport(DXGI_FORMAT_NV12, &nv12_format_support); 870 D3D11Device()->CheckFormatSupport(DXGI_FORMAT_NV12, &nv12_format_support);
870 RETURN_ON_HR_FAILURE(hr, "Failed to check NV12 format support", false); 871 RETURN_ON_HR_FAILURE(hr, "Failed to check NV12 format support", false);
871 872
872 if (!(nv12_format_support & D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT)) 873 if (!(nv12_format_support & D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT))
873 copy_nv12_textures_ = false; 874 copy_nv12_textures_ = false;
874 875
875 UINT fp16_format_support = 0; 876 UINT fp16_format_support = 0;
876 hr = d3d11_device_->CheckFormatSupport(DXGI_FORMAT_R16G16B16A16_FLOAT, 877 hr = D3D11Device()->CheckFormatSupport(DXGI_FORMAT_R16G16B16A16_FLOAT,
877 &fp16_format_support); 878 &fp16_format_support);
878 if (FAILED(hr) || 879 if (FAILED(hr) ||
879 !(fp16_format_support & D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT)) 880 !(fp16_format_support & D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT))
880 use_fp16_ = false; 881 use_fp16_ = false;
881 882
882 // Enable multithreaded mode on the device. This ensures that accesses to 883 // Enable multithreaded mode on the device. This ensures that accesses to
883 // context are synchronized across threads. We have multiple threads 884 // context are synchronized across threads. We have multiple threads
884 // accessing the context, the media foundation decoder threads and the 885 // accessing the context, the media foundation decoder threads and the
885 // decoder thread via the video format conversion transform. 886 // decoder thread via the video format conversion transform.
886 hr = multi_threaded_.QueryFrom(d3d11_device_.Get()); 887 hr = multi_threaded_.QueryFrom(D3D11Device());
887 RETURN_ON_HR_FAILURE(hr, "Failed to query ID3D10Multithread", false); 888 RETURN_ON_HR_FAILURE(hr, "Failed to query ID3D10Multithread", false);
888 multi_threaded_->SetMultithreadProtected(TRUE); 889 multi_threaded_->SetMultithreadProtected(TRUE);
889 890
890 hr = d3d11_device_manager_->ResetDevice(d3d11_device_.Get(), 891 hr = d3d11_device_manager_->ResetDevice(D3D11Device(),
891 dx11_dev_manager_reset_token_); 892 dx11_dev_manager_reset_token_);
892 RETURN_ON_HR_FAILURE(hr, "Failed to reset device", false); 893 RETURN_ON_HR_FAILURE(hr, "Failed to reset device", false);
893 894
894 D3D11_QUERY_DESC query_desc; 895 D3D11_QUERY_DESC query_desc;
895 query_desc.Query = D3D11_QUERY_EVENT; 896 query_desc.Query = D3D11_QUERY_EVENT;
896 query_desc.MiscFlags = 0; 897 query_desc.MiscFlags = 0;
897 hr = d3d11_device_->CreateQuery(&query_desc, d3d11_query_.Receive()); 898 hr = D3D11Device()->CreateQuery(&query_desc, d3d11_query_.Receive());
898 RETURN_ON_HR_FAILURE(hr, "Failed to create DX11 device query", false); 899 RETURN_ON_HR_FAILURE(hr, "Failed to create DX11 device query", false);
899 900
900 return true; 901 return true;
901 } 902 }
902 903
903 void DXVAVideoDecodeAccelerator::Decode( 904 void DXVAVideoDecodeAccelerator::Decode(
904 const BitstreamBuffer& bitstream_buffer) { 905 const BitstreamBuffer& bitstream_buffer) {
905 TRACE_EVENT0("media", "DXVAVideoDecodeAccelerator::Decode"); 906 TRACE_EVENT0("media", "DXVAVideoDecodeAccelerator::Decode");
906 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); 907 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
907 908
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 void DXVAVideoDecodeAccelerator::DoDecode(const gfx::ColorSpace& color_space) { 1753 void DXVAVideoDecodeAccelerator::DoDecode(const gfx::ColorSpace& color_space) {
1753 TRACE_EVENT0("media", "DXVAVideoDecodeAccelerator::DoDecode"); 1754 TRACE_EVENT0("media", "DXVAVideoDecodeAccelerator::DoDecode");
1754 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); 1755 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
1755 // This function is also called from FlushInternal in a loop which could 1756 // This function is also called from FlushInternal in a loop which could
1756 // result in the state transitioning to kStopped due to no decoded output. 1757 // result in the state transitioning to kStopped due to no decoded output.
1757 State state = GetState(); 1758 State state = GetState();
1758 RETURN_AND_NOTIFY_ON_FAILURE( 1759 RETURN_AND_NOTIFY_ON_FAILURE(
1759 (state == kNormal || state == kFlushing || state == kStopped), 1760 (state == kNormal || state == kFlushing || state == kStopped),
1760 "DoDecode: not in normal/flushing/stopped state", ILLEGAL_STATE, ); 1761 "DoDecode: not in normal/flushing/stopped state", ILLEGAL_STATE, );
1761 1762
1762 if (d3d11_device_) 1763 if (D3D11Device())
1763 g_last_device_removed_reason = d3d11_device_->GetDeviceRemovedReason(); 1764 g_last_device_removed_reason = D3D11Device()->GetDeviceRemovedReason();
1764 1765
1765 MFT_OUTPUT_DATA_BUFFER output_data_buffer = {0}; 1766 MFT_OUTPUT_DATA_BUFFER output_data_buffer = {0};
1766 DWORD status = 0; 1767 DWORD status = 0;
1767 HRESULT hr; 1768 HRESULT hr;
1768 { 1769 {
1769 ScopedExceptionCatcher catcher(using_ms_vp9_mft_); 1770 ScopedExceptionCatcher catcher(using_ms_vp9_mft_);
1770 g_last_process_output_time = GetCurrentQPC(); 1771 g_last_process_output_time = GetCurrentQPC();
1771 hr = decoder_->ProcessOutput(0, // No flags 1772 hr = decoder_->ProcessOutput(0, // No flags
1772 1, // # of out streams to pull from 1773 1, // # of out streams to pull from
1773 &output_data_buffer, &status); 1774 &output_data_buffer, &status);
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2985 FROM_HERE, 2986 FROM_HERE,
2986 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, 2987 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers,
2987 base::Unretained(this))); 2988 base::Unretained(this)));
2988 } 2989 }
2989 2990
2990 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { 2991 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const {
2991 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; 2992 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_;
2992 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; 2993 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D;
2993 } 2994 }
2994 2995
2996 ID3D11Device* DXVAVideoDecodeAccelerator::D3D11Device() const {
2997 return share_nv12_textures_ ? angle_device_.Get() : d3d11_device_.Get();
2998 }
2999
2995 } // namespace media 3000 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/dxva_video_decode_accelerator_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698