mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Enable Direct3D 11 in the GPU process. (bug 1294988 part 3, r=mattwoodrow)
This commit is contained in:
parent
e30ff6d169
commit
7df82d4b70
@ -141,6 +141,31 @@ gfxConfig::Reenable(Feature aFeature, Fallback aFallback)
|
||||
state.SetRuntime(FeatureStatus::Available, nullptr);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
gfxConfig::Inherit(Feature aFeature, FeatureStatus aStatus)
|
||||
{
|
||||
FeatureState& state = sConfig->GetState(aFeature);
|
||||
|
||||
switch (aStatus) {
|
||||
case FeatureStatus::Unused:
|
||||
break;
|
||||
case FeatureStatus::Available:
|
||||
gfxConfig::EnableByDefault(aFeature);
|
||||
break;
|
||||
case FeatureStatus::ForceEnabled:
|
||||
gfxConfig::EnableByDefault(aFeature);
|
||||
gfxConfig::UserForceEnable(aFeature, "Inherited from parent process");
|
||||
break;
|
||||
default:
|
||||
gfxConfig::SetDefault(
|
||||
aFeature,
|
||||
false,
|
||||
aStatus,
|
||||
"Disabled in parent process");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
gfxConfig::UseFallback(Fallback aFallback)
|
||||
{
|
||||
|
@ -67,6 +67,9 @@ public:
|
||||
const nsACString& aFailureId = EmptyCString());
|
||||
static void EnableByDefault(Feature aFeature);
|
||||
|
||||
// Inherit a computed value from another process.
|
||||
static void Inherit(Feature aFeature, FeatureStatus aStatus);
|
||||
|
||||
// Set a environment status that overrides both the default and user
|
||||
// statuses; this should be used to disable features based on system
|
||||
// or hardware problems that can be determined up-front. The only
|
||||
|
@ -22,7 +22,9 @@ FeatureState::IsEnabled() const
|
||||
FeatureStatus
|
||||
FeatureState::GetValue() const
|
||||
{
|
||||
AssertInitialized();
|
||||
if (!IsInitialized()) {
|
||||
return FeatureStatus::Unused;
|
||||
}
|
||||
|
||||
if (mRuntime.mStatus != FeatureStatus::Unused) {
|
||||
return mRuntime.mStatus;
|
||||
|
@ -4,6 +4,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "GPUChild.h"
|
||||
#include "gfxConfig.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "GPUProcessHost.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
@ -42,7 +43,15 @@ GPUChild::Init()
|
||||
}
|
||||
|
||||
nsTArray<GfxVarUpdate> updates = gfxVars::FetchNonDefaultVars();
|
||||
SendInit(prefs, updates);
|
||||
|
||||
DevicePrefs devicePrefs;
|
||||
devicePrefs.hwCompositing() = gfxConfig::GetValue(Feature::HW_COMPOSITING);
|
||||
devicePrefs.d3d11Compositing() = gfxConfig::GetValue(Feature::D3D11_COMPOSITING);
|
||||
devicePrefs.d3d9Compositing() = gfxConfig::GetValue(Feature::D3D9_COMPOSITING);
|
||||
devicePrefs.oglCompositing() = gfxConfig::GetValue(Feature::OPENGL_COMPOSITING);
|
||||
devicePrefs.useD2D1() = gfxConfig::GetValue(Feature::DIRECT2D);
|
||||
|
||||
SendInit(prefs, updates, devicePrefs);
|
||||
|
||||
gfxVars::AddReceiver(this);
|
||||
}
|
||||
|
@ -17,6 +17,9 @@
|
||||
#include "VRManager.h"
|
||||
#include "VRManagerParent.h"
|
||||
#include "VsyncBridgeParent.h"
|
||||
#if defined(XP_WIN)
|
||||
# include "mozilla/gfx/DeviceManagerD3D11.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
@ -45,6 +48,9 @@ GPUParent::Init(base::ProcessId aParentPid,
|
||||
gfxPrefs::GetSingleton();
|
||||
gfxConfig::Init();
|
||||
gfxVars::Initialize();
|
||||
#if defined(XP_WIN)
|
||||
DeviceManagerD3D11::Init();
|
||||
#endif
|
||||
CompositorThreadHolder::Start();
|
||||
VRManager::ManagerInit();
|
||||
gfxPlatform::InitNullMetadata();
|
||||
@ -53,7 +59,8 @@ GPUParent::Init(base::ProcessId aParentPid,
|
||||
|
||||
bool
|
||||
GPUParent::RecvInit(nsTArray<GfxPrefSetting>&& prefs,
|
||||
nsTArray<GfxVarUpdate>&& vars)
|
||||
nsTArray<GfxVarUpdate>&& vars,
|
||||
const DevicePrefs& devicePrefs)
|
||||
{
|
||||
const nsTArray<gfxPrefs::Pref*>& globalPrefs = gfxPrefs::all();
|
||||
for (auto& setting : prefs) {
|
||||
@ -63,6 +70,20 @@ GPUParent::RecvInit(nsTArray<GfxPrefSetting>&& prefs,
|
||||
for (const auto& var : vars) {
|
||||
gfxVars::ApplyUpdate(var);
|
||||
}
|
||||
|
||||
// Inherit device preferences.
|
||||
gfxConfig::Inherit(Feature::HW_COMPOSITING, devicePrefs.hwCompositing());
|
||||
gfxConfig::Inherit(Feature::D3D11_COMPOSITING, devicePrefs.d3d11Compositing());
|
||||
gfxConfig::Inherit(Feature::D3D9_COMPOSITING, devicePrefs.d3d9Compositing());
|
||||
gfxConfig::Inherit(Feature::OPENGL_COMPOSITING, devicePrefs.oglCompositing());
|
||||
gfxConfig::Inherit(Feature::DIRECT2D, devicePrefs.useD2D1());
|
||||
|
||||
#if defined(XP_WIN)
|
||||
if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
|
||||
DeviceManagerD3D11::Get()->CreateCompositorDevices();
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -170,6 +191,9 @@ GPUParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
mVsyncBridge->Shutdown();
|
||||
}
|
||||
CompositorThreadHolder::Shutdown();
|
||||
#if defined(XP_WIN)
|
||||
DeviceManagerD3D11::Shutdown();
|
||||
#endif
|
||||
gfxVars::Shutdown();
|
||||
gfxConfig::Shutdown();
|
||||
gfxPrefs::DestroySingleton();
|
||||
|
@ -25,7 +25,8 @@ public:
|
||||
IPC::Channel* aChannel);
|
||||
|
||||
bool RecvInit(nsTArray<GfxPrefSetting>&& prefs,
|
||||
nsTArray<GfxVarUpdate>&& vars) override;
|
||||
nsTArray<GfxVarUpdate>&& vars,
|
||||
const DevicePrefs& devicePrefs) override;
|
||||
bool RecvInitVsyncBridge(Endpoint<PVsyncBridgeParent>&& aVsyncEndpoint) override;
|
||||
bool RecvInitImageBridge(Endpoint<PImageBridgeParent>&& aEndpoint) override;
|
||||
bool RecvInitVRManager(Endpoint<PVRManagerParent>&& aEndpoint) override;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
#include "gfxPoint.h"
|
||||
#include "gfxRect.h"
|
||||
#include "gfxTelemetry.h"
|
||||
#include "gfxTypes.h"
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/gfx/Matrix.h"
|
||||
@ -229,6 +230,14 @@ struct ParamTraits<mozilla::gfx::BackendType>
|
||||
mozilla::gfx::BackendType::BACKEND_LAST>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::gfx::FeatureStatus>
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::gfx::FeatureStatus,
|
||||
mozilla::gfx::FeatureStatus::Unused,
|
||||
mozilla::gfx::FeatureStatus::LAST>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::layers::ScaleMode>
|
||||
: public ContiguousEnumSerializer<
|
||||
|
@ -6,6 +6,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using struct DxgiAdapterDesc from "mozilla/D3DMessageUtils.h";
|
||||
using mozilla::gfx::FeatureStatus from "gfxTelemetry.h";
|
||||
using mozilla::gfx::BackendType from "mozilla/gfx/Types.h";
|
||||
using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
|
||||
|
||||
@ -23,6 +24,15 @@ struct DeviceInitData
|
||||
DxgiAdapterDesc adapter;
|
||||
};
|
||||
|
||||
struct DevicePrefs
|
||||
{
|
||||
FeatureStatus hwCompositing;
|
||||
FeatureStatus d3d11Compositing;
|
||||
FeatureStatus d3d9Compositing;
|
||||
FeatureStatus oglCompositing;
|
||||
FeatureStatus useD2D1;
|
||||
};
|
||||
|
||||
union GfxVarValue
|
||||
{
|
||||
BackendType;
|
||||
|
@ -32,7 +32,9 @@ sync protocol PGPU
|
||||
{
|
||||
parent:
|
||||
// Sent by the UI process to initiate core settings.
|
||||
async Init(GfxPrefSetting[] prefs, GfxVarUpdate[] vars);
|
||||
async Init(GfxPrefSetting[] prefs,
|
||||
GfxVarUpdate[] vars,
|
||||
DevicePrefs devicePrefs);
|
||||
|
||||
async InitVsyncBridge(Endpoint<PVsyncBridgeParent> endpoint);
|
||||
async InitImageBridge(Endpoint<PImageBridgeParent> endpoint);
|
||||
|
@ -48,7 +48,10 @@ enum class FeatureStatus
|
||||
CrashedOnStartup,
|
||||
|
||||
// This feature was attempted but later determined to be broken.
|
||||
Broken
|
||||
Broken,
|
||||
|
||||
// Add new entries above here.
|
||||
LAST
|
||||
};
|
||||
|
||||
const char* FeatureStatusToString(FeatureStatus aStatus);
|
||||
|
@ -311,8 +311,10 @@ DeviceManagerD3D11::CreateCompositorDevice(FeatureState& d3d11)
|
||||
"RenderTargetViews need recreating");
|
||||
}
|
||||
|
||||
// It seems like this may only happen when we're using the NVIDIA gpu
|
||||
D3D11Checks::WarnOnAdapterMismatch(mCompositorDevice);
|
||||
if (XRE_IsParentProcess()) {
|
||||
// It seems like this may only happen when we're using the NVIDIA gpu
|
||||
D3D11Checks::WarnOnAdapterMismatch(mCompositorDevice);
|
||||
}
|
||||
|
||||
mCompositorDevice->SetExceptionMode(0);
|
||||
mIsWARP = false;
|
||||
|
@ -2034,7 +2034,7 @@ gfxWindowsPlatform::GetAcceleratedCompositorBackends(nsTArray<LayersBackend>& aB
|
||||
aBackends.AppendElement(LayersBackend::LAYERS_D3D9);
|
||||
}
|
||||
|
||||
if (DeviceManagerD3D11::Get()->GetCompositorDevice()) {
|
||||
if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
|
||||
aBackends.AppendElement(LayersBackend::LAYERS_D3D11);
|
||||
} else {
|
||||
NS_WARNING("Direct3D 11-accelerated layers are not supported on this system.");
|
||||
|
Loading…
Reference in New Issue
Block a user