Bug 1291084: Unconditionally create all devices as threadsafe. r=mattwoodrow
MozReview-Commit-ID: GWJWd7oXoOb
--- a/gfx/thebes/DeviceManagerDx.cpp
+++ b/gfx/thebes/DeviceManagerDx.cpp
@@ -12,16 +12,17 @@
#include "mozilla/D3DMessageUtils.h"
#include "mozilla/Telemetry.h"
#include "mozilla/WindowsVersion.h"
#include "mozilla/gfx/GraphicsMessages.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/layers/CompositorThread.h"
#include "nsIGfxInfo.h"
#include <d3d11.h>
+#include <d3d11_4.h>
#include <ddraw.h>
namespace mozilla {
namespace gfx {
using namespace mozilla::widget;
StaticAutoPtr<DeviceManagerDx> DeviceManagerDx::sInstance;
@@ -369,19 +370,29 @@ DeviceManagerDx::CreateDevice(IDXGIAdapt
RefPtr<ID3D11Device>& aOutDevice)
{
MOZ_SEH_TRY {
aResOut = sD3D11CreateDeviceFn(
aAdapter, aDriverType, nullptr,
aFlags,
mFeatureLevels.Elements(), mFeatureLevels.Length(),
D3D11_SDK_VERSION, getter_AddRefs(aOutDevice), nullptr, nullptr);
+
} MOZ_SEH_EXCEPT (EXCEPTION_EXECUTE_HANDLER) {
return false;
}
+
+ RefPtr<ID3D10Multithread> mt;
+ HRESULT hr = aOutDevice->QueryInterface((ID3D10Multithread**)getter_AddRefs(mt));
+ if (SUCCEEDED(hr) && mt) {
+ mt->SetMultithreadProtected(TRUE);
+ } else {
+ gfxCriticalError() << "Failed to set device safe for multithreading.";
+ }
+
return true;
}
void
DeviceManagerDx::CreateWARPCompositorDevice()
{
ScopedGfxFeatureReporter reporterWARP("D3D11-WARP", gfxPrefs::LayersD3D11ForceWARP());
FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING);
@@ -478,35 +489,24 @@ DeviceManagerDx::CreateContentDevice()
}
{
MutexAutoLock lock(mDeviceLock);
mContentDevice = device;
}
mContentDevice->SetExceptionMode(0);
- RefPtr<ID3D10Multithread> multi;
- hr = mContentDevice->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi));
- if (SUCCEEDED(hr) && multi) {
- multi->SetMultithreadProtected(TRUE);
- }
return FeatureStatus::Available;
}
RefPtr<ID3D11Device>
DeviceManagerDx::CreateDecoderDevice()
{
if (mCompositorDevice && mCompositorDeviceSupportsVideo && !mDecoderDevice) {
mDecoderDevice = mCompositorDevice;
-
- RefPtr<ID3D10Multithread> multi;
- mDecoderDevice->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi));
- if (multi) {
- multi->SetMultithreadProtected(TRUE);
- }
}
if (mDecoderDevice) {
RefPtr<ID3D11Device> dev = mDecoderDevice;
return dev.forget();
}
if (!sD3D11CreateDeviceFn) {
@@ -526,21 +526,16 @@ DeviceManagerDx::CreateDecoderDevice()
D3D11_CREATE_DEVICE_VIDEO_SUPPORT;
if (!CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, flags, hr, device)) {
return nullptr;
}
if (FAILED(hr) || !device || !D3D11Checks::DoesDeviceWork()) {
return nullptr;
}
- RefPtr<ID3D10Multithread> multi;
- device->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi));
-
- multi->SetMultithreadProtected(TRUE);
-
mDecoderDevice = device;
return device;
}
void
DeviceManagerDx::ResetDevices()
{
MutexAutoLock lock(mDeviceLock);