Bug 1464032 Part 9: Add a D3D11 device to be used on canvas threads in the GPU process. r=jrmuizel

This commit is contained in:
Bob Owen committed 2018-12-02 14:17:02 +00:00
1 parent 1a3a346bca
commit 1239056371
3 files changed
+62 -2

No files matched your search

+5 -1
View File
@@ -205,7 +205,11 @@ mozilla::ipc::IPCResult GPUParent::RecvInit(
#if defined(XP_WIN)
if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
DeviceManagerDx::Get()->CreateCompositorDevices();
if (DeviceManagerDx::Get()->CreateCompositorDevices() &&
gfxVars::RemoteCanvasEnabled()) {
MOZ_ALWAYS_TRUE(DeviceManagerDx::Get()->CreateCanvasDevice());
MOZ_ALWAYS_TRUE(Factory::EnsureDWriteFactory());
}
}
if (gfxVars::UseWebRender()) {
DeviceManagerDx::Get()->CreateDirectCompositionDevice();
+53 -1
View File
@@ -267,6 +267,44 @@ bool DeviceManagerDx::CreateVRDevice() {
return true;
}
bool DeviceManagerDx::CreateCanvasDevice() {
MOZ_ASSERT(ProcessOwnsCompositor());
if (mCanvasDevice) {
return true;
}
if (!LoadD3D11()) {
return false;
}
RefPtr<IDXGIAdapter1> adapter = GetDXGIAdapter();
if (!adapter) {
NS_WARNING("Failed to acquire a DXGI adapter for Canvas");
return false;
}
UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
HRESULT hr;
if (!CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, flags, hr,
mCanvasDevice)) {
gfxCriticalError() << "Crash during D3D11 device creation for Canvas";
return false;
}
if (FAILED(hr) || !mCanvasDevice) {
NS_WARNING("Failed to acquire a D3D11 device for Canvas");
return false;
}
if (XRE_IsGPUProcess()) {
Factory::SetDirect3D11Device(mCanvasDevice);
}
return true;
}
void DeviceManagerDx::CreateDirectCompositionDevice() {
if (!gfxVars::UseWebRenderDCompWin()) {
return;
@@ -866,6 +904,7 @@ void DeviceManagerDx::ResetDevices() {
mMLGDevice = nullptr;
mCompositorDevice = nullptr;
mContentDevice = nullptr;
mCanvasDevice = nullptr;
mImageDevice = nullptr;
mDeviceStatus = Nothing();
mDeviceResetReason = Nothing();
@@ -888,6 +927,7 @@ bool DeviceManagerDx::MaybeResetAndReacquireDevices() {
bool createCompositorDevice = !!mCompositorDevice;
bool createContentDevice = !!mContentDevice;
bool createCanvasDevice = !!mCanvasDevice;
ResetDevices();
@@ -898,6 +938,9 @@ bool DeviceManagerDx::MaybeResetAndReacquireDevices() {
if (createContentDevice) {
CreateContentDevices();
}
if (createCanvasDevice) {
CreateCanvasDevice();
}
return true;
}
@@ -986,7 +1029,8 @@ bool DeviceManagerDx::GetAnyDeviceRemovedReason(DeviceResetReason* aOutReason) {
mDeviceLock.AssertCurrentThreadOwns();
if (DidDeviceReset(mCompositorDevice, aOutReason) ||
DidDeviceReset(mContentDevice, aOutReason)) {
DidDeviceReset(mContentDevice, aOutReason) ||
DidDeviceReset(mCanvasDevice, aOutReason)) {
return true;
}
@@ -1069,6 +1113,14 @@ RefPtr<ID3D11Device> DeviceManagerDx::GetVRDevice() {
return mVRDevice;
}
RefPtr<ID3D11Device> DeviceManagerDx::GetCanvasDevice() {
MutexAutoLock lock(mDeviceLock);
if (!mCanvasDevice) {
CreateCanvasDevice();
}
return mCanvasDevice;
}
RefPtr<IDCompositionDevice> DeviceManagerDx::GetDirectCompositionDevice() {
MutexAutoLock lock(mDeviceLock);
return mDirectCompositionDevice;
+4
View File
@@ -19,6 +19,7 @@
#include <windows.h>
#include <objbase.h>
#include <d3d11.h>
#include <dxgi.h>
#include <dxgi1_6.h>
@@ -56,6 +57,7 @@ class DeviceManagerDx final {
RefPtr<ID3D11Device> GetCompositorDevice();
RefPtr<ID3D11Device> GetContentDevice();
RefPtr<ID3D11Device> GetCanvasDevice();
RefPtr<ID3D11Device> GetImageDevice();
RefPtr<IDCompositionDevice> GetDirectCompositionDevice();
RefPtr<ID3D11Device> GetVRDevice();
@@ -88,6 +90,7 @@ class DeviceManagerDx final {
bool CreateCompositorDevices();
void CreateContentDevices();
void CreateDirectCompositionDevice();
bool CreateCanvasDevice();
void GetCompositorDevices(
RefPtr<ID3D11Device>* aOutDevice,
@@ -165,6 +168,7 @@ class DeviceManagerDx final {
RefPtr<IDXGIAdapter1> mAdapter;
RefPtr<ID3D11Device> mCompositorDevice;
RefPtr<ID3D11Device> mContentDevice;
RefPtr<ID3D11Device> mCanvasDevice;
RefPtr<ID3D11Device> mImageDevice;
RefPtr<ID3D11Device> mVRDevice;
RefPtr<ID3D11Device> mDecoderDevice;