Commit b9293977 by Jamie Madill

Add UMA histogram for D3D11 init failures.

This will give ANGLE in Chrome a sense of device init calls fails in D3D11, and why. BUG=436191 Change-Id: Ia7b1bfa334cec595b6f0265357385d0dcc2d6cbf Reviewed-on: https://chromium-review.googlesource.com/248632Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5cc9ac85
......@@ -9,18 +9,20 @@
#include "libANGLE/Context.h"
#include "common/utilities.h"
#include <iterator>
#include <sstream>
#include "common/platform.h"
#include "libANGLE/Compiler.h"
#include "common/utilities.h"
#include "libANGLE/Buffer.h"
#include "libANGLE/Config.h"
#include "libANGLE/Compiler.h"
#include "libANGLE/Display.h"
#include "libANGLE/Fence.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/Program.h"
#include "libANGLE/Query.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/ResourceManager.h"
#include "libANGLE/Sampler.h"
#include "libANGLE/Surface.h"
......@@ -31,9 +33,6 @@
#include "libANGLE/validationES.h"
#include "libANGLE/renderer/Renderer.h"
#include <sstream>
#include <iterator>
namespace gl
{
......@@ -936,6 +935,7 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*numParams = mCaps.shaderBinaryFormats.size();
}
return true;
case GL_MAX_VERTEX_ATTRIBS:
case GL_MAX_VERTEX_UNIFORM_VECTORS:
case GL_MAX_VARYING_VECTORS:
......
......@@ -87,13 +87,27 @@ namespace egl
Error::Error(EGLint errorCode)
: mCode(errorCode),
mMessage(NULL)
mID(0),
mMessage(nullptr)
{
}
Error::Error(EGLint errorCode, const char *msg, ...)
: mCode(errorCode),
mMessage(NULL)
mID(0),
mMessage(nullptr)
{
va_list vararg;
va_start(vararg, msg);
createMessageString();
*mMessage = FormatString(msg, vararg);
va_end(vararg);
}
Error::Error(EGLint errorCode, EGLint id, const char *msg, ...)
: mCode(errorCode),
mID(id),
mMessage(nullptr)
{
va_list vararg;
va_start(vararg, msg);
......@@ -104,9 +118,10 @@ Error::Error(EGLint errorCode, const char *msg, ...)
Error::Error(const Error &other)
: mCode(other.mCode),
mMessage(NULL)
mID(other.mID),
mMessage(nullptr)
{
if (other.mMessage != NULL)
if (other.mMessage != nullptr)
{
createMessageString();
*mMessage = *(other.mMessage);
......@@ -121,8 +136,9 @@ Error::~Error()
Error &Error::operator=(const Error &other)
{
mCode = other.mCode;
mID = other.mID;
if (other.mMessage != NULL)
if (other.mMessage != nullptr)
{
createMessageString();
*mMessage = *(other.mMessage);
......
......@@ -48,11 +48,13 @@ class Error
public:
explicit Error(EGLint errorCode);
Error(EGLint errorCode, const char *msg, ...);
Error(EGLint errorCode, EGLint id, const char *msg, ...);
Error(const Error &other);
~Error();
Error &operator=(const Error &other);
EGLint getCode() const { return mCode; }
EGLint getID() const { return mID; }
bool isError() const { return (mCode != EGL_SUCCESS); }
const std::string &getMessage() const;
......@@ -61,6 +63,7 @@ class Error
void createMessageString() const;
EGLint mCode;
EGLint mID;
mutable std::string *mMessage;
};
......
......@@ -15,6 +15,7 @@
#include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/SurfaceD3D.h"
#include "libANGLE/renderer/d3d/SwapChainD3D.h"
#include "platform/Platform.h"
#include <EGL/eglext.h>
......@@ -102,6 +103,16 @@ egl::Error CreateRendererD3D(egl::Display *display, RendererD3D **outRenderer)
{
RendererD3D *renderer = rendererCreationFunctions[i](display);
result = renderer->initialize();
if (renderer->getRendererClass() == RENDERER_D3D11)
{
ASSERT(result.getID() >= 0 && result.getID() < NUM_D3D11_INIT_ERRORS);
angle::Platform *platform = angle::Platform::current();
platform->histogramEnumeration("GPU.ANGLE.D3D11InitializeResult",
result.getID(), NUM_D3D11_INIT_ERRORS);
}
if (!result.isError())
{
*outRenderer = renderer;
......
......@@ -48,6 +48,12 @@ enum ShaderType
SHADER_GEOMETRY
};
enum RendererClass
{
RENDERER_D3D11,
RENDERER_D3D9,
};
class RendererD3D : public Renderer
{
public:
......@@ -163,6 +169,8 @@ class RendererD3D : public Renderer
void notifyDeviceLost() override;
virtual bool resetDevice() = 0;
virtual RendererClass getRendererClass() const = 0;
gl::Error getScratchMemoryBuffer(size_t requestedSize, MemoryBuffer **bufferOut);
protected:
......
......@@ -256,7 +256,9 @@ egl::Error Renderer11::initialize()
{
if (!mCompiler.initialize())
{
return egl::Error(EGL_NOT_INITIALIZED, "Failed to initialize compiler.");
return egl::Error(EGL_NOT_INITIALIZED,
D3D11_INIT_COMPILER_ERROR,
"Failed to initialize compiler.");
}
#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
......@@ -265,7 +267,9 @@ egl::Error Renderer11::initialize()
if (mD3d11Module == NULL || mDxgiModule == NULL)
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not load D3D11 or DXGI library.");
return egl::Error(EGL_NOT_INITIALIZED,
D3D11_INIT_MISSING_DEP,
"Could not load D3D11 or DXGI library.");
}
// create the D3D11 device
......@@ -274,7 +278,9 @@ egl::Error Renderer11::initialize()
if (D3D11CreateDevice == NULL)
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not retrieve D3D11CreateDevice address.");
return egl::Error(EGL_NOT_INITIALIZED,
D3D11_INIT_MISSING_DEP,
"Could not retrieve D3D11CreateDevice address.");
}
#endif
......@@ -310,10 +316,20 @@ egl::Error Renderer11::initialize()
&mFeatureLevel,
&mDeviceContext);
if (result == E_INVALIDARG)
{
// Cleanup done by destructor through glDestroyRenderer
return egl::Error(EGL_NOT_INITIALIZED,
D3D11_INIT_CREATEDEVICE_INVALIDARG,
"Could not create D3D11 device.");
}
if (!mDevice || FAILED(result))
{
// Cleanup done by destructor through glDestroyRenderer
return egl::Error(EGL_NOT_INITIALIZED, "Could not create D3D11 device.");
return egl::Error(EGL_NOT_INITIALIZED,
D3D11_INIT_CREATEDEVICE_ERROR,
"Could not create D3D11 device.");
}
}
......@@ -341,7 +357,9 @@ egl::Error Renderer11::initialize()
result = mDevice->QueryInterface(__uuidof(IDXGIDevice2), (void**)&dxgiDevice2);
if (FAILED(result))
{
return egl::Error(EGL_NOT_INITIALIZED, "DXGI 1.2 required to present to HWNDs owned by another process.");
return egl::Error(EGL_NOT_INITIALIZED,
D3D11_INIT_INCOMPATIBLE_DXGI,
"DXGI 1.2 required to present to HWNDs owned by another process.");
}
SafeRelease(dxgiDevice2);
}
......@@ -358,14 +376,18 @@ egl::Error Renderer11::initialize()
if (FAILED(result))
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not query DXGI device.");
return egl::Error(EGL_NOT_INITIALIZED,
D3D11_INIT_OTHER_ERROR,
"Could not query DXGI device.");
}
result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&mDxgiAdapter);
if (FAILED(result))
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not retrieve DXGI adapter");
return egl::Error(EGL_NOT_INITIALIZED,
D3D11_INIT_OTHER_ERROR,
"Could not retrieve DXGI adapter");
}
SafeRelease(dxgiDevice);
......@@ -404,7 +426,9 @@ egl::Error Renderer11::initialize()
if (!mDxgiFactory || FAILED(result))
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not create DXGI factory.");
return egl::Error(EGL_NOT_INITIALIZED,
D3D11_INIT_OTHER_ERROR,
"Could not create DXGI factory.");
}
// Disable some spurious D3D11 debug warnings to prevent them from flooding the output log
......
......@@ -46,6 +46,26 @@ enum
MAX_FRAGMENT_UNIFORM_VECTORS_D3D11 = 1024
};
// Possible reasons RendererD3D initialize can fail
enum D3D11InitError
{
// The renderer loaded successfully
D3D11_INIT_SUCCESS = 0,
// Failed to load the ANGLE & D3D compiler libraries
D3D11_INIT_COMPILER_ERROR,
// Failed to load a necessary DLL (non-compiler)
D3D11_INIT_MISSING_DEP,
// CreateDevice returned E_INVALIDARG
D3D11_INIT_CREATEDEVICE_INVALIDARG,
// CreateDevice failed with an error other than invalid arg
D3D11_INIT_CREATEDEVICE_ERROR,
// DXGI 1.2 required but not found
D3D11_INIT_INCOMPATIBLE_DXGI,
// Other initialization error
D3D11_INIT_OTHER_ERROR,
NUM_D3D11_INIT_ERRORS
};
class Renderer11 : public RendererD3D
{
public:
......@@ -212,6 +232,8 @@ class Renderer11 : public RendererD3D
bool isES3Capable() const;
D3D_FEATURE_LEVEL getFeatureLevel() const { return mFeatureLevel; };
RendererClass getRendererClass() const override { return RENDERER_D3D11; }
private:
DISALLOW_COPY_AND_ASSIGN(Renderer11);
......
......@@ -203,6 +203,8 @@ class Renderer9 : public RendererD3D
gl::Error copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged);
RendererClass getRendererClass() const override { return RENDERER_D3D9; }
private:
DISALLOW_COPY_AND_ASSIGN(Renderer9);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment