Commit 437fa654 by Jamie Madill Committed by Commit Bot

Add a ContextImpl class.

This class can contain impl-specific functionality for a Context. This will eventually replace the Renderer class, and we can then start passing around a gl::Context instead of gl::ContextState. In D3D11, the ContextImpl could hold a DeferredContext, which would enable multi-thread rendering. In GL, we can implement non-virtual (native) Contexts. In Vulkan it might store the logical device. BUG=angleproject:1363 Change-Id: I39617e6d1a605d1a9574832e4d322400b09867ec Reviewed-on: https://chromium-review.googlesource.com/340745Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent bd329091
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
namespace rx namespace rx
{ {
class ContextImpl;
class Renderer; class Renderer;
} }
...@@ -388,7 +389,7 @@ class Context final : public ValidationContext ...@@ -388,7 +389,7 @@ class Context final : public ValidationContext
void bindUniformLocation(GLuint program, GLint location, const GLchar *name); void bindUniformLocation(GLuint program, GLint location, const GLchar *name);
void recordError(const Error &error) override; void handleError(const Error &error) override;
GLenum getError(); GLenum getError();
GLenum getResetStatus(); GLenum getResetStatus();
...@@ -432,6 +433,8 @@ class Context final : public ValidationContext ...@@ -432,6 +433,8 @@ class Context final : public ValidationContext
void initCaps(GLuint clientVersion); void initCaps(GLuint clientVersion);
std::unique_ptr<rx::ContextImpl> mImplementation;
// Caps to use for validation // Caps to use for validation
Caps mCaps; Caps mCaps;
TextureCapsMap mTextureCaps; TextureCapsMap mTextureCaps;
......
...@@ -51,7 +51,7 @@ class ValidationContext : angle::NonCopyable ...@@ -51,7 +51,7 @@ class ValidationContext : angle::NonCopyable
bool skipValidation); bool skipValidation);
virtual ~ValidationContext() {} virtual ~ValidationContext() {}
virtual void recordError(const Error &error) = 0; virtual void handleError(const Error &error) = 0;
const ContextState &getData() const { return mData; } const ContextState &getData() const { return mData; }
int getClientVersion() const { return mData.clientVersion; } int getClientVersion() const { return mData.clientVersion; }
......
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ContextImpl:
// Implementation-specific functionality associated with a GL Context.
//
#ifndef LIBANGLE_RENDERER_CONTEXTIMPL_H_
#define LIBANGLE_RENDERER_CONTEXTIMPL_H_
#include "common/angleutils.h"
#include "libANGLE/Error.h"
namespace rx
{
class Renderer;
class ContextImpl : angle::NonCopyable
{
public:
ContextImpl() {}
virtual ~ContextImpl() {}
virtual gl::Error initialize(Renderer *renderer) = 0;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_CONTEXTIMPL_H_
...@@ -19,6 +19,7 @@ namespace rx ...@@ -19,6 +19,7 @@ namespace rx
{ {
class BufferImpl; class BufferImpl;
class CompilerImpl; class CompilerImpl;
class ContextImpl;
class FenceNVImpl; class FenceNVImpl;
class FenceSyncImpl; class FenceSyncImpl;
class FramebufferImpl; class FramebufferImpl;
...@@ -37,6 +38,9 @@ class ImplFactory : angle::NonCopyable ...@@ -37,6 +38,9 @@ class ImplFactory : angle::NonCopyable
ImplFactory() {} ImplFactory() {}
virtual ~ImplFactory() {} virtual ~ImplFactory() {}
// Context creation
virtual ContextImpl *createContext() = 0;
// Shader creation // Shader creation
virtual CompilerImpl *createCompiler() = 0; virtual CompilerImpl *createCompiler() = 0;
virtual ShaderImpl *createShader(const gl::ShaderState &data) = 0; virtual ShaderImpl *createShader(const gl::ShaderState &data) = 0;
......
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Context11:
// D3D11-specific functionality associated with a GL Context.
//
#ifndef LIBANGLE_RENDERER_D3D_D3D11_CONTEXT11_H_
#define LIBANGLE_RENDERER_D3D_D3D11_CONTEXT11_H_
#include "libANGLE/renderer/ContextImpl.h"
namespace rx
{
class Context11 : public ContextImpl
{
public:
Context11() {}
~Context11() override {}
gl::Error initialize(Renderer *renderer) override { return gl::NoError(); }
};
} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D11_CONTEXT11_H_
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "libANGLE/renderer/d3d/d3d11/Blit11.h" #include "libANGLE/renderer/d3d/d3d11/Blit11.h"
#include "libANGLE/renderer/d3d/d3d11/Buffer11.h" #include "libANGLE/renderer/d3d/d3d11/Buffer11.h"
#include "libANGLE/renderer/d3d/d3d11/Clear11.h" #include "libANGLE/renderer/d3d/d3d11/Clear11.h"
#include "libANGLE/renderer/d3d/d3d11/Context11.h"
#include "libANGLE/renderer/d3d/d3d11/dxgi_support_table.h" #include "libANGLE/renderer/d3d/d3d11/dxgi_support_table.h"
#include "libANGLE/renderer/d3d/d3d11/Fence11.h" #include "libANGLE/renderer/d3d/d3d11/Fence11.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
...@@ -1143,6 +1144,11 @@ SwapChainD3D *Renderer11::createSwapChain(NativeWindowD3D *nativeWindow, ...@@ -1143,6 +1144,11 @@ SwapChainD3D *Renderer11::createSwapChain(NativeWindowD3D *nativeWindow,
depthBufferFormat, orientation); depthBufferFormat, orientation);
} }
ContextImpl *Renderer11::createContext()
{
return new Context11;
}
CompilerImpl *Renderer11::createCompiler() CompilerImpl *Renderer11::createCompiler()
{ {
if (mRenderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3) if (mRenderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3)
......
...@@ -124,6 +124,8 @@ class Renderer11 : public RendererD3D ...@@ -124,6 +124,8 @@ class Renderer11 : public RendererD3D
GLenum depthBufferFormat, GLenum depthBufferFormat,
EGLint orientation) override; EGLint orientation) override;
ContextImpl *createContext() override;
CompilerImpl *createCompiler() override; CompilerImpl *createCompiler() override;
virtual gl::Error generateSwizzle(gl::Texture *texture); virtual gl::Error generateSwizzle(gl::Texture *texture);
......
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Context9:
// D3D9-specific functionality associated with a GL Context.
//
#ifndef LIBANGLE_RENDERER_D3D_D3D9_CONTEXT9_H_
#define LIBANGLE_RENDERER_D3D_D3D9_CONTEXT9_H_
#include "libANGLE/renderer/ContextImpl.h"
namespace rx
{
class Context9 : public ContextImpl
{
public:
Context9() {}
~Context9() override {}
gl::Error initialize(Renderer *renderer) override { return gl::NoError(); }
};
} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D9_CONTEXT9_H_
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
#include "libANGLE/renderer/d3d/d3d9/Blit9.h" #include "libANGLE/renderer/d3d/d3d9/Blit9.h"
#include "libANGLE/renderer/d3d/d3d9/Buffer9.h" #include "libANGLE/renderer/d3d/d3d9/Buffer9.h"
#include "libANGLE/renderer/d3d/d3d9/Context9.h"
#include "libANGLE/renderer/d3d/d3d9/Fence9.h" #include "libANGLE/renderer/d3d/d3d9/Fence9.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h" #include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/d3d/d3d9/Framebuffer9.h" #include "libANGLE/renderer/d3d/d3d9/Framebuffer9.h"
...@@ -680,6 +681,11 @@ SwapChainD3D *Renderer9::createSwapChain(NativeWindowD3D *nativeWindow, ...@@ -680,6 +681,11 @@ SwapChainD3D *Renderer9::createSwapChain(NativeWindowD3D *nativeWindow,
depthBufferFormat, orientation); depthBufferFormat, orientation);
} }
ContextImpl *Renderer9::createContext()
{
return new Context9;
}
CompilerImpl *Renderer9::createCompiler() CompilerImpl *Renderer9::createCompiler()
{ {
return new CompilerD3D(SH_HLSL_3_0_OUTPUT); return new CompilerD3D(SH_HLSL_3_0_OUTPUT);
......
...@@ -90,6 +90,8 @@ class Renderer9 : public RendererD3D ...@@ -90,6 +90,8 @@ class Renderer9 : public RendererD3D
GLenum depthBufferFormat, GLenum depthBufferFormat,
EGLint orientation) override; EGLint orientation) override;
ContextImpl *createContext() override;
CompilerImpl *createCompiler() override; CompilerImpl *createCompiler() override;
gl::Error allocateEventQuery(IDirect3DQuery9 **outQuery); gl::Error allocateEventQuery(IDirect3DQuery9 **outQuery);
......
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ContextGL:
// OpenGL-specific functionality associated with a GL Context.
//
#ifndef LIBANGLE_RENDERER_GL_CONTEXTGL_H_
#define LIBANGLE_RENDERER_GL_CONTEXTGL_H_
#include "libANGLE/renderer/ContextImpl.h"
namespace rx
{
class ContextGL : public ContextImpl
{
public:
ContextGL() {}
~ContextGL() override {}
gl::Error initialize(Renderer *renderer) override { return gl::NoError(); }
};
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_CONTEXTGL_H_
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "libANGLE/renderer/gl/BlitGL.h" #include "libANGLE/renderer/gl/BlitGL.h"
#include "libANGLE/renderer/gl/BufferGL.h" #include "libANGLE/renderer/gl/BufferGL.h"
#include "libANGLE/renderer/gl/CompilerGL.h" #include "libANGLE/renderer/gl/CompilerGL.h"
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/FenceNVGL.h" #include "libANGLE/renderer/gl/FenceNVGL.h"
#include "libANGLE/renderer/gl/FenceSyncGL.h" #include "libANGLE/renderer/gl/FenceSyncGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h" #include "libANGLE/renderer/gl/FramebufferGL.h"
...@@ -262,6 +263,11 @@ gl::Error RendererGL::drawRangeElements(const gl::ContextState &data, ...@@ -262,6 +263,11 @@ gl::Error RendererGL::drawRangeElements(const gl::ContextState &data,
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
ContextImpl *RendererGL::createContext()
{
return new ContextGL;
}
CompilerImpl *RendererGL::createCompiler() CompilerImpl *RendererGL::createCompiler()
{ {
return new CompilerGL(mFunctions); return new CompilerGL(mFunctions);
......
...@@ -60,6 +60,8 @@ class RendererGL : public Renderer ...@@ -60,6 +60,8 @@ class RendererGL : public Renderer
const GLvoid *indices, const GLvoid *indices,
const gl::IndexRange &indexRange) override; const gl::IndexRange &indexRange) override;
ContextImpl *createContext() override;
// Shader creation // Shader creation
CompilerImpl *createCompiler() override; CompilerImpl *createCompiler() override;
ShaderImpl *createShader(const gl::ShaderState &data) override; ShaderImpl *createShader(const gl::ShaderState &data) override;
......
...@@ -38,7 +38,7 @@ class MockValidationContext : public ValidationContext ...@@ -38,7 +38,7 @@ class MockValidationContext : public ValidationContext
const Limitations &limitations, const Limitations &limitations,
bool skipValidation); bool skipValidation);
MOCK_METHOD1(recordError, void(const Error &)); MOCK_METHOD1(handleError, void(const Error &));
}; };
MockValidationContext::MockValidationContext(GLint clientVersion, MockValidationContext::MockValidationContext(GLint clientVersion,
...@@ -110,7 +110,7 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError) ...@@ -110,7 +110,7 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError)
// Set the expectation for the validation error here. // Set the expectation for the validation error here.
Error expectedError(GL_INVALID_OPERATION, g_ExceedsMaxElementErrorMessage); Error expectedError(GL_INVALID_OPERATION, g_ExceedsMaxElementErrorMessage);
EXPECT_CALL(testContext, recordError(expectedError)).Times(1); EXPECT_CALL(testContext, handleError(expectedError)).Times(1);
// Call once with maximum index, and once with an excessive index. // Call once with maximum index, and once with an excessive index.
GLuint indexData[] = {0, 1, static_cast<GLuint>(caps.maxElementIndex - 1), GLuint indexData[] = {0, 1, static_cast<GLuint>(caps.maxElementIndex - 1),
......
...@@ -137,6 +137,7 @@ ...@@ -137,6 +137,7 @@
'libANGLE/queryconversions.h', 'libANGLE/queryconversions.h',
'libANGLE/renderer/BufferImpl.h', 'libANGLE/renderer/BufferImpl.h',
'libANGLE/renderer/CompilerImpl.h', 'libANGLE/renderer/CompilerImpl.h',
'libANGLE/renderer/ContextImpl.h',
'libANGLE/renderer/DeviceImpl.cpp', 'libANGLE/renderer/DeviceImpl.cpp',
'libANGLE/renderer/DeviceImpl.h', 'libANGLE/renderer/DeviceImpl.h',
'libANGLE/renderer/DisplayImpl.cpp', 'libANGLE/renderer/DisplayImpl.cpp',
...@@ -245,6 +246,7 @@ ...@@ -245,6 +246,7 @@
'libANGLE/renderer/d3d/d3d9/Blit9.h', 'libANGLE/renderer/d3d/d3d9/Blit9.h',
'libANGLE/renderer/d3d/d3d9/Buffer9.cpp', 'libANGLE/renderer/d3d/d3d9/Buffer9.cpp',
'libANGLE/renderer/d3d/d3d9/Buffer9.h', 'libANGLE/renderer/d3d/d3d9/Buffer9.h',
'libANGLE/renderer/d3d/d3d9/Context9.h',
'libANGLE/renderer/d3d/d3d9/DebugAnnotator9.cpp', 'libANGLE/renderer/d3d/d3d9/DebugAnnotator9.cpp',
'libANGLE/renderer/d3d/d3d9/DebugAnnotator9.h', 'libANGLE/renderer/d3d/d3d9/DebugAnnotator9.h',
'libANGLE/renderer/d3d/d3d9/Fence9.cpp', 'libANGLE/renderer/d3d/d3d9/Fence9.cpp',
...@@ -296,6 +298,7 @@ ...@@ -296,6 +298,7 @@
'libANGLE/renderer/d3d/d3d11/Buffer11.h', 'libANGLE/renderer/d3d/d3d11/Buffer11.h',
'libANGLE/renderer/d3d/d3d11/Clear11.cpp', 'libANGLE/renderer/d3d/d3d11/Clear11.cpp',
'libANGLE/renderer/d3d/d3d11/Clear11.h', 'libANGLE/renderer/d3d/d3d11/Clear11.h',
'libANGLE/renderer/d3d/d3d11/Context11.h',
'libANGLE/renderer/d3d/d3d11/copyvertex.h', 'libANGLE/renderer/d3d/d3d11/copyvertex.h',
'libANGLE/renderer/d3d/d3d11/copyvertex.inl', 'libANGLE/renderer/d3d/d3d11/copyvertex.inl',
'libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp', 'libANGLE/renderer/d3d/d3d11/DebugAnnotator11.cpp',
...@@ -427,6 +430,7 @@ ...@@ -427,6 +430,7 @@
'libANGLE/renderer/gl/BufferGL.h', 'libANGLE/renderer/gl/BufferGL.h',
'libANGLE/renderer/gl/CompilerGL.cpp', 'libANGLE/renderer/gl/CompilerGL.cpp',
'libANGLE/renderer/gl/CompilerGL.h', 'libANGLE/renderer/gl/CompilerGL.h',
'libANGLE/renderer/gl/ContextGL.h',
'libANGLE/renderer/gl/DisplayGL.cpp', 'libANGLE/renderer/gl/DisplayGL.cpp',
'libANGLE/renderer/gl/DisplayGL.h', 'libANGLE/renderer/gl/DisplayGL.h',
'libANGLE/renderer/gl/FenceNVGL.cpp', 'libANGLE/renderer/gl/FenceNVGL.cpp',
......
...@@ -133,7 +133,7 @@ Context *GetValidGlobalContext() ...@@ -133,7 +133,7 @@ Context *GetValidGlobalContext()
{ {
if (context->isContextLost()) if (context->isContextLost())
{ {
context->recordError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost.")); context->handleError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost."));
return nullptr; return nullptr;
} }
else else
......
...@@ -62,6 +62,7 @@ class NullFactory : public ImplFactory ...@@ -62,6 +62,7 @@ class NullFactory : public ImplFactory
class MockFactory : public ImplFactory class MockFactory : public ImplFactory
{ {
public: public:
MOCK_METHOD0(createContext, ContextImpl *());
MOCK_METHOD0(createCompiler, CompilerImpl *()); MOCK_METHOD0(createCompiler, CompilerImpl *());
MOCK_METHOD1(createShader, ShaderImpl *(const gl::ShaderState &)); MOCK_METHOD1(createShader, ShaderImpl *(const gl::ShaderState &));
MOCK_METHOD1(createProgram, ProgramImpl *(const gl::ProgramState &)); MOCK_METHOD1(createProgram, ProgramImpl *(const gl::ProgramState &));
......
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