Commit 8415b5fd by Jamie Madill

Pass ContextImpl to Framebuffer methods instead of ContextState.

BUG=angleproject:1363 Change-Id: I7e7524d95f2ca31c35918f9fe5c0cb681ed93616 Reviewed-on: https://chromium-review.googlesource.com/340746Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 437fa654
...@@ -134,7 +134,7 @@ Context::Context(const egl::Config *config, ...@@ -134,7 +134,7 @@ Context::Context(const egl::Config *config,
nullptr, nullptr,
mLimitations, mLimitations,
GetNoError(attribs)), GetNoError(attribs)),
mImplementation(renderer->createContext()), mImplementation(renderer->createContext(getData())),
mCompiler(nullptr), mCompiler(nullptr),
mRenderer(renderer), mRenderer(renderer),
mClientVersion(GetClientVersion(attribs)), mClientVersion(GetClientVersion(attribs)),
...@@ -2158,9 +2158,6 @@ void Context::blitFramebuffer(GLint srcX0, ...@@ -2158,9 +2158,6 @@ void Context::blitFramebuffer(GLint srcX0,
GLbitfield mask, GLbitfield mask,
GLenum filter) GLenum filter)
{ {
Framebuffer *readFramebuffer = mState.getReadFramebuffer();
ASSERT(readFramebuffer);
Framebuffer *drawFramebuffer = mState.getDrawFramebuffer(); Framebuffer *drawFramebuffer = mState.getDrawFramebuffer();
ASSERT(drawFramebuffer); ASSERT(drawFramebuffer);
...@@ -2169,31 +2166,34 @@ void Context::blitFramebuffer(GLint srcX0, ...@@ -2169,31 +2166,34 @@ void Context::blitFramebuffer(GLint srcX0,
syncStateForBlit(); syncStateForBlit();
handleError(drawFramebuffer->blit(mState, srcArea, dstArea, mask, filter, readFramebuffer)); handleError(drawFramebuffer->blit(mImplementation.get(), srcArea, dstArea, mask, filter));
} }
void Context::clear(GLbitfield mask) void Context::clear(GLbitfield mask)
{ {
syncStateForClear(); syncStateForClear();
handleError(mState.getDrawFramebuffer()->clear(mData, mask)); handleError(mState.getDrawFramebuffer()->clear(mImplementation.get(), mask));
} }
void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values) void Context::clearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *values)
{ {
syncStateForClear(); syncStateForClear();
handleError(mState.getDrawFramebuffer()->clearBufferfv(mData, buffer, drawbuffer, values)); handleError(mState.getDrawFramebuffer()->clearBufferfv(mImplementation.get(), buffer,
drawbuffer, values));
} }
void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values) void Context::clearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *values)
{ {
syncStateForClear(); syncStateForClear();
handleError(mState.getDrawFramebuffer()->clearBufferuiv(mData, buffer, drawbuffer, values)); handleError(mState.getDrawFramebuffer()->clearBufferuiv(mImplementation.get(), buffer,
drawbuffer, values));
} }
void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values) void Context::clearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *values)
{ {
syncStateForClear(); syncStateForClear();
handleError(mState.getDrawFramebuffer()->clearBufferiv(mData, buffer, drawbuffer, values)); handleError(mState.getDrawFramebuffer()->clearBufferiv(mImplementation.get(), buffer,
drawbuffer, values));
} }
void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
...@@ -2209,7 +2209,8 @@ void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLin ...@@ -2209,7 +2209,8 @@ void Context::clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLin
} }
syncStateForClear(); syncStateForClear();
handleError(framebufferObject->clearBufferfi(mData, buffer, drawbuffer, depth, stencil)); handleError(framebufferObject->clearBufferfi(mImplementation.get(), buffer, drawbuffer, depth,
stencil));
} }
void Context::readPixels(GLint x, void Context::readPixels(GLint x,
...@@ -2226,7 +2227,7 @@ void Context::readPixels(GLint x, ...@@ -2226,7 +2227,7 @@ void Context::readPixels(GLint x,
ASSERT(framebufferObject); ASSERT(framebufferObject);
Rectangle area(x, y, width, height); Rectangle area(x, y, width, height);
handleError(framebufferObject->readPixels(mState, area, format, type, pixels)); handleError(framebufferObject->readPixels(mImplementation.get(), area, format, type, pixels));
} }
void Context::copyTexImage2D(GLenum target, void Context::copyTexImage2D(GLenum target,
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/ImplFactory.h"
#include "libANGLE/renderer/RenderbufferImpl.h" #include "libANGLE/renderer/RenderbufferImpl.h"
...@@ -613,67 +614,67 @@ Error Framebuffer::invalidateSub(size_t count, const GLenum *attachments, const ...@@ -613,67 +614,67 @@ Error Framebuffer::invalidateSub(size_t count, const GLenum *attachments, const
return mImpl->invalidateSub(count, attachments, area); return mImpl->invalidateSub(count, attachments, area);
} }
Error Framebuffer::clear(const ContextState &data, GLbitfield mask) Error Framebuffer::clear(rx::ContextImpl *context, GLbitfield mask)
{ {
if (data.state->isRasterizerDiscardEnabled()) if (context->getState().isRasterizerDiscardEnabled())
{ {
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
return mImpl->clear(data, mask); return mImpl->clear(context, mask);
} }
Error Framebuffer::clearBufferfv(const ContextState &data, Error Framebuffer::clearBufferfv(rx::ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLfloat *values) const GLfloat *values)
{ {
if (data.state->isRasterizerDiscardEnabled()) if (context->getState().isRasterizerDiscardEnabled())
{ {
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
return mImpl->clearBufferfv(data, buffer, drawbuffer, values); return mImpl->clearBufferfv(context, buffer, drawbuffer, values);
} }
Error Framebuffer::clearBufferuiv(const ContextState &data, Error Framebuffer::clearBufferuiv(rx::ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLuint *values) const GLuint *values)
{ {
if (data.state->isRasterizerDiscardEnabled()) if (context->getState().isRasterizerDiscardEnabled())
{ {
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
return mImpl->clearBufferuiv(data, buffer, drawbuffer, values); return mImpl->clearBufferuiv(context, buffer, drawbuffer, values);
} }
Error Framebuffer::clearBufferiv(const ContextState &data, Error Framebuffer::clearBufferiv(rx::ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLint *values) const GLint *values)
{ {
if (data.state->isRasterizerDiscardEnabled()) if (context->getState().isRasterizerDiscardEnabled())
{ {
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
return mImpl->clearBufferiv(data, buffer, drawbuffer, values); return mImpl->clearBufferiv(context, buffer, drawbuffer, values);
} }
Error Framebuffer::clearBufferfi(const ContextState &data, Error Framebuffer::clearBufferfi(rx::ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
GLfloat depth, GLfloat depth,
GLint stencil) GLint stencil)
{ {
if (data.state->isRasterizerDiscardEnabled()) if (context->getState().isRasterizerDiscardEnabled())
{ {
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
return mImpl->clearBufferfi(data, buffer, drawbuffer, depth, stencil); return mImpl->clearBufferfi(context, buffer, drawbuffer, depth, stencil);
} }
GLenum Framebuffer::getImplementationColorReadFormat() const GLenum Framebuffer::getImplementationColorReadFormat() const
...@@ -686,19 +687,19 @@ GLenum Framebuffer::getImplementationColorReadType() const ...@@ -686,19 +687,19 @@ GLenum Framebuffer::getImplementationColorReadType() const
return mImpl->getImplementationColorReadType(); return mImpl->getImplementationColorReadType();
} }
Error Framebuffer::readPixels(const State &state, Error Framebuffer::readPixels(rx::ContextImpl *context,
const Rectangle &area, const Rectangle &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLvoid *pixels) const GLvoid *pixels) const
{ {
Error error = mImpl->readPixels(state, area, format, type, pixels); Error error = mImpl->readPixels(context, area, format, type, pixels);
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
Buffer *unpackBuffer = state.getUnpackState().pixelBuffer.get(); Buffer *unpackBuffer = context->getState().getUnpackState().pixelBuffer.get();
if (unpackBuffer) if (unpackBuffer)
{ {
unpackBuffer->onPixelUnpack(); unpackBuffer->onPixelUnpack();
...@@ -707,14 +708,13 @@ Error Framebuffer::readPixels(const State &state, ...@@ -707,14 +708,13 @@ Error Framebuffer::readPixels(const State &state,
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
Error Framebuffer::blit(const State &state, Error Framebuffer::blit(rx::ContextImpl *context,
const Rectangle &sourceArea, const Rectangle &sourceArea,
const Rectangle &destArea, const Rectangle &destArea,
GLbitfield mask, GLbitfield mask,
GLenum filter, GLenum filter)
const Framebuffer *sourceFramebuffer)
{ {
return mImpl->blit(state, sourceArea, destArea, mask, filter, sourceFramebuffer); return mImpl->blit(context, sourceArea, destArea, mask, filter);
} }
int Framebuffer::getSamples(const ContextState &data) const int Framebuffer::getSamples(const ContextState &data) const
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
namespace rx namespace rx
{ {
class ContextImpl;
class ImplFactory; class ImplFactory;
class FramebufferImpl; class FramebufferImpl;
class RenderbufferImpl; class RenderbufferImpl;
...@@ -143,20 +144,20 @@ class Framebuffer final : public LabeledObject ...@@ -143,20 +144,20 @@ class Framebuffer final : public LabeledObject
Error invalidate(size_t count, const GLenum *attachments); Error invalidate(size_t count, const GLenum *attachments);
Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area); Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area);
Error clear(const ContextState &data, GLbitfield mask); Error clear(rx::ContextImpl *context, GLbitfield mask);
Error clearBufferfv(const ContextState &data, Error clearBufferfv(rx::ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLfloat *values); const GLfloat *values);
Error clearBufferuiv(const ContextState &data, Error clearBufferuiv(rx::ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLuint *values); const GLuint *values);
Error clearBufferiv(const ContextState &data, Error clearBufferiv(rx::ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLint *values); const GLint *values);
Error clearBufferfi(const ContextState &data, Error clearBufferfi(rx::ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
GLfloat depth, GLfloat depth,
...@@ -164,18 +165,17 @@ class Framebuffer final : public LabeledObject ...@@ -164,18 +165,17 @@ class Framebuffer final : public LabeledObject
GLenum getImplementationColorReadFormat() const; GLenum getImplementationColorReadFormat() const;
GLenum getImplementationColorReadType() const; GLenum getImplementationColorReadType() const;
Error readPixels(const gl::State &state, Error readPixels(rx::ContextImpl *context,
const gl::Rectangle &area, const gl::Rectangle &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLvoid *pixels) const; GLvoid *pixels) const;
Error blit(const State &state, Error blit(rx::ContextImpl *context,
const Rectangle &sourceArea, const Rectangle &sourceArea,
const Rectangle &destArea, const Rectangle &destArea,
GLbitfield mask, GLbitfield mask,
GLenum filter, GLenum filter);
const Framebuffer *sourceFramebuffer);
enum DirtyBitType enum DirtyBitType
{ {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#define LIBANGLE_RENDERER_CONTEXTIMPL_H_ #define LIBANGLE_RENDERER_CONTEXTIMPL_H_
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Error.h" #include "libANGLE/ContextState.h"
namespace rx namespace rx
{ {
...@@ -20,10 +20,20 @@ class Renderer; ...@@ -20,10 +20,20 @@ class Renderer;
class ContextImpl : angle::NonCopyable class ContextImpl : angle::NonCopyable
{ {
public: public:
ContextImpl() {} ContextImpl(const gl::ContextState &state) : mState(state) {}
virtual ~ContextImpl() {} virtual ~ContextImpl() {}
virtual gl::Error initialize(Renderer *renderer) = 0; virtual gl::Error initialize(Renderer *renderer) = 0;
int getClientVersion() const { return mState.clientVersion; }
const gl::State &getState() const { return *mState.state; }
const gl::Caps &getCaps() const { return *mState.caps; }
const gl::TextureCapsMap &getTextureCaps() const { return *mState.textureCaps; }
const gl::Extensions &getExtensions() const { return *mState.extensions; }
const gl::Limitations &getLimitations() const { return *mState.limitations; }
private:
const gl::ContextState &mState;
}; };
} // namespace rx } // namespace rx
......
...@@ -35,20 +35,20 @@ class FramebufferImpl : angle::NonCopyable ...@@ -35,20 +35,20 @@ class FramebufferImpl : angle::NonCopyable
virtual gl::Error invalidate(size_t count, const GLenum *attachments) = 0; virtual gl::Error invalidate(size_t count, const GLenum *attachments) = 0;
virtual gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) = 0; virtual gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) = 0;
virtual gl::Error clear(const gl::ContextState &data, GLbitfield mask) = 0; virtual gl::Error clear(ContextImpl *context, GLbitfield mask) = 0;
virtual gl::Error clearBufferfv(const gl::ContextState &data, virtual gl::Error clearBufferfv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLfloat *values) = 0; const GLfloat *values) = 0;
virtual gl::Error clearBufferuiv(const gl::ContextState &data, virtual gl::Error clearBufferuiv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLuint *values) = 0; const GLuint *values) = 0;
virtual gl::Error clearBufferiv(const gl::ContextState &data, virtual gl::Error clearBufferiv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLint *values) = 0; const GLint *values) = 0;
virtual gl::Error clearBufferfi(const gl::ContextState &data, virtual gl::Error clearBufferfi(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
GLfloat depth, GLfloat depth,
...@@ -56,10 +56,17 @@ class FramebufferImpl : angle::NonCopyable ...@@ -56,10 +56,17 @@ class FramebufferImpl : angle::NonCopyable
virtual GLenum getImplementationColorReadFormat() const = 0; virtual GLenum getImplementationColorReadFormat() const = 0;
virtual GLenum getImplementationColorReadType() const = 0; virtual GLenum getImplementationColorReadType() const = 0;
virtual gl::Error readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const = 0; virtual gl::Error readPixels(ContextImpl *context,
const gl::Rectangle &area,
virtual gl::Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, GLenum format,
GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) = 0; GLenum type,
GLvoid *pixels) const = 0;
virtual gl::Error blit(ContextImpl *context,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLbitfield mask,
GLenum filter) = 0;
virtual bool checkStatus() const = 0; virtual bool checkStatus() const = 0;
......
...@@ -27,27 +27,20 @@ class MockFramebufferImpl : public rx::FramebufferImpl ...@@ -27,27 +27,20 @@ class MockFramebufferImpl : public rx::FramebufferImpl
MOCK_METHOD2(invalidate, gl::Error(size_t, const GLenum *)); MOCK_METHOD2(invalidate, gl::Error(size_t, const GLenum *));
MOCK_METHOD3(invalidateSub, gl::Error(size_t, const GLenum *, const gl::Rectangle &)); MOCK_METHOD3(invalidateSub, gl::Error(size_t, const GLenum *, const gl::Rectangle &));
MOCK_METHOD2(clear, gl::Error(const gl::ContextState &, GLbitfield)); MOCK_METHOD2(clear, gl::Error(ContextImpl *, GLbitfield));
MOCK_METHOD4(clearBufferfv, MOCK_METHOD4(clearBufferfv, gl::Error(ContextImpl *, GLenum, GLint, const GLfloat *));
gl::Error(const gl::ContextState &, GLenum, GLint, const GLfloat *)); MOCK_METHOD4(clearBufferuiv, gl::Error(ContextImpl *, GLenum, GLint, const GLuint *));
MOCK_METHOD4(clearBufferuiv, MOCK_METHOD4(clearBufferiv, gl::Error(ContextImpl *, GLenum, GLint, const GLint *));
gl::Error(const gl::ContextState &, GLenum, GLint, const GLuint *)); MOCK_METHOD5(clearBufferfi, gl::Error(ContextImpl *, GLenum, GLint, GLfloat, GLint));
MOCK_METHOD4(clearBufferiv, gl::Error(const gl::ContextState &, GLenum, GLint, const GLint *));
MOCK_METHOD5(clearBufferfi, gl::Error(const gl::ContextState &, GLenum, GLint, GLfloat, GLint));
MOCK_CONST_METHOD0(getImplementationColorReadFormat, GLenum()); MOCK_CONST_METHOD0(getImplementationColorReadFormat, GLenum());
MOCK_CONST_METHOD0(getImplementationColorReadType, GLenum()); MOCK_CONST_METHOD0(getImplementationColorReadType, GLenum());
MOCK_CONST_METHOD5( MOCK_CONST_METHOD5(readPixels,
readPixels, gl::Error(ContextImpl *, const gl::Rectangle &, GLenum, GLenum, GLvoid *));
gl::Error(const gl::State &, const gl::Rectangle &, GLenum, GLenum, GLvoid *));
MOCK_METHOD5(
MOCK_METHOD6(blit, blit,
gl::Error(const gl::State &, gl::Error(ContextImpl *, const gl::Rectangle &, const gl::Rectangle &, GLbitfield, GLenum));
const gl::Rectangle &,
const gl::Rectangle &,
GLbitfield,
GLenum,
const gl::Framebuffer *));
MOCK_CONST_METHOD0(checkStatus, bool()); MOCK_CONST_METHOD0(checkStatus, bool());
......
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
#include "libANGLE/Shader.h" #include "libANGLE/Shader.h"
#include "libANGLE/VertexArray.h" #include "libANGLE/VertexArray.h"
namespace gl
{
struct ContextState;
}
namespace rx namespace rx
{ {
class BufferImpl; class BufferImpl;
...@@ -39,7 +44,7 @@ class ImplFactory : angle::NonCopyable ...@@ -39,7 +44,7 @@ class ImplFactory : angle::NonCopyable
virtual ~ImplFactory() {} virtual ~ImplFactory() {}
// Context creation // Context creation
virtual ContextImpl *createContext() = 0; virtual ContextImpl *createContext(const gl::ContextState &state) = 0;
// Shader creation // Shader creation
virtual CompilerImpl *createCompiler() = 0; virtual CompilerImpl *createCompiler() = 0;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/d3d/RendererD3D.h" #include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/RenderbufferD3D.h" #include "libANGLE/renderer/d3d/RenderbufferD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h" #include "libANGLE/renderer/d3d/RenderTargetD3D.h"
...@@ -94,20 +95,19 @@ FramebufferD3D::~FramebufferD3D() ...@@ -94,20 +95,19 @@ FramebufferD3D::~FramebufferD3D()
{ {
} }
gl::Error FramebufferD3D::clear(const gl::ContextState &data, GLbitfield mask) gl::Error FramebufferD3D::clear(ContextImpl *context, GLbitfield mask)
{ {
const gl::State &state = *data.state; ClearParameters clearParams = GetClearParameters(context->getState(), mask);
ClearParameters clearParams = GetClearParameters(state, mask); return clearImpl(context, clearParams);
return clear(data, clearParams);
} }
gl::Error FramebufferD3D::clearBufferfv(const gl::ContextState &data, gl::Error FramebufferD3D::clearBufferfv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLfloat *values) const GLfloat *values)
{ {
// glClearBufferfv can be called to clear the color buffer or depth buffer // glClearBufferfv can be called to clear the color buffer or depth buffer
ClearParameters clearParams = GetClearParameters(*data.state, 0); ClearParameters clearParams = GetClearParameters(context->getState(), 0);
if (buffer == GL_COLOR) if (buffer == GL_COLOR)
{ {
...@@ -125,16 +125,16 @@ gl::Error FramebufferD3D::clearBufferfv(const gl::ContextState &data, ...@@ -125,16 +125,16 @@ gl::Error FramebufferD3D::clearBufferfv(const gl::ContextState &data,
clearParams.depthClearValue = values[0]; clearParams.depthClearValue = values[0];
} }
return clear(data, clearParams); return clearImpl(context, clearParams);
} }
gl::Error FramebufferD3D::clearBufferuiv(const gl::ContextState &data, gl::Error FramebufferD3D::clearBufferuiv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLuint *values) const GLuint *values)
{ {
// glClearBufferuiv can only be called to clear a color buffer // glClearBufferuiv can only be called to clear a color buffer
ClearParameters clearParams = GetClearParameters(*data.state, 0); ClearParameters clearParams = GetClearParameters(context->getState(), 0);
for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++) for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
{ {
clearParams.clearColor[i] = (drawbuffer == static_cast<int>(i)); clearParams.clearColor[i] = (drawbuffer == static_cast<int>(i));
...@@ -142,16 +142,16 @@ gl::Error FramebufferD3D::clearBufferuiv(const gl::ContextState &data, ...@@ -142,16 +142,16 @@ gl::Error FramebufferD3D::clearBufferuiv(const gl::ContextState &data,
clearParams.colorUIClearValue = gl::ColorUI(values[0], values[1], values[2], values[3]); clearParams.colorUIClearValue = gl::ColorUI(values[0], values[1], values[2], values[3]);
clearParams.colorClearType = GL_UNSIGNED_INT; clearParams.colorClearType = GL_UNSIGNED_INT;
return clear(data, clearParams); return clearImpl(context, clearParams);
} }
gl::Error FramebufferD3D::clearBufferiv(const gl::ContextState &data, gl::Error FramebufferD3D::clearBufferiv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLint *values) const GLint *values)
{ {
// glClearBufferiv can be called to clear the color buffer or stencil buffer // glClearBufferiv can be called to clear the color buffer or stencil buffer
ClearParameters clearParams = GetClearParameters(*data.state, 0); ClearParameters clearParams = GetClearParameters(context->getState(), 0);
if (buffer == GL_COLOR) if (buffer == GL_COLOR)
{ {
...@@ -169,23 +169,23 @@ gl::Error FramebufferD3D::clearBufferiv(const gl::ContextState &data, ...@@ -169,23 +169,23 @@ gl::Error FramebufferD3D::clearBufferiv(const gl::ContextState &data,
clearParams.stencilClearValue = values[1]; clearParams.stencilClearValue = values[1];
} }
return clear(data, clearParams); return clearImpl(context, clearParams);
} }
gl::Error FramebufferD3D::clearBufferfi(const gl::ContextState &data, gl::Error FramebufferD3D::clearBufferfi(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
GLfloat depth, GLfloat depth,
GLint stencil) GLint stencil)
{ {
// glClearBufferfi can only be called to clear a depth stencil buffer // glClearBufferfi can only be called to clear a depth stencil buffer
ClearParameters clearParams = GetClearParameters(*data.state, 0); ClearParameters clearParams = GetClearParameters(context->getState(), 0);
clearParams.clearDepth = true; clearParams.clearDepth = true;
clearParams.depthClearValue = depth; clearParams.depthClearValue = depth;
clearParams.clearStencil = true; clearParams.clearStencil = true;
clearParams.stencilClearValue = stencil; clearParams.stencilClearValue = stencil;
return clear(data, clearParams); return clearImpl(context, clearParams);
} }
GLenum FramebufferD3D::getImplementationColorReadFormat() const GLenum FramebufferD3D::getImplementationColorReadFormat() const
...@@ -232,9 +232,13 @@ GLenum FramebufferD3D::getImplementationColorReadType() const ...@@ -232,9 +232,13 @@ GLenum FramebufferD3D::getImplementationColorReadType() const
return implementationFormatInfo.type; return implementationFormatInfo.type;
} }
gl::Error FramebufferD3D::readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const gl::Error FramebufferD3D::readPixels(ContextImpl *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
GLvoid *pixels) const
{ {
const gl::PixelPackState &packState = state.getPackState(); const gl::PixelPackState &packState = context->getState().getPackState();
GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, type); GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, type);
const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(sizedInternalFormat); const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(sizedInternalFormat);
...@@ -247,9 +251,14 @@ gl::Error FramebufferD3D::readPixels(const gl::State &state, const gl::Rectangle ...@@ -247,9 +251,14 @@ gl::Error FramebufferD3D::readPixels(const gl::State &state, const gl::Rectangle
reinterpret_cast<uint8_t *>(pixels) + outputSkipBytes); reinterpret_cast<uint8_t *>(pixels) + outputSkipBytes);
} }
gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, gl::Error FramebufferD3D::blit(ContextImpl *context,
GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLbitfield mask,
GLenum filter)
{ {
const auto &glState = context->getState();
const gl::Framebuffer *sourceFramebuffer = glState.getReadFramebuffer();
bool blitRenderTarget = false; bool blitRenderTarget = false;
if ((mask & GL_COLOR_BUFFER_BIT) && sourceFramebuffer->getReadColorbuffer() != nullptr && if ((mask & GL_COLOR_BUFFER_BIT) && sourceFramebuffer->getReadColorbuffer() != nullptr &&
mState.getFirstColorAttachment() != nullptr) mState.getFirstColorAttachment() != nullptr)
...@@ -273,9 +282,10 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour ...@@ -273,9 +282,10 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour
if (blitRenderTarget || blitDepth || blitStencil) if (blitRenderTarget || blitDepth || blitStencil)
{ {
const gl::Rectangle *scissor = state.isScissorTestEnabled() ? &state.getScissor() : NULL; const gl::Rectangle *scissor =
gl::Error error = blit(sourceArea, destArea, scissor, blitRenderTarget, blitDepth, blitStencil, glState.isScissorTestEnabled() ? &glState.getScissor() : nullptr;
filter, sourceFramebuffer); gl::Error error = blitImpl(sourceArea, destArea, scissor, blitRenderTarget, blitDepth,
blitStencil, filter, sourceFramebuffer);
if (error.isError()) if (error.isError())
{ {
return error; return error;
......
...@@ -60,20 +60,20 @@ class FramebufferD3D : public FramebufferImpl ...@@ -60,20 +60,20 @@ class FramebufferD3D : public FramebufferImpl
FramebufferD3D(const gl::FramebufferState &data, RendererD3D *renderer); FramebufferD3D(const gl::FramebufferState &data, RendererD3D *renderer);
virtual ~FramebufferD3D(); virtual ~FramebufferD3D();
gl::Error clear(const gl::ContextState &data, GLbitfield mask) override; gl::Error clear(ContextImpl *impl, GLbitfield mask) override;
gl::Error clearBufferfv(const gl::ContextState &data, gl::Error clearBufferfv(ContextImpl *impl,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLfloat *values) override; const GLfloat *values) override;
gl::Error clearBufferuiv(const gl::ContextState &data, gl::Error clearBufferuiv(ContextImpl *impl,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLuint *values) override; const GLuint *values) override;
gl::Error clearBufferiv(const gl::ContextState &data, gl::Error clearBufferiv(ContextImpl *impl,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLint *values) override; const GLint *values) override;
gl::Error clearBufferfi(const gl::ContextState &data, gl::Error clearBufferfi(ContextImpl *impl,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
GLfloat depth, GLfloat depth,
...@@ -81,10 +81,17 @@ class FramebufferD3D : public FramebufferImpl ...@@ -81,10 +81,17 @@ class FramebufferD3D : public FramebufferImpl
GLenum getImplementationColorReadFormat() const override; GLenum getImplementationColorReadFormat() const override;
GLenum getImplementationColorReadType() const override; GLenum getImplementationColorReadType() const override;
gl::Error readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const override; gl::Error readPixels(ContextImpl *impl,
const gl::Rectangle &area,
gl::Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, GLenum format,
GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) override; GLenum type,
GLvoid *pixels) const override;
gl::Error blit(ContextImpl *impl,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLbitfield mask,
GLenum filter) override;
bool checkStatus() const override; bool checkStatus() const override;
...@@ -93,7 +100,7 @@ class FramebufferD3D : public FramebufferImpl ...@@ -93,7 +100,7 @@ class FramebufferD3D : public FramebufferImpl
const gl::AttachmentList &getColorAttachmentsForRender() const; const gl::AttachmentList &getColorAttachmentsForRender() const;
private: private:
virtual gl::Error clear(const gl::ContextState &data, const ClearParameters &clearParams) = 0; virtual gl::Error clearImpl(ContextImpl *impl, const ClearParameters &clearParams) = 0;
virtual gl::Error readPixelsImpl(const gl::Rectangle &area, virtual gl::Error readPixelsImpl(const gl::Rectangle &area,
GLenum format, GLenum format,
...@@ -102,9 +109,14 @@ class FramebufferD3D : public FramebufferImpl ...@@ -102,9 +109,14 @@ class FramebufferD3D : public FramebufferImpl
const gl::PixelPackState &pack, const gl::PixelPackState &pack,
uint8_t *pixels) const = 0; uint8_t *pixels) const = 0;
virtual gl::Error blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, virtual gl::Error blitImpl(const gl::Rectangle &sourceArea,
bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, const gl::Rectangle &destArea,
const gl::Framebuffer *sourceFramebuffer) = 0; const gl::Rectangle *scissor,
bool blitRenderTarget,
bool blitDepth,
bool blitStencil,
GLenum filter,
const gl::Framebuffer *sourceFramebuffer) = 0;
virtual GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const = 0; virtual GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const = 0;
......
...@@ -18,7 +18,7 @@ namespace rx ...@@ -18,7 +18,7 @@ namespace rx
class Context11 : public ContextImpl class Context11 : public ContextImpl
{ {
public: public:
Context11() {} Context11(const gl::ContextState &state) : ContextImpl(state) {}
~Context11() override {} ~Context11() override {}
gl::Error initialize(Renderer *renderer) override { return gl::NoError(); } gl::Error initialize(Renderer *renderer) override { return gl::NoError(); }
......
...@@ -144,7 +144,7 @@ gl::Error Framebuffer11::invalidateSwizzles() const ...@@ -144,7 +144,7 @@ gl::Error Framebuffer11::invalidateSwizzles() const
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Framebuffer11::clear(const gl::ContextState &data, const ClearParameters &clearParams) gl::Error Framebuffer11::clearImpl(ContextImpl *context, const ClearParameters &clearParams)
{ {
Clear11 *clearer = mRenderer->getClearer(); Clear11 *clearer = mRenderer->getClearer();
gl::Error error(GL_NO_ERROR); gl::Error error(GL_NO_ERROR);
...@@ -368,9 +368,14 @@ gl::Error Framebuffer11::readPixelsImpl(const gl::Rectangle &area, ...@@ -368,9 +368,14 @@ gl::Error Framebuffer11::readPixelsImpl(const gl::Rectangle &area,
static_cast<GLuint>(outputPitch), pack, pixels); static_cast<GLuint>(outputPitch), pack, pixels);
} }
gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, gl::Error Framebuffer11::blitImpl(const gl::Rectangle &sourceArea,
bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, const gl::Rectangle &destArea,
const gl::Framebuffer *sourceFramebuffer) const gl::Rectangle *scissor,
bool blitRenderTarget,
bool blitDepth,
bool blitStencil,
GLenum filter,
const gl::Framebuffer *sourceFramebuffer)
{ {
if (blitRenderTarget) if (blitRenderTarget)
{ {
......
...@@ -48,7 +48,7 @@ class Framebuffer11 : public FramebufferD3D ...@@ -48,7 +48,7 @@ class Framebuffer11 : public FramebufferD3D
void syncInternalState() const; void syncInternalState() const;
private: private:
gl::Error clear(const gl::ContextState &data, const ClearParameters &clearParams) override; gl::Error clearImpl(ContextImpl *context, const ClearParameters &clearParams) override;
gl::Error readPixelsImpl(const gl::Rectangle &area, gl::Error readPixelsImpl(const gl::Rectangle &area,
GLenum format, GLenum format,
...@@ -57,9 +57,14 @@ class Framebuffer11 : public FramebufferD3D ...@@ -57,9 +57,14 @@ class Framebuffer11 : public FramebufferD3D
const gl::PixelPackState &pack, const gl::PixelPackState &pack,
uint8_t *pixels) const override; uint8_t *pixels) const override;
gl::Error blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, gl::Error blitImpl(const gl::Rectangle &sourceArea,
bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, const gl::Rectangle &destArea,
const gl::Framebuffer *sourceFramebuffer) override; const gl::Rectangle *scissor,
bool blitRenderTarget,
bool blitDepth,
bool blitStencil,
GLenum filter,
const gl::Framebuffer *sourceFramebuffer) override;
gl::Error invalidateBase(size_t count, const GLenum *attachments, bool useEXTBehavior) const; gl::Error invalidateBase(size_t count, const GLenum *attachments, bool useEXTBehavior) const;
......
...@@ -1144,9 +1144,9 @@ SwapChainD3D *Renderer11::createSwapChain(NativeWindowD3D *nativeWindow, ...@@ -1144,9 +1144,9 @@ SwapChainD3D *Renderer11::createSwapChain(NativeWindowD3D *nativeWindow,
depthBufferFormat, orientation); depthBufferFormat, orientation);
} }
ContextImpl *Renderer11::createContext() ContextImpl *Renderer11::createContext(const gl::ContextState &state)
{ {
return new Context11; return new Context11(state);
} }
CompilerImpl *Renderer11::createCompiler() CompilerImpl *Renderer11::createCompiler()
......
...@@ -124,7 +124,7 @@ class Renderer11 : public RendererD3D ...@@ -124,7 +124,7 @@ class Renderer11 : public RendererD3D
GLenum depthBufferFormat, GLenum depthBufferFormat,
EGLint orientation) override; EGLint orientation) override;
ContextImpl *createContext() override; ContextImpl *createContext(const gl::ContextState &state) override;
CompilerImpl *createCompiler() override; CompilerImpl *createCompiler() override;
......
...@@ -18,7 +18,7 @@ namespace rx ...@@ -18,7 +18,7 @@ namespace rx
class Context9 : public ContextImpl class Context9 : public ContextImpl
{ {
public: public:
Context9() {} Context9(const gl::ContextState &state) : ContextImpl(state) {}
~Context9() override {} ~Context9() override {}
gl::Error initialize(Renderer *renderer) override { return gl::NoError(); } gl::Error initialize(Renderer *renderer) override { return gl::NoError(); }
......
...@@ -7,16 +7,18 @@ ...@@ -7,16 +7,18 @@
// Framebuffer9.cpp: Implements the Framebuffer9 class. // Framebuffer9.cpp: Implements the Framebuffer9 class.
#include "libANGLE/renderer/d3d/d3d9/Framebuffer9.h" #include "libANGLE/renderer/d3d/d3d9/Framebuffer9.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
namespace rx namespace rx
{ {
...@@ -52,7 +54,7 @@ gl::Error Framebuffer9::invalidateSub(size_t, const GLenum *, const gl::Rectangl ...@@ -52,7 +54,7 @@ gl::Error Framebuffer9::invalidateSub(size_t, const GLenum *, const gl::Rectangl
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Framebuffer9::clear(const gl::ContextState &data, const ClearParameters &clearParams) gl::Error Framebuffer9::clearImpl(ContextImpl *context, const ClearParameters &clearParams)
{ {
const gl::FramebufferAttachment *colorAttachment = mState.getColorAttachment(0); const gl::FramebufferAttachment *colorAttachment = mState.getColorAttachment(0);
const gl::FramebufferAttachment *depthStencilAttachment = mState.getDepthOrStencilAttachment(); const gl::FramebufferAttachment *depthStencilAttachment = mState.getDepthOrStencilAttachment();
...@@ -63,12 +65,13 @@ gl::Error Framebuffer9::clear(const gl::ContextState &data, const ClearParameter ...@@ -63,12 +65,13 @@ gl::Error Framebuffer9::clear(const gl::ContextState &data, const ClearParameter
return error; return error;
} }
float nearZ = data.state->getNearPlane(); const gl::State &glState = context->getState();
float farZ = data.state->getFarPlane(); float nearZ = glState.getNearPlane();
mRenderer->setViewport(data.caps, data.state->getViewport(), nearZ, farZ, GL_TRIANGLES, float farZ = glState.getFarPlane();
data.state->getRasterizerState().frontFace, true); mRenderer->setViewport(glState.getViewport(), nearZ, farZ, GL_TRIANGLES,
glState.getRasterizerState().frontFace, true);
mRenderer->setScissorRectangle(data.state->getScissor(), data.state->isScissorTestEnabled()); mRenderer->setScissorRectangle(glState.getScissor(), glState.isScissorTestEnabled());
return mRenderer->clear(clearParams, colorAttachment, depthStencilAttachment); return mRenderer->clear(clearParams, colorAttachment, depthStencilAttachment);
} }
...@@ -256,9 +259,14 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area, ...@@ -256,9 +259,14 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area,
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, gl::Error Framebuffer9::blitImpl(const gl::Rectangle &sourceArea,
bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, const gl::Rectangle &destArea,
const gl::Framebuffer *sourceFramebuffer) const gl::Rectangle *scissor,
bool blitRenderTarget,
bool blitDepth,
bool blitStencil,
GLenum filter,
const gl::Framebuffer *sourceFramebuffer)
{ {
ASSERT(filter == GL_NEAREST); ASSERT(filter == GL_NEAREST);
......
...@@ -26,7 +26,7 @@ class Framebuffer9 : public FramebufferD3D ...@@ -26,7 +26,7 @@ class Framebuffer9 : public FramebufferD3D
gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override; gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override;
private: private:
gl::Error clear(const gl::ContextState &data, const ClearParameters &clearParams) override; gl::Error clearImpl(ContextImpl *context, const ClearParameters &clearParams) override;
gl::Error readPixelsImpl(const gl::Rectangle &area, gl::Error readPixelsImpl(const gl::Rectangle &area,
GLenum format, GLenum format,
...@@ -35,9 +35,14 @@ class Framebuffer9 : public FramebufferD3D ...@@ -35,9 +35,14 @@ class Framebuffer9 : public FramebufferD3D
const gl::PixelPackState &pack, const gl::PixelPackState &pack,
uint8_t *pixels) const override; uint8_t *pixels) const override;
gl::Error blit(const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, const gl::Rectangle *scissor, gl::Error blitImpl(const gl::Rectangle &sourceArea,
bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter, const gl::Rectangle &destArea,
const gl::Framebuffer *sourceFramebuffer) override; const gl::Rectangle *scissor,
bool blitRenderTarget,
bool blitDepth,
bool blitStencil,
GLenum filter,
const gl::Framebuffer *sourceFramebuffer) override;
GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const override; GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const override;
......
...@@ -681,9 +681,9 @@ SwapChainD3D *Renderer9::createSwapChain(NativeWindowD3D *nativeWindow, ...@@ -681,9 +681,9 @@ SwapChainD3D *Renderer9::createSwapChain(NativeWindowD3D *nativeWindow,
depthBufferFormat, orientation); depthBufferFormat, orientation);
} }
ContextImpl *Renderer9::createContext() ContextImpl *Renderer9::createContext(const gl::ContextState &state)
{ {
return new Context9; return new Context9(state);
} }
CompilerImpl *Renderer9::createCompiler() CompilerImpl *Renderer9::createCompiler()
...@@ -949,9 +949,8 @@ gl::Error Renderer9::updateState(const gl::ContextState &data, GLenum drawMode) ...@@ -949,9 +949,8 @@ gl::Error Renderer9::updateState(const gl::ContextState &data, GLenum drawMode)
} }
// Setting viewport state // Setting viewport state
setViewport(data.caps, data.state->getViewport(), data.state->getNearPlane(), setViewport(data.state->getViewport(), data.state->getNearPlane(), data.state->getFarPlane(),
data.state->getFarPlane(), drawMode, data.state->getRasterizerState().frontFace, drawMode, data.state->getRasterizerState().frontFace, false);
false);
// Setting scissors state // Setting scissors state
setScissorRectangle(data.state->getScissor(), data.state->isScissorTestEnabled()); setScissorRectangle(data.state->getScissor(), data.state->isScissorTestEnabled());
...@@ -991,16 +990,14 @@ gl::Error Renderer9::setBlendDepthRasterStates(const gl::ContextState &glData, G ...@@ -991,16 +990,14 @@ gl::Error Renderer9::setBlendDepthRasterStates(const gl::ContextState &glData, G
return mStateManager.setBlendDepthRasterStates(*glData.state, mask); return mStateManager.setBlendDepthRasterStates(*glData.state, mask);
} }
void Renderer9::setViewport(const gl::Caps *caps, void Renderer9::setViewport(const gl::Rectangle &viewport,
const gl::Rectangle &viewport,
float zNear, float zNear,
float zFar, float zFar,
GLenum drawMode, GLenum drawMode,
GLenum frontFace, GLenum frontFace,
bool ignoreViewport) bool ignoreViewport)
{ {
mStateManager.setViewportState(caps, viewport, zNear, zFar, drawMode, frontFace, mStateManager.setViewportState(viewport, zNear, zFar, drawMode, frontFace, ignoreViewport);
ignoreViewport);
} }
bool Renderer9::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSize) bool Renderer9::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSize)
......
...@@ -90,7 +90,7 @@ class Renderer9 : public RendererD3D ...@@ -90,7 +90,7 @@ class Renderer9 : public RendererD3D
GLenum depthBufferFormat, GLenum depthBufferFormat,
EGLint orientation) override; EGLint orientation) override;
ContextImpl *createContext() override; ContextImpl *createContext(const gl::ContextState &state) override;
CompilerImpl *createCompiler() override; CompilerImpl *createCompiler() override;
...@@ -113,8 +113,7 @@ class Renderer9 : public RendererD3D ...@@ -113,8 +113,7 @@ class Renderer9 : public RendererD3D
gl::Error updateState(const gl::ContextState &data, GLenum drawMode) override; gl::Error updateState(const gl::ContextState &data, GLenum drawMode) override;
void setScissorRectangle(const gl::Rectangle &scissor, bool enabled); void setScissorRectangle(const gl::Rectangle &scissor, bool enabled);
void setViewport(const gl::Caps *caps, void setViewport(const gl::Rectangle &viewport,
const gl::Rectangle &viewport,
float zNear, float zNear,
float zFar, float zFar,
GLenum drawMode, GLenum drawMode,
......
...@@ -473,8 +473,7 @@ gl::Error StateManager9::setBlendDepthRasterStates(const gl::State &glState, ...@@ -473,8 +473,7 @@ gl::Error StateManager9::setBlendDepthRasterStates(const gl::State &glState,
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
void StateManager9::setViewportState(const gl::Caps *caps, void StateManager9::setViewportState(const gl::Rectangle &viewport,
const gl::Rectangle &viewport,
float zNear, float zNear,
float zFar, float zFar,
GLenum drawMode, GLenum drawMode,
......
...@@ -45,8 +45,7 @@ class StateManager9 final : angle::NonCopyable ...@@ -45,8 +45,7 @@ class StateManager9 final : angle::NonCopyable
gl::Error setBlendDepthRasterStates(const gl::State &glState, unsigned int sampleMask); gl::Error setBlendDepthRasterStates(const gl::State &glState, unsigned int sampleMask);
void setScissorState(const gl::Rectangle &scissor, bool enabled); void setScissorState(const gl::Rectangle &scissor, bool enabled);
void setViewportState(const gl::Caps *caps, void setViewportState(const gl::Rectangle &viewport,
const gl::Rectangle &viewport,
float zNear, float zNear,
float zFar, float zFar,
GLenum drawMode, GLenum drawMode,
......
...@@ -18,7 +18,7 @@ namespace rx ...@@ -18,7 +18,7 @@ namespace rx
class ContextGL : public ContextImpl class ContextGL : public ContextImpl
{ {
public: public:
ContextGL() {} ContextGL(const gl::ContextState &state) : ContextImpl(state) {}
~ContextGL() override {} ~ContextGL() override {}
gl::Error initialize(Renderer *renderer) override { return gl::NoError(); } gl::Error initialize(Renderer *renderer) override { return gl::NoError(); }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/gl/FunctionsGL.h" #include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/RenderbufferGL.h" #include "libANGLE/renderer/gl/RenderbufferGL.h"
#include "libANGLE/renderer/gl/StateManagerGL.h" #include "libANGLE/renderer/gl/StateManagerGL.h"
...@@ -149,7 +150,7 @@ Error FramebufferGL::invalidateSub(size_t count, ...@@ -149,7 +150,7 @@ Error FramebufferGL::invalidateSub(size_t count,
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
Error FramebufferGL::clear(const ContextState &data, GLbitfield mask) Error FramebufferGL::clear(ContextImpl *context, GLbitfield mask)
{ {
syncClearState(mask); syncClearState(mask);
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
...@@ -158,7 +159,7 @@ Error FramebufferGL::clear(const ContextState &data, GLbitfield mask) ...@@ -158,7 +159,7 @@ Error FramebufferGL::clear(const ContextState &data, GLbitfield mask)
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
Error FramebufferGL::clearBufferfv(const ContextState &data, Error FramebufferGL::clearBufferfv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLfloat *values) const GLfloat *values)
...@@ -170,7 +171,7 @@ Error FramebufferGL::clearBufferfv(const ContextState &data, ...@@ -170,7 +171,7 @@ Error FramebufferGL::clearBufferfv(const ContextState &data,
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
Error FramebufferGL::clearBufferuiv(const ContextState &data, Error FramebufferGL::clearBufferuiv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLuint *values) const GLuint *values)
...@@ -182,7 +183,7 @@ Error FramebufferGL::clearBufferuiv(const ContextState &data, ...@@ -182,7 +183,7 @@ Error FramebufferGL::clearBufferuiv(const ContextState &data,
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
Error FramebufferGL::clearBufferiv(const ContextState &data, Error FramebufferGL::clearBufferiv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLint *values) const GLint *values)
...@@ -194,7 +195,7 @@ Error FramebufferGL::clearBufferiv(const ContextState &data, ...@@ -194,7 +195,7 @@ Error FramebufferGL::clearBufferiv(const ContextState &data,
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
Error FramebufferGL::clearBufferfi(const ContextState &data, Error FramebufferGL::clearBufferfi(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
GLfloat depth, GLfloat depth,
...@@ -223,7 +224,7 @@ GLenum FramebufferGL::getImplementationColorReadType() const ...@@ -223,7 +224,7 @@ GLenum FramebufferGL::getImplementationColorReadType() const
return internalFormatInfo.type; return internalFormatInfo.type;
} }
Error FramebufferGL::readPixels(const State &state, Error FramebufferGL::readPixels(ContextImpl *context,
const gl::Rectangle &area, const gl::Rectangle &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -231,7 +232,7 @@ Error FramebufferGL::readPixels(const State &state, ...@@ -231,7 +232,7 @@ Error FramebufferGL::readPixels(const State &state,
{ {
// TODO: don't sync the pixel pack state here once the dirty bits contain the pixel pack buffer // TODO: don't sync the pixel pack state here once the dirty bits contain the pixel pack buffer
// binding // binding
const PixelPackState &packState = state.getPackState(); const PixelPackState &packState = context->getState().getPackState();
mStateManager->setPixelPackState(packState); mStateManager->setPixelPackState(packState);
mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, mFramebufferID); mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, mFramebufferID);
...@@ -240,13 +241,13 @@ Error FramebufferGL::readPixels(const State &state, ...@@ -240,13 +241,13 @@ Error FramebufferGL::readPixels(const State &state,
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
Error FramebufferGL::blit(const State &state, Error FramebufferGL::blit(ContextImpl *context,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea, const gl::Rectangle &destArea,
GLbitfield mask, GLbitfield mask,
GLenum filter, GLenum filter)
const Framebuffer *sourceFramebuffer)
{ {
const Framebuffer *sourceFramebuffer = context->getState().getReadFramebuffer();
const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(sourceFramebuffer); const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(sourceFramebuffer);
mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID()); mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID());
......
...@@ -40,20 +40,20 @@ class FramebufferGL : public FramebufferImpl ...@@ -40,20 +40,20 @@ class FramebufferGL : public FramebufferImpl
gl::Error invalidate(size_t count, const GLenum *attachments) override; gl::Error invalidate(size_t count, const GLenum *attachments) override;
gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override; gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override;
gl::Error clear(const gl::ContextState &data, GLbitfield mask) override; gl::Error clear(ContextImpl *context, GLbitfield mask) override;
gl::Error clearBufferfv(const gl::ContextState &data, gl::Error clearBufferfv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLfloat *values) override; const GLfloat *values) override;
gl::Error clearBufferuiv(const gl::ContextState &data, gl::Error clearBufferuiv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLuint *values) override; const GLuint *values) override;
gl::Error clearBufferiv(const gl::ContextState &data, gl::Error clearBufferiv(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
const GLint *values) override; const GLint *values) override;
gl::Error clearBufferfi(const gl::ContextState &data, gl::Error clearBufferfi(ContextImpl *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
GLfloat depth, GLfloat depth,
...@@ -61,10 +61,17 @@ class FramebufferGL : public FramebufferImpl ...@@ -61,10 +61,17 @@ class FramebufferGL : public FramebufferImpl
GLenum getImplementationColorReadFormat() const override; GLenum getImplementationColorReadFormat() const override;
GLenum getImplementationColorReadType() const override; GLenum getImplementationColorReadType() const override;
gl::Error readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const override; gl::Error readPixels(ContextImpl *context,
const gl::Rectangle &area,
gl::Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, GLenum format,
GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer) override; GLenum type,
GLvoid *pixels) const override;
gl::Error blit(ContextImpl *context,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLbitfield mask,
GLenum filter) override;
bool checkStatus() const override; bool checkStatus() const override;
......
...@@ -263,9 +263,9 @@ gl::Error RendererGL::drawRangeElements(const gl::ContextState &data, ...@@ -263,9 +263,9 @@ gl::Error RendererGL::drawRangeElements(const gl::ContextState &data,
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
ContextImpl *RendererGL::createContext() ContextImpl *RendererGL::createContext(const gl::ContextState &state)
{ {
return new ContextGL; return new ContextGL(state);
} }
CompilerImpl *RendererGL::createCompiler() CompilerImpl *RendererGL::createCompiler()
......
...@@ -60,7 +60,7 @@ class RendererGL : public Renderer ...@@ -60,7 +60,7 @@ class RendererGL : public Renderer
const GLvoid *indices, const GLvoid *indices,
const gl::IndexRange &indexRange) override; const gl::IndexRange &indexRange) override;
ContextImpl *createContext() override; ContextImpl *createContext(const gl::ContextState &state) override;
// Shader creation // Shader creation
CompilerImpl *createCompiler() override; CompilerImpl *createCompiler() override;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifndef TESTS_ANGLE_UNITTESTS_UTILS_H_ #ifndef TESTS_ANGLE_UNITTESTS_UTILS_H_
#define TESTS_ANGLE_UNITTESTS_UTILS_H_ #define TESTS_ANGLE_UNITTESTS_UTILS_H_
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/ImplFactory.h" #include "libANGLE/renderer/ImplFactory.h"
namespace rx namespace rx
...@@ -62,7 +63,7 @@ class NullFactory : public ImplFactory ...@@ -62,7 +63,7 @@ class NullFactory : public ImplFactory
class MockFactory : public ImplFactory class MockFactory : public ImplFactory
{ {
public: public:
MOCK_METHOD0(createContext, ContextImpl *()); MOCK_METHOD1(createContext, ContextImpl *(const gl::ContextState &));
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