Commit 038e725a by Jamie Madill Committed by Commit Bot

D3D11: Use angle::Result error pattern. 2/3

This CL introduces d3d::Context. This new class can wrap a DisplayD3D and a Context9/11 so we can use them through the same code paths. It also refactors the D3D11 resource allocation to always have access to a d3d::Context. Bug: angleproject:2738 Change-Id: I8161acdffee7a868cc26f2d49715413bcca7cc2b Reviewed-on: https://chromium-review.googlesource.com/1151451 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent ad63728b
...@@ -359,4 +359,18 @@ gl::Version DisplayD3D::getMaxSupportedESVersion() const ...@@ -359,4 +359,18 @@ gl::Version DisplayD3D::getMaxSupportedESVersion() const
return mRenderer->getMaxSupportedESVersion(); return mRenderer->getMaxSupportedESVersion();
} }
void DisplayD3D::handleError(HRESULT hr,
const char *message,
const char *file,
const char *function,
unsigned int line)
{
ASSERT(FAILED(hr));
std::stringstream errorStream;
errorStream << "Internal D3D11 error: " << gl::FmtHR(hr) << ", in " << file << ", " << function
<< ":" << line << ". " << message;
mStoredErrorString = errorStream.str();
}
} // namespace rx } // namespace rx
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
#include "libANGLE/renderer/DisplayImpl.h" #include "libANGLE/renderer/DisplayImpl.h"
#include "libANGLE/Device.h" #include "libANGLE/Device.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
namespace rx namespace rx
{ {
class RendererD3D; class DisplayD3D : public DisplayImpl, public d3d::Context
class DisplayD3D : public DisplayImpl
{ {
public: public:
DisplayD3D(const egl::DisplayState &state); DisplayD3D(const egl::DisplayState &state);
...@@ -72,6 +72,14 @@ class DisplayD3D : public DisplayImpl ...@@ -72,6 +72,14 @@ class DisplayD3D : public DisplayImpl
egl::Error waitNative(const gl::Context *context, EGLint engine) override; egl::Error waitNative(const gl::Context *context, EGLint engine) override;
gl::Version getMaxSupportedESVersion() const override; gl::Version getMaxSupportedESVersion() const override;
void handleError(HRESULT hr,
const char *message,
const char *file,
const char *function,
unsigned int line) override;
const std::string &getStoredErrorString() const { return mStoredErrorString; }
private: private:
void generateExtensions(egl::DisplayExtensions *outExtensions) const override; void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
void generateCaps(egl::Caps *outCaps) const override; void generateCaps(egl::Caps *outCaps) const override;
...@@ -79,8 +87,9 @@ class DisplayD3D : public DisplayImpl ...@@ -79,8 +87,9 @@ class DisplayD3D : public DisplayImpl
egl::Display *mDisplay; egl::Display *mDisplay;
rx::RendererD3D *mRenderer; rx::RendererD3D *mRenderer;
std::string mStoredErrorString;
}; };
} } // namespace rx
#endif // LIBANGLE_RENDERER_D3D_DISPLAYD3D_H_ #endif // LIBANGLE_RENDERER_D3D_DISPLAYD3D_H_
...@@ -73,6 +73,23 @@ enum RendererClass ...@@ -73,6 +73,23 @@ enum RendererClass
RENDERER_D3D9 RENDERER_D3D9
}; };
// A d3d::Context wraps error handling.
namespace d3d
{
class Context : angle::NonCopyable
{
public:
Context() {}
virtual ~Context() {}
virtual void handleError(HRESULT hr,
const char *message,
const char *file,
const char *function,
unsigned int line) = 0;
};
} // namespace d3d
// ANGLE_TRY for HRESULT errors. // ANGLE_TRY for HRESULT errors.
#define ANGLE_TRY_HR(CONTEXT, EXPR, MESSAGE) \ #define ANGLE_TRY_HR(CONTEXT, EXPR, MESSAGE) \
\ \
......
...@@ -12,11 +12,13 @@ ...@@ -12,11 +12,13 @@
#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
namespace rx namespace rx
{ {
class Renderer11; class Renderer11;
class Context11 : public ContextImpl, public MultisampleTextureInitializer class Context11 : public ContextImpl, public MultisampleTextureInitializer, public d3d::Context
{ {
public: public:
Context11(const gl::ContextState &state, Renderer11 *renderer); Context11(const gl::ContextState &state, Renderer11 *renderer);
...@@ -161,7 +163,7 @@ class Context11 : public ContextImpl, public MultisampleTextureInitializer ...@@ -161,7 +163,7 @@ class Context11 : public ContextImpl, public MultisampleTextureInitializer
const char *message, const char *message,
const char *file, const char *file,
const char *function, const char *function,
unsigned int line); unsigned int line) override;
// TODO(jmadill): Remove this once refactor is complete. http://anglebug.com/2738 // TODO(jmadill): Remove this once refactor is complete. http://anglebug.com/2738
void handleError(const gl::Error &error); void handleError(const gl::Error &error);
...@@ -173,7 +175,6 @@ class Context11 : public ContextImpl, public MultisampleTextureInitializer ...@@ -173,7 +175,6 @@ class Context11 : public ContextImpl, public MultisampleTextureInitializer
Renderer11 *mRenderer; Renderer11 *mRenderer;
IncompleteTextureSet mIncompleteTextures; IncompleteTextureSet mIncompleteTextures;
}; };
} // namespace rx } // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D11_CONTEXT11_H_ #endif // LIBANGLE_RENDERER_D3D_D3D11_CONTEXT11_H_
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