Bug 1068613 - Part 3: Log failures in D2D, D2D 1.1 and the D3D11 TextureClient. r=bas
authorNicolas Silva <nsilva@mozilla.com>
Wed, 17 Sep 2014 23:23:09 +0200
changeset 205910 011c41a9da9f6e0db78e88ef83a92fb39f3ac680
parent 205909 4a1a9df5a8d6411c80837b3feecec3753464c865
child 205911 f023469654ddaa7f6d98d8d6c17efb449fcb12be
push id27507
push userryanvm@gmail.com
push dateThu, 18 Sep 2014 02:16:54 +0000
treeherdermozilla-central@488d490da742 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs1068613
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1068613 - Part 3: Log failures in D2D, D2D 1.1 and the D3D11 TextureClient. r=bas
gfx/2d/DrawTargetD2D.cpp
gfx/2d/DrawTargetD2D1.cpp
gfx/layers/d3d11/TextureD3D11.cpp
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -71,34 +71,34 @@ public:
     SurfaceFormat format = mDT->mFormat;
 
     CD3D10_TEXTURE2D_DESC desc(DXGIFormat(format), size.width, size.height,
                                1, 1);
     desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
 
     HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture));
     if (FAILED(hr)) {
-      gfxWarning() << "Failure to create temporary texture. Size: " << size << " Code: " << hr;
+      gfxCriticalError() << "[D2D] CreateTexture2D failure " << size << " Code: " << hr;
       // Crash debug builds but try to recover in release builds.
       MOZ_ASSERT(false);
       return;
     }
     mDT->mDevice->CopyResource(tmpTexture, mDT->mTexture);
 
     D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2DPixelFormat(format));
 
     RefPtr<IDXGISurface> surf;
 
     tmpTexture->QueryInterface((IDXGISurface**)byRef(surf));
 
     hr = mDT->mRT->CreateSharedBitmap(IID_IDXGISurface, surf,
                                       &props, byRef(mOldSurfBitmap));
 
     if (FAILED(hr)) {
-      gfxWarning() << "Failed to create shared bitmap for old surface. Code: " << hr;
+      gfxCriticalError() << "[D2D] CreateSharedBitmap failure " << size << " Code: " << hr;
       // Crash debug builds but try to recover in release builds.
       MOZ_ASSERT(false);
       return;
     }
 
     IntRect clipBounds;
     mClippedArea = mDT->GetClippedGeometry(&clipBounds);
 
@@ -527,18 +527,17 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
                                aSurface->GetSize().height);
     desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
     desc.MiscFlags = D3D10_RESOURCE_MISC_GENERATE_MIPS;
 
     RefPtr<ID3D10Texture2D> mipTexture;
     hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mipTexture));
 
     if (FAILED(hr)) {
-      gfxWarning() << "Failure to create temporary texture. Size: " <<
-        aSurface->GetSize() << " Code: " << hr;
+      gfxCriticalError() << "[D2D] CreateTexture2D failure " << aSurface->GetSize() << " Code: " << hr;
       return;
     }
 
     IntSize dsSize = IntSize(int32_t(aSurface->GetSize().width * (1.7f / aSigma)),
                              int32_t(aSurface->GetSize().height * (1.7f / aSigma)));
 
     if (dsSize.width < 1) {
       dsSize.width = 1;
@@ -555,17 +554,17 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
     desc = CD3D10_TEXTURE2D_DESC(DXGI_FORMAT_B8G8R8A8_UNORM,
                                  dsSize.width,
                                  dsSize.height, 1, 1);
     desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
     RefPtr<ID3D10Texture2D> tmpDSTexture;
     hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpDSTexture));
 
     if (FAILED(hr)) {
-      gfxWarning() << "Failure to create temporary texture. Size: " << dsSize << " Code: " << hr;
+      gfxCriticalError() << "[D2D] CreateTexture2D failure " << dsSize << " Code: " << hr;
       return;
     }
 
     D3D10_BOX box;
     box.left = box.top = box.front = 0;
     box.back = 1;
     box.right = aSurface->GetSize().width;
     box.bottom = aSurface->GetSize().height;
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -614,16 +614,20 @@ DrawTargetD2D1::CreateSourceSurfaceFromD
                                             SurfaceFormat aFormat) const
 {
   RefPtr<ID2D1Bitmap1> bitmap;
 
   HRESULT hr = mDC->CreateBitmap(D2DIntSize(aSize), aData, aStride,
                                  D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_NONE, D2DPixelFormat(aFormat)),
                                  byRef(bitmap));
 
+  if (FAILED(hr)) {
+    gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << aSize << " Code: " << hr;
+  }
+
   if (!bitmap) {
     return nullptr;
   }
 
   return new SourceSurfaceD2D1(bitmap.get(), mDC, aFormat, aSize);
 }
 
 TemporaryRef<DrawTarget>
@@ -699,17 +703,17 @@ DrawTargetD2D1::CreateFilter(FilterType 
 {
   return FilterNodeD2D1::Create(this, mDC, aType);
 }
 
 bool
 DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat)
 {
   HRESULT hr;
-
+`
   hr = Factory::GetD2D1Device()->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, byRef(mDC));
 
   if (FAILED(hr)) {
     gfxWarning() << *this << ": Error " << hr << " failed to initialize new DeviceContext.";
     return false;
   }
 
   RefPtr<IDXGISurface> dxgiSurface;
@@ -723,30 +727,35 @@ DrawTargetD2D1::Init(ID3D11Texture2D* aT
   props.dpiX = 96;
   props.dpiY = 96;
   props.pixelFormat = D2DPixelFormat(aFormat);
   props.colorContext = nullptr;
   props.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET;
   hr = mDC->CreateBitmapFromDxgiSurface(dxgiSurface, props, (ID2D1Bitmap1**)byRef(mBitmap));
 
   if (FAILED(hr)) {
-    gfxWarning() << *this << ": Error " << hr << " failed to create new bitmap.";
+    gfxCriticalError() << "[D2D1.1] CreateBitmapFromDxgiSurface failure Code: " << hr;
     return false;
   }
 
   mFormat = aFormat;
   D3D11_TEXTURE2D_DESC desc;
   aTexture->GetDesc(&desc);
   desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
   mSize.width = desc.Width;
   mSize.height = desc.Height;
   props.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
   props.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM;
 
-  mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mTempBitmap));
+  hr = mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mTempBitmap));
+
+  if (FAILED(hr)) {
+    gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << mSize << " Code: " << hr;
+    return false;
+  }
 
   mDC->SetTarget(mBitmap);
 
   mDC->BeginDraw();
   return true;
 }
 
 bool
@@ -1268,16 +1277,20 @@ DrawTargetD2D1::OptimizeSourceSurface(So
     return nullptr;
   }
 
   RefPtr<ID2D1Bitmap1> bitmap;
   HRESULT hr = mDC->CreateBitmap(D2DIntSize(data->GetSize()), map.mData, map.mStride,
                                  D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_NONE, D2DPixelFormat(data->GetFormat())),
                                  byRef(bitmap));
 
+  if (FAILED(hr)) {
+    gfxCriticalError() << "[D2D1.1] CreateBitmap failure " << data->GetSize() << " Code: " << hr;
+  }
+
   data->Unmap();
 
   if (!bitmap) {
     return data.forget();
   }
 
   return new SourceSurfaceD2D1(bitmap.get(), mDC, data->GetFormat(), data->GetSize());
 }
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -8,16 +8,17 @@
 #include "gfxContext.h"
 #include "Effects.h"
 #include "mozilla/layers/YCbCrImageDataSerializer.h"
 #include "gfxWindowsPlatform.h"
 #include "gfxD2DSurface.h"
 #include "gfx2DGlue.h"
 #include "gfxPrefs.h"
 #include "ReadbackManagerD3D11.h"
+#include "mozilla/gfx/Logging.h"
 
 namespace mozilla {
 
 using namespace gfx;
 
 namespace layers {
 
 static DXGI_FORMAT
@@ -281,16 +282,21 @@ TextureClientD3D11::Unlock()
     desc.BindFlags = 0;
     desc.Usage = D3D10_USAGE_STAGING;
     desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
     desc.MiscFlags = 0;
 
     RefPtr<ID3D10Texture2D> tex;
     HRESULT hr = device->CreateTexture2D(&desc, nullptr, byRef(tex));
 
+    if (FAILED(hr)) {
+      gfx::gfxCriticalError() << "[D3D11] CreateTexture2D failure " << mSize << " Code: " << hr;
+      return false;
+    }
+
     if (SUCCEEDED(hr)) {
       device->CopyResource(tex, mTexture10);
 
       gfxWindowsPlatform::GetPlatform()->GetReadbackManager()->PostTask(tex, mReadbackSink);
     } else {
       mReadbackSink->ProcessReadback(nullptr);
     }
   }
@@ -364,17 +370,17 @@ TextureClientD3D11::AllocateForSurface(g
       D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE);
 
     newDesc.MiscFlags = D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX;
 
     hr = device->CreateTexture2D(&newDesc, nullptr, byRef(mTexture10));
   }
 
   if (FAILED(hr)) {
-    LOGD3D11("Error creating texture for client!");
+    gfx::gfxCriticalError() << "[D3D11] CreateTexture2D failure " << aSize << " Code: " << hr;
     return false;
   }
 
   // Defer clearing to the next time we lock to avoid an extra (expensive) lock.
   mNeedsClear = aFlags & ALLOC_CLEAR_BUFFER;
   mNeedsClearWhite = aFlags & ALLOC_CLEAR_BUFFER_WHITE;
 
   return true;