Bug 1149343 - Part 1: Unify prefs/blacklist for hardware acceleration video decoding. r=cpearce

This commit is contained in:
Matt Woodrow 2015-04-01 16:06:56 +13:00
parent 2f71229f66
commit b9044f9109
9 changed files with 45 additions and 47 deletions

View File

@ -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

View File

@ -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<CreateDXVAManagerEvent> event(new CreateDXVAManagerEvent());
NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);

View File

@ -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;

View File

@ -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,14 +2190,13 @@ InitLayersAccelerationPrefs()
gfxPrefs::GetSingleton();
sPrefBrowserTabsRemoteAutostart = BrowserTabsRemoteAutostart();
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
int32_t status;
#ifdef XP_WIN
if (gfxPrefs::LayersAccelerationForceEnabled()) {
sLayersSupportsD3D9 = true;
sLayersSupportsD3D11 = true;
} else {
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
if (gfxInfo) {
int32_t status;
} else if (gfxInfo) {
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS, &status))) {
if (status == nsIGfxInfo::FEATURE_STATUS_OK) {
sLayersSupportsD3D9 = true;
@ -2212,15 +2211,20 @@ InitLayersAccelerationPrefs()
// Always support D3D11 when WARP is allowed.
sLayersSupportsD3D11 = true;
}
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DXVA, &status))) {
if (status == nsIGfxInfo::FEATURE_STATUS_OK) {
sLayersSupportsDXVA = 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

View File

@ -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

View File

@ -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);

View File

@ -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<GfxDriverInfo>& 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,

View File

@ -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

View File

@ -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.