Backed out changeset 2b05d4e71d11 (
bug 1083071) for Win7 mochitest-1 leaks.
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -309,18 +309,19 @@ gfxWindowsPlatform::gfxWindowsPlatform()
RegisterStrongMemoryReporter(new GfxD2DSurfaceReporter());
mD2DDevice = nullptr;
#endif
RegisterStrongMemoryReporter(new GfxD2DVramReporter());
UpdateRenderMode();
if (gfxPrefs::Direct2DUse1_1()) {
- GetD3D11Device();
+ InitD3D11Devices();
}
+
RegisterStrongMemoryReporter(new GPUAdapterReporter());
}
gfxWindowsPlatform::~gfxWindowsPlatform()
{
mDeviceManager = nullptr;
// not calling FT_Done_FreeType because cairo may still hold references to
@@ -385,20 +386,17 @@ gfxWindowsPlatform::UpdateRenderMode()
bool tryD2D = d2dForceEnabled || (!d2dBlocked && !gfxPrefs::LayersPreferD3D9());
// Do not ever try if d2d is explicitly disabled,
// or if we're not using DWrite fonts.
if (d2dDisabled || mUsingGDIFonts) {
tryD2D = false;
}
- ID3D11Device *device = GetD3D11Device();
- if (isVistaOrHigher && !safeMode && tryD2D && device &&
- DoesD3D11DeviceSupportResourceSharing(device)) {
-
+ if (isVistaOrHigher && !safeMode && tryD2D) {
VerifyD2DDevice(d2dForceEnabled);
if (mD2DDevice) {
mRenderMode = RENDER_DIRECT2D;
mUseDirectWrite = true;
}
} else {
mD2DDevice = nullptr;
}
@@ -1497,77 +1495,19 @@ gfxWindowsPlatform::GetDXGIAdapter()
}
// We leak this module everywhere, we might as well do so here as well.
dxgiModule.disown();
return mAdapter;
}
-// See bug 1083071. On some drivers, Direct3D 11 CreateShaderResourceView fails
-// with E_OUTOFMEMORY.
-bool DoesD3D11DeviceSupportResourceSharing(ID3D11Device *device)
-{
- RefPtr<ID3D11Texture2D> texture;
- D3D11_TEXTURE2D_DESC desc;
- desc.Width = 32;
- desc.Height = 32;
- desc.MipLevels = 1;
- desc.ArraySize = 1;
- desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
- desc.SampleDesc.Count = 1;
- desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.CPUAccessFlags = 0;
- desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
- desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
- if (FAILED(device->CreateTexture2D(&desc, NULL, byRef(texture)))) {
- return false;
- }
-
- HANDLE shareHandle;
- nsRefPtr<IDXGIResource> otherResource;
- if (FAILED(texture->QueryInterface(__uuidof(IDXGIResource),
- getter_AddRefs(otherResource))))
- {
- return false;
- }
-
- if (FAILED(otherResource->GetSharedHandle(&shareHandle))) {
- return false;
- }
-
- nsRefPtr<ID3D11Resource> sharedResource;
- nsRefPtr<ID3D11Texture2D> sharedTexture;
- if (FAILED(device->OpenSharedResource(shareHandle, __uuidof(ID3D11Resource),
- getter_AddRefs(sharedResource))))
- {
- return false;
- }
-
- if (FAILED(sharedResource->QueryInterface(__uuidof(ID3D11Texture2D),
- getter_AddRefs(sharedTexture))))
- {
- return false;
- }
-
- RefPtr<ID3D11ShaderResourceView> sharedView;
-
- // This if(FAILED()) is the one that actually fails on systems affected by bug 1083071.
- if (FAILED(device->CreateShaderResourceView(sharedTexture, NULL, byRef(sharedView)))) {
- return false;
- }
-
- return true;
-}
-
void
gfxWindowsPlatform::InitD3D11Devices()
{
- MOZ_ASSERT(!mD3D11DeviceInitialized);
mD3D11DeviceInitialized = true;
nsModuleHandle d3d11Module(LoadLibrarySystem32(L"d3d11.dll"));
decltype(D3D11CreateDevice)* d3d11CreateDevice = (decltype(D3D11CreateDevice)*)
GetProcAddress(d3d11Module, "D3D11CreateDevice");
if (!d3d11CreateDevice) {
return;
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -300,11 +300,9 @@ private:
mozilla::RefPtr<mozilla::layers::ReadbackManagerD3D11> mD3D11ReadbackManager;
virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size);
// TODO: unify this with mPrefFonts (NB: holds families, not fonts) in gfxPlatformFontList
nsDataHashtable<nsCStringHashKey, nsTArray<nsRefPtr<gfxFontEntry> > > mPrefFonts;
};
-bool DoesD3D11DeviceSupportResourceSharing(ID3D11Device *device);
-
#endif /* GFX_WINDOWS_PLATFORM_H */
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6728,28 +6728,20 @@ nsWindow::GetPreferredCompositorBackends
// We don't currently support using an accelerated layer manager with
// transparent windows so don't even try. I'm also not sure if we even
// want to support this case. See bug 593471
if (!(prefs.mDisableAcceleration ||
mTransparencyMode == eTransparencyTransparent)) {
if (prefs.mPreferOpenGL) {
aHints.AppendElement(LayersBackend::LAYERS_OPENGL);
}
-
- ID3D11Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D11Device();
- if (device && !DoesD3D11DeviceSupportResourceSharing(device))
- {
- // bug 1083071 - bad things - fall back to basic layers
- }
- else {
- if (!prefs.mPreferD3D9) {
- aHints.AppendElement(LayersBackend::LAYERS_D3D11);
- }
- aHints.AppendElement(LayersBackend::LAYERS_D3D9);
- }
+ if (!prefs.mPreferD3D9) {
+ aHints.AppendElement(LayersBackend::LAYERS_D3D11);
+ }
+ aHints.AppendElement(LayersBackend::LAYERS_D3D9);
}
aHints.AppendElement(LayersBackend::LAYERS_BASIC);
}
void
nsWindow::WindowUsesOMTC()
{
ULONG_PTR style = ::GetClassLongPtr(mWnd, GCL_STYLE);