mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
Bug 1146315 - Part 1: Create D3D media device on the ImageBridge thread. r=nical
--HG-- extra : rebase_source : 29a7c9e7fb5ab2726cb9a3868b85a5c0292a38b4
This commit is contained in:
parent
69645b11a3
commit
a5a35423f7
@ -412,6 +412,7 @@ NS_IMPL_ISUPPORTS(D3D9SharedTextureReporter, nsIMemoryReporter)
|
||||
gfxWindowsPlatform::gfxWindowsPlatform()
|
||||
: mD3D11DeviceInitialized(false)
|
||||
, mIsWARP(false)
|
||||
, mCanInitMediaDevice(false)
|
||||
{
|
||||
mUseClearTypeForDownloadableFonts = UNINITIALIZED_VALUE;
|
||||
mUseClearTypeAlways = UNINITIALIZED_VALUE;
|
||||
@ -1589,11 +1590,51 @@ gfxWindowsPlatform::GetD3D11ContentDevice()
|
||||
ID3D11Device*
|
||||
gfxWindowsPlatform::GetD3D11MediaDevice()
|
||||
{
|
||||
if (mD3D11DeviceInitialized) {
|
||||
if (mD3D11MediaDevice) {
|
||||
return mD3D11MediaDevice;
|
||||
}
|
||||
|
||||
InitD3D11Devices();
|
||||
if (!mCanInitMediaDevice) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mCanInitMediaDevice = false;
|
||||
|
||||
nsModuleHandle d3d11Module(LoadLibrarySystem32(L"d3d11.dll"));
|
||||
decltype(D3D11CreateDevice)* d3d11CreateDevice = (decltype(D3D11CreateDevice)*)
|
||||
GetProcAddress(d3d11Module, "D3D11CreateDevice");
|
||||
MOZ_ASSERT(d3d11CreateDevice);
|
||||
|
||||
nsTArray<D3D_FEATURE_LEVEL> featureLevels;
|
||||
if (IsWin8OrLater()) {
|
||||
featureLevels.AppendElement(D3D_FEATURE_LEVEL_11_1);
|
||||
}
|
||||
featureLevels.AppendElement(D3D_FEATURE_LEVEL_11_0);
|
||||
featureLevels.AppendElement(D3D_FEATURE_LEVEL_10_1);
|
||||
featureLevels.AppendElement(D3D_FEATURE_LEVEL_10_0);
|
||||
featureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3);
|
||||
|
||||
RefPtr<IDXGIAdapter1> adapter = GetDXGIAdapter();
|
||||
MOZ_ASSERT(adapter);
|
||||
|
||||
HRESULT hr = E_INVALIDARG;
|
||||
|
||||
MOZ_SEH_TRY{
|
||||
hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
|
||||
D3D11_CREATE_DEVICE_BGRA_SUPPORT,
|
||||
featureLevels.Elements(), featureLevels.Length(),
|
||||
D3D11_SDK_VERSION, byRef(mD3D11MediaDevice), nullptr, nullptr);
|
||||
} MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
mD3D11MediaDevice = nullptr;
|
||||
}
|
||||
|
||||
d3d11Module.disown();
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mD3D11MediaDevice->SetExceptionMode(0);
|
||||
|
||||
return mD3D11MediaDevice;
|
||||
}
|
||||
@ -1959,23 +2000,8 @@ gfxWindowsPlatform::InitD3D11Devices()
|
||||
Factory::SetDirect3D11Device(mD3D11ContentDevice);
|
||||
}
|
||||
|
||||
if (!useWARP || gfxPrefs::LayersD3D11ForceWARP()) {
|
||||
hr = E_INVALIDARG;
|
||||
MOZ_SEH_TRY{
|
||||
hr = d3d11CreateDevice(adapter, useWARP ? D3D_DRIVER_TYPE_WARP : D3D_DRIVER_TYPE_UNKNOWN, nullptr,
|
||||
D3D11_CREATE_DEVICE_BGRA_SUPPORT,
|
||||
featureLevels.Elements(), featureLevels.Length(),
|
||||
D3D11_SDK_VERSION, byRef(mD3D11MediaDevice), nullptr, nullptr);
|
||||
} MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
mD3D11MediaDevice = nullptr;
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
d3d11Module.disown();
|
||||
return;
|
||||
}
|
||||
|
||||
mD3D11MediaDevice->SetExceptionMode(0);
|
||||
if (!useWARP) {
|
||||
mCanInitMediaDevice = true;
|
||||
}
|
||||
|
||||
// We leak these everywhere and we need them our entire runtime anyway, let's
|
||||
|
@ -296,6 +296,7 @@ private:
|
||||
bool mD3D11DeviceInitialized;
|
||||
mozilla::RefPtr<mozilla::layers::ReadbackManagerD3D11> mD3D11ReadbackManager;
|
||||
bool mIsWARP;
|
||||
bool mCanInitMediaDevice;
|
||||
|
||||
virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user