From 552d0169446f70bb21485374b8aa8eaf2b4a8cf9 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Thu, 3 Nov 2016 09:57:18 +1300 Subject: [PATCH] Bug 1300678 - Use gfxPrefs for media vars that get accessed from the GPU process. r=jya --- dom/media/MediaPrefs.h | 4 ---- dom/media/platforms/wmf/DXVA2Manager.cpp | 18 +++++------------- dom/media/platforms/wmf/WMFVideoMFTManager.cpp | 10 +++------- gfx/thebes/gfxPrefs.h | 6 ++++++ 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/dom/media/MediaPrefs.h b/dom/media/MediaPrefs.h index f31c04afe6d3..b27594b05cc7 100644 --- a/dom/media/MediaPrefs.h +++ b/dom/media/MediaPrefs.h @@ -124,11 +124,7 @@ private: DECL_MEDIA_PREF("media.wmf.enabled", PDMWMFEnabled, bool, true); DECL_MEDIA_PREF("media.decoder-doctor.wmf-disabled-is-failure", DecoderDoctorWMFDisabledIsFailure, bool, false); DECL_MEDIA_PREF("media.wmf.vp9.enabled", PDMWMFVP9DecoderEnabled, bool, true); - DECL_MEDIA_PREF("media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false); DECL_MEDIA_PREF("media.wmf.decoder.thread-count", PDMWMFThreadCount, int32_t, -1); - DECL_MEDIA_PREF("media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false); - DECL_MEDIA_PREF("media.windows-media-foundation.max-dxva-videos", PDMWMFMaxDXVAVideos, uint32_t, 8); - DECL_MEDIA_PREF("media.windows-media-foundation.allow-d3d11-dxva", PDMWMFAllowD3D11, bool, true); #endif DECL_MEDIA_PREF("media.decoder.fuzzing.enabled", PDMFuzzingEnabled, bool, false); DECL_MEDIA_PREF("media.decoder.fuzzing.video-output-minimum-interval-ms", PDMFuzzingInterval, uint32_t, 0); diff --git a/dom/media/platforms/wmf/DXVA2Manager.cpp b/dom/media/platforms/wmf/DXVA2Manager.cpp index 7148be3dcc5c..6dc6239b2dd8 100644 --- a/dom/media/platforms/wmf/DXVA2Manager.cpp +++ b/dom/media/platforms/wmf/DXVA2Manager.cpp @@ -17,7 +17,7 @@ #include "mozilla/Telemetry.h" #include "MediaTelemetryConstants.h" #include "mfapi.h" -#include "MediaPrefs.h" +#include "gfxPrefs.h" #include "MFTDecoder.h" #include "DriverCrashGuard.h" #include "nsPrintfCString.h" @@ -408,7 +408,7 @@ D3D9DXVA2Manager::Init(layers::KnowsCompositor* aKnowsCompositor, return hr; } - if (adapter.VendorId == 0x1022 && !MediaPrefs::PDMWMFSkipBlacklist()) { + if (adapter.VendorId == 0x1022 && !gfxPrefs::PDMWMFSkipBlacklist()) { for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sAMDPreUVD4); i++) { if (adapter.DeviceId == sAMDPreUVD4[i]) { mIsAMDPreUVD4 = true; @@ -503,11 +503,7 @@ DXVA2Manager::CreateD3D9DXVA(layers::KnowsCompositor* aKnowsCompositor, // DXVA processing takes up a lot of GPU resources, so limit the number of // videos we use DXVA with at any one time. - uint32_t dxvaLimit = 4; - // TODO: Sync this value across to the GPU process. - if (XRE_GetProcessType() != GeckoProcessType_GPU) { - dxvaLimit = MediaPrefs::PDMWMFMaxDXVAVideos(); - } + uint32_t dxvaLimit = gfxPrefs::PDMWMFMaxDXVAVideos(); if (sDXVAVideosCount == dxvaLimit) { aFailureReason.AssignLiteral("Too many DXVA videos playing"); @@ -745,7 +741,7 @@ D3D11DXVA2Manager::Init(layers::KnowsCompositor* aKnowsCompositor, return hr; } - if (adapterDesc.VendorId == 0x1022 && !MediaPrefs::PDMWMFSkipBlacklist()) { + if (adapterDesc.VendorId == 0x1022 && !gfxPrefs::PDMWMFSkipBlacklist()) { for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sAMDPreUVD4); i++) { if (adapterDesc.DeviceId == sAMDPreUVD4[i]) { mIsAMDPreUVD4 = true; @@ -924,11 +920,7 @@ DXVA2Manager::CreateD3D11DXVA(layers::KnowsCompositor* aKnowsCompositor, { // DXVA processing takes up a lot of GPU resources, so limit the number of // videos we use DXVA with at any one time. - uint32_t dxvaLimit = 4; - // TODO: Sync this value across to the GPU process. - if (XRE_GetProcessType() != GeckoProcessType_GPU) { - dxvaLimit = MediaPrefs::PDMWMFMaxDXVAVideos(); - } + uint32_t dxvaLimit = gfxPrefs::PDMWMFMaxDXVAVideos(); if (sDXVAVideosCount == dxvaLimit) { aFailureReason.AssignLiteral("Too many DXVA videos playing"); diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp index 15455ccaa20a..feee32b35261 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -8,7 +8,7 @@ #include #include "WMFVideoMFTManager.h" #include "MediaDecoderReader.h" -#include "MediaPrefs.h" +#include "gfxPrefs.h" #include "WMFUtils.h" #include "ImageContainer.h" #include "VideoUtils.h" @@ -18,7 +18,6 @@ #include "mozilla/ClearOnShutdown.h" #include "mozilla/layers/LayersTypes.h" #include "MediaInfo.h" -#include "MediaPrefs.h" #include "mozilla/Logging.h" #include "mozilla/Preferences.h" #include "nsWindowsHelpers.h" @@ -316,10 +315,8 @@ public: NS_ASSERTION(NS_IsMainThread(), "Must be on main thread."); nsACString* failureReason = &mFailureReason; nsCString secondFailureReason; - bool allowD3D11 = (XRE_GetProcessType() == GeckoProcessType_GPU) || - MediaPrefs::PDMWMFAllowD3D11(); if (mBackend == LayersBackend::LAYERS_D3D11 && - allowD3D11 && IsWin8OrLater()) { + gfxPrefs::PDMWMFAllowD3D11() && IsWin8OrLater()) { const nsCString& blacklistedDLL = FindD3D11BlacklistedDLL(); if (!blacklistedDLL.IsEmpty()) { failureReason->AppendPrintf("D3D11 blacklisted with DLL %s", @@ -447,8 +444,7 @@ WMFVideoMFTManager::InitInternal(bool aForceD3D9) attr->GetUINT32(MF_SA_D3D_AWARE, &aware); attr->SetUINT32(CODECAPI_AVDecNumWorkerThreads, WMFDecoderModule::GetNumDecoderThreads()); - if ((XRE_GetProcessType() != GeckoProcessType_GPU) && - MediaPrefs::PDMWMFLowLatencyEnabled()) { + if (gfxPrefs::PDMWMFLowLatencyEnabled()) { hr = attr->SetUINT32(CODECAPI_AVLowLatencyMode, TRUE); if (SUCCEEDED(hr)) { LOG("Enabling Low Latency Mode"); diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 93aa7838bfa0..6c48e9d2113a 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -541,6 +541,12 @@ private: DECL_GFX_PREF(Once, "media.hardware-video-decoding.force-enabled", HardwareVideoDecodingForceEnabled, bool, false); +#ifdef XP_WIN + DECL_GFX_PREF(Live, "media.windows-media-foundation.allow-d3d11-dxva", PDMWMFAllowD3D11, bool, true); + DECL_GFX_PREF(Live, "media.windows-media-foundation.max-dxva-videos", PDMWMFMaxDXVAVideos, uint32_t, 8); + DECL_GFX_PREF(Live, "media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false); + DECL_GFX_PREF(Live, "media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false); +#endif // These affect how line scrolls from wheel events will be accelerated. DECL_GFX_PREF(Live, "mousewheel.acceleration.factor", MouseWheelAccelerationFactor, int32_t, -1);