diff --git a/dom/media/fmp4/wmf/WMFDecoderModule.cpp b/dom/media/fmp4/wmf/WMFDecoderModule.cpp index e33a8b5e843..0fa610c2837 100644 --- a/dom/media/fmp4/wmf/WMFDecoderModule.cpp +++ b/dom/media/fmp4/wmf/WMFDecoderModule.cpp @@ -44,7 +44,8 @@ WMFDecoderModule::Init() if (NS_FAILED(WMFDecoder::LoadDLLs())) { sIsWMFEnabled = false; } - sDXVAEnabled = Preferences::GetBool("media.windows-media-foundation.use-dxva", false); + sDXVAEnabled = !gfxWindowsPlatform::GetPlatform()->IsWARP() && + gfxPlatform::CanUseHardwareVideoDecoding(); } nsresult diff --git a/dom/media/fmp4/wmf/WMFVideoMFTManager.cpp b/dom/media/fmp4/wmf/WMFVideoMFTManager.cpp index f1019c957f3..97992d85533 100644 --- a/dom/media/fmp4/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/fmp4/wmf/WMFVideoMFTManager.cpp @@ -154,11 +154,6 @@ WMFVideoMFTManager::InitializeDXVA() return false; } - if (gfxWindowsPlatform::GetPlatform()->IsWARP() || - !gfxPlatform::CanUseDXVA()) { - return false; - } - // The DXVA manager must be created on the main thread. nsRefPtr event(new CreateDXVAManagerEvent()); NS_DispatchToMainThread(event, NS_DISPATCH_SYNC); diff --git a/dom/media/wmf/WMFReader.cpp b/dom/media/wmf/WMFReader.cpp index d442c377884..4861c0c646d 100644 --- a/dom/media/wmf/WMFReader.cpp +++ b/dom/media/wmf/WMFReader.cpp @@ -84,9 +84,11 @@ WMFReader::~WMFReader() bool WMFReader::InitializeDXVA() { - if (!Preferences::GetBool("media.windows-media-foundation.use-dxva", false)) { + if (gfxWindowsPlatform::GetPlatform()->IsWARP() || + !gfxPlatform::CanUseHardwareVideoDecoding()) { return false; } + MOZ_ASSERT(mDecoder->GetImageContainer()); // Extract the layer manager backend type so that we can determine @@ -111,11 +113,6 @@ WMFReader::InitializeDXVA() return false; } - if (gfxWindowsPlatform::GetPlatform()->IsWARP() || - !gfxPlatform::CanUseDXVA()) { - return false; - } - mDXVA2Manager = DXVA2Manager::Create(); return mDXVA2Manager != nullptr; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 1d3a4f0f233..1bcba331652 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -2170,7 +2170,7 @@ gfxPlatform::OptimalFormatForContent(gfxContentType aContent) */ static bool sLayersSupportsD3D9 = false; static bool sLayersSupportsD3D11 = false; -static bool sLayersSupportsDXVA = false; +static bool sLayersSupportsHardwareVideoDecoding = false; static bool sBufferRotationCheckPref = true; static bool sPrefBrowserTabsRemoteAutostart = false; @@ -2190,37 +2190,41 @@ InitLayersAccelerationPrefs() gfxPrefs::GetSingleton(); sPrefBrowserTabsRemoteAutostart = BrowserTabsRemoteAutostart(); + nsCOMPtr gfxInfo = do_GetService("@mozilla.org/gfx/info;1"); + int32_t status; #ifdef XP_WIN if (gfxPrefs::LayersAccelerationForceEnabled()) { sLayersSupportsD3D9 = true; sLayersSupportsD3D11 = true; - } else { - nsCOMPtr gfxInfo = do_GetService("@mozilla.org/gfx/info;1"); - if (gfxInfo) { - int32_t status; - if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS, &status))) { - if (status == nsIGfxInfo::FEATURE_STATUS_OK) { - sLayersSupportsD3D9 = true; - } + } else if (gfxInfo) { + if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS, &status))) { + if (status == nsIGfxInfo::FEATURE_STATUS_OK) { + sLayersSupportsD3D9 = true; } - if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS, &status))) { - if (status == nsIGfxInfo::FEATURE_STATUS_OK) { - sLayersSupportsD3D11 = true; - } - } - if (!gfxPrefs::LayersD3D11DisableWARP()) { - // Always support D3D11 when WARP is allowed. + } + if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS, &status))) { + if (status == nsIGfxInfo::FEATURE_STATUS_OK) { sLayersSupportsD3D11 = true; } - if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DXVA, &status))) { - if (status == nsIGfxInfo::FEATURE_STATUS_OK) { - sLayersSupportsDXVA = true; - } - } + } + if (!gfxPrefs::LayersD3D11DisableWARP()) { + // Always support D3D11 when WARP is allowed. + sLayersSupportsD3D11 = true; } } #endif + if (Preferences::GetBool("media.hardware-video-decoding.enabled", false) && +#ifdef XP_WIN + Preferences::GetBool("media.windows-media-foundation.use-dxva", true) && +#endif + NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING, + &status))) { + if (status == nsIGfxInfo::FEATURE_STATUS_OK) { + sLayersSupportsHardwareVideoDecoding = true; + } + } + sLayersAccelerationPrefsInitialized = true; } } @@ -2244,12 +2248,12 @@ gfxPlatform::CanUseDirect3D11() } bool -gfxPlatform::CanUseDXVA() +gfxPlatform::CanUseHardwareVideoDecoding() { // this function is called from the compositor thread, so it is not // safe to init the prefs etc. from here. MOZ_ASSERT(sLayersAccelerationPrefsInitialized); - return sLayersSupportsDXVA; + return sLayersSupportsHardwareVideoDecoding; } bool diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 9127397e477..917afa96468 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -497,7 +497,7 @@ public: static bool CanUseDirect3D9(); static bool CanUseDirect3D11(); - static bool CanUseDXVA(); + static bool CanUseHardwareVideoDecoding(); /** * Is it possible to use buffer rotation. Note that these diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index fbc18a20372..4837a40987a 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -271,6 +271,8 @@ pref("media.wakelock_timeout", 2000); // opened as top-level documents, as opposed to inside a media element. pref("media.play-stand-alone", true); +pref("media.hardware-video-decoding.enabled", true); + #if defined(XP_WIN) pref("media.decoder.heuristic.dormant.enabled", true); pref("media.decoder.heuristic.dormant.timeout", 60000); @@ -278,7 +280,6 @@ pref("media.decoder.heuristic.dormant.timeout", 60000); #ifdef MOZ_WMF pref("media.windows-media-foundation.enabled", true); -pref("media.windows-media-foundation.use-dxva", true); #endif #ifdef MOZ_DIRECTSHOW pref("media.directshow.enabled", true); diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index c6fe1e5cacc..154c7f032ec 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -123,8 +123,8 @@ GetPrefNameForFeature(int32_t aFeature) case nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS: name = BLACKLIST_PREF_BRANCH "layers.direct3d11"; break; - case nsIGfxInfo::FEATURE_DXVA: - name = BLACKLIST_PREF_BRANCH "dxva"; + case nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING: + name = BLACKLIST_PREF_BRANCH "hardwarevideodecoding"; break; case nsIGfxInfo::FEATURE_OPENGL_LAYERS: name = BLACKLIST_PREF_BRANCH "layers.opengl"; @@ -290,8 +290,8 @@ BlacklistFeatureToGfxFeature(const nsAString& aFeature) return nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS; else if (aFeature.EqualsLiteral("DIRECT3D_11_LAYERS")) return nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS; - else if (aFeature.EqualsLiteral("DXVA")) - return nsIGfxInfo::FEATURE_DXVA; + else if (aFeature.EqualsLiteral("HARDWARE_VIDEO_DECODING")) + return nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING; else if (aFeature.EqualsLiteral("OPENGL_LAYERS")) return nsIGfxInfo::FEATURE_OPENGL_LAYERS; else if (aFeature.EqualsLiteral("WEBGL_OPENGL")) @@ -858,7 +858,7 @@ GfxInfoBase::EvaluateDownloadedBlacklist(nsTArray& aDriverInfo) nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS, nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS, nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS, - nsIGfxInfo::FEATURE_DXVA, + nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING, nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_WEBGL_ANGLE, diff --git a/widget/nsIGfxInfo.idl b/widget/nsIGfxInfo.idl index b5537c95c72..4eb9953505e 100644 --- a/widget/nsIGfxInfo.idl +++ b/widget/nsIGfxInfo.idl @@ -8,7 +8,7 @@ /* NOTE: this interface is completely undesigned, not stable and likely to change */ -[scriptable, uuid(f5b38c7d-142e-4a94-8097-b2e083f8c19b)] +[scriptable, uuid(b0541ea1-58c8-4c16-b3ea-94b3e14236d2)] interface nsIGfxInfo : nsISupports { /* @@ -87,8 +87,8 @@ interface nsIGfxInfo : nsISupports const long FEATURE_WEBRTC_HW_ACCELERATION = 10; /* Whether Direct3D 11 is supported for layers. */ const long FEATURE_DIRECT3D_11_LAYERS = 11; - /* Whether DXVA is supported for video decoding. */ - const long FEATURE_DXVA = 12; + /* Whether hardware accelerated video decoding is supported. */ + const long FEATURE_HARDWARE_VIDEO_DECODING = 12; /* * A set of return values from GetFeatureStatus diff --git a/widget/windows/GfxInfo.cpp b/widget/windows/GfxInfo.cpp index 2c9555bf363..e86c79d9a79 100644 --- a/widget/windows/GfxInfo.cpp +++ b/widget/windows/GfxInfo.cpp @@ -1092,13 +1092,13 @@ GfxInfo::GetGfxDriverInfo() APPEND_TO_DRIVER_BLOCKLIST2(DRIVER_OS_ALL, (nsAString&)GfxDriverInfo::GetDeviceVendor(VendorATI), (GfxDeviceFamily*)GfxDriverInfo::GetDeviceFamily(AMDRadeonHD5800), - nsIGfxInfo::FEATURE_DXVA, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, + nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions); /* Bug 1139503: DXVA crashes with ATI cards on windows 10. */ APPEND_TO_DRIVER_BLOCKLIST2(DRIVER_OS_WINDOWS_10, (nsAString&)GfxDriverInfo::GetDeviceVendor(VendorATI), GfxDriverInfo::allDevices, - nsIGfxInfo::FEATURE_DXVA, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, + nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL, V(15,200,1006,0)); /* Bug 1137716: XXX this should really check for the matching Intel piece as well.