Commit 11cd6af6 by Corentin Wallez

Revert "Make the default framebuffer owned by Surface"

Compilation warning on Windows This reverts commit 6cb2ae82. Change-Id: I4ecadf5d8e909f986da186a7326cfa0922ae8710 Reviewed-on: https://chromium-review.googlesource.com/294241Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 6cb2ae82
......@@ -94,10 +94,15 @@ Context::Context(const egl::Config *config,
mState.initializeZeroTextures(mZeroTextures);
// Allocate default FBO
mFramebufferMap[0] = new Framebuffer(mCaps, mRenderer, 0);
bindVertexArray(0);
bindArrayBuffer(0);
bindElementArrayBuffer(0);
bindReadFramebuffer(0);
bindDrawFramebuffer(0);
bindRenderbuffer(0);
bindGenericUniformBuffer(0);
......@@ -131,13 +136,10 @@ Context::~Context()
{
mState.reset();
for (auto framebuffer : mFramebufferMap)
while (!mFramebufferMap.empty())
{
// Default framebuffer are owned by their respective Surface
if (framebuffer.second->id() != 0)
{
SafeDelete(framebuffer.second);
}
// Delete the framebuffer in reverse order to destroy the framebuffer zero last.
deleteFramebuffer(mFramebufferMap.rbegin()->first);
}
while (!mFenceNVMap.empty())
......@@ -202,43 +204,60 @@ void Context::makeCurrent(egl::Surface *surface)
{
releaseSurface();
}
surface->setIsCurrent(true);
ASSERT(mCurrentSurface == nullptr);
mCurrentSurface = surface;
surface->setIsCurrent(true);
// Update default framebuffer
Framebuffer *defaultFBO = mFramebufferMap[0];
GLenum drawBufferState = GL_BACK;
defaultFBO->setDrawBuffers(1, &drawBufferState);
defaultFBO->setReadBuffer(GL_BACK);
// Update default framebuffer, the binding of the previous default
// framebuffer (or lack of) will have a nullptr.
const FramebufferAttachment *backAttachment = defaultFBO->getAttachment(GL_BACK);
if (backAttachment && backAttachment->getSurface() == surface)
{
Framebuffer *newDefault = surface->getDefaultFramebuffer();
if (mState.getReadFramebuffer() == nullptr)
{
mState.setReadFramebufferBinding(newDefault);
}
if (mState.getDrawFramebuffer() == nullptr)
{
mState.setDrawFramebufferBinding(newDefault);
}
mFramebufferMap[0] = newDefault;
// FBO already initialized to the surface.
return;
}
const egl::Config *config = surface->getConfig();
defaultFBO->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_BACK, ImageIndex::MakeInvalid(), surface);
if (config->depthSize > 0)
{
defaultFBO->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, ImageIndex::MakeInvalid(), surface);
}
else
{
defaultFBO->resetAttachment(GL_DEPTH);
}
if (config->stencilSize > 0)
{
defaultFBO->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_STENCIL, ImageIndex::MakeInvalid(), surface);
}
else
{
defaultFBO->resetAttachment(GL_STENCIL);
}
}
void Context::releaseSurface()
{
ASSERT(mCurrentSurface != nullptr);
// Remove the default framebuffer
Framebuffer *defaultFBO = mFramebufferMap[0];
if (defaultFBO)
{
Framebuffer *currentDefault = mCurrentSurface->getDefaultFramebuffer();
if (mState.getReadFramebuffer() == currentDefault)
{
mState.setReadFramebufferBinding(nullptr);
}
if (mState.getDrawFramebuffer() == currentDefault)
{
mState.setDrawFramebufferBinding(nullptr);
}
mFramebufferMap.erase(0);
defaultFBO->resetAttachment(GL_BACK);
defaultFBO->resetAttachment(GL_DEPTH);
defaultFBO->resetAttachment(GL_STENCIL);
}
ASSERT(mCurrentSurface != nullptr);
mCurrentSurface->setIsCurrent(false);
mCurrentSurface = nullptr;
}
......@@ -1383,19 +1402,10 @@ EGLenum Context::getClientType() const
EGLenum Context::getRenderBuffer() const
{
auto framebufferIt = mFramebufferMap.find(0);
if (framebufferIt != mFramebufferMap.end())
{
const Framebuffer *framebuffer = framebufferIt->second;
const FramebufferAttachment *backAttachment = framebuffer->getAttachment(GL_BACK);
ASSERT(backAttachment != nullptr);
return backAttachment->getSurface()->getRenderBuffer();
}
else
{
return EGL_NONE;
}
ASSERT(mFramebufferMap.count(0) > 0);
const Framebuffer *framebuffer = mFramebufferMap.find(0)->second;
const FramebufferAttachment *backAttachment = framebuffer->getAttachment(GL_BACK);
return backAttachment ? backAttachment->getSurface()->getRenderBuffer() : EGL_NONE;
}
const Caps &Context::getCaps() const
......
......@@ -20,7 +20,6 @@
#include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/ImplFactory.h"
#include "libANGLE/renderer/RenderbufferImpl.h"
#include "libANGLE/renderer/SurfaceImpl.h"
namespace gl
{
......@@ -38,14 +37,6 @@ void DetachMatchingAttachment(FramebufferAttachment *attachment, GLenum matchTyp
}
}
Framebuffer::Data::Data()
: mColorAttachments(1),
mDrawBufferStates(1, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT)
{
mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
}
Framebuffer::Data::Data(const Caps &caps)
: mColorAttachments(caps.maxColorAttachments),
mDrawBufferStates(caps.maxDrawBuffers, GL_NONE),
......@@ -92,7 +83,7 @@ const FramebufferAttachment *Framebuffer::Data::getDepthOrStencilAttachment() co
return nullptr;
}
const FramebufferAttachment *Framebuffer::Data::getColorAttachment(size_t colorAttachment) const
const FramebufferAttachment *Framebuffer::Data::getColorAttachment(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < mColorAttachments.size());
return mColorAttachments[colorAttachment].isAttached() ?
......@@ -125,15 +116,18 @@ const FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment() cons
}
Framebuffer::Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id)
: mData(caps), mImpl(factory->createFramebuffer(mData)), mId(id)
{
ASSERT(mId != 0);
ASSERT(mImpl != nullptr);
}
Framebuffer::Framebuffer(rx::SurfaceImpl *surface)
: mData(), mImpl(surface->createDefaultFramebuffer(mData)), mId(0)
: mData(caps),
mImpl(nullptr),
mId(id)
{
if (mId == 0)
{
mImpl = factory->createDefaultFramebuffer(mData);
}
else
{
mImpl = factory->createFramebuffer(mData);
}
ASSERT(mImpl != nullptr);
}
......@@ -163,7 +157,7 @@ void Framebuffer::detachResourceById(GLenum resourceType, GLuint resourceId)
DetachMatchingAttachment(&mData.mStencilAttachment, resourceType, resourceId);
}
const FramebufferAttachment *Framebuffer::getColorbuffer(size_t colorAttachment) const
const FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment) const
{
return mData.getColorAttachment(colorAttachment);
}
......@@ -263,7 +257,7 @@ void Framebuffer::setReadBuffer(GLenum buffer)
mImpl->setReadBuffer(buffer);
}
bool Framebuffer::isEnabledColorAttachment(size_t colorAttachment) const
bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < mData.mColorAttachments.size());
return (mData.mColorAttachments[colorAttachment].isAttached() &&
......@@ -283,11 +277,6 @@ bool Framebuffer::hasEnabledColorAttachment() const
return false;
}
size_t Framebuffer::getNumColorBuffers() const
{
return mData.mColorAttachments.size();
}
bool Framebuffer::hasStencil() const
{
return (mData.mStencilAttachment.isAttached() && mData.mStencilAttachment.getStencilSize() > 0);
......
......@@ -23,7 +23,6 @@ namespace rx
class ImplFactory;
class FramebufferImpl;
class RenderbufferImpl;
class SurfaceImpl;
}
namespace egl
......@@ -51,14 +50,13 @@ class Framebuffer
class Data final : angle::NonCopyable
{
public:
explicit Data();
explicit Data(const Caps &caps);
~Data();
const FramebufferAttachment *getReadAttachment() const;
const FramebufferAttachment *getFirstColorAttachment() const;
const FramebufferAttachment *getDepthOrStencilAttachment() const;
const FramebufferAttachment *getColorAttachment(size_t colorAttachment) const;
const FramebufferAttachment *getColorAttachment(unsigned int colorAttachment) const;
const FramebufferAttachment *getDepthAttachment() const;
const FramebufferAttachment *getStencilAttachment() const;
const FramebufferAttachment *getDepthStencilAttachment() const;
......@@ -78,7 +76,6 @@ class Framebuffer
};
Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id);
Framebuffer(rx::SurfaceImpl *surface);
virtual ~Framebuffer();
const rx::FramebufferImpl *getImplementation() const { return mImpl; }
......@@ -95,7 +92,7 @@ class Framebuffer
void detachTexture(GLuint texture);
void detachRenderbuffer(GLuint renderbuffer);
const FramebufferAttachment *getColorbuffer(size_t colorAttachment) const;
const FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
const FramebufferAttachment *getDepthbuffer() const;
const FramebufferAttachment *getStencilbuffer() const;
const FramebufferAttachment *getDepthStencilBuffer() const;
......@@ -112,9 +109,8 @@ class Framebuffer
GLenum getReadBufferState() const;
void setReadBuffer(GLenum buffer);
bool isEnabledColorAttachment(size_t colorAttachment) const;
bool isEnabledColorAttachment(unsigned int colorAttachment) const;
bool hasEnabledColorAttachment() const;
size_t getNumColorBuffers() const;
bool hasStencil() const;
int getSamples(const gl::Data &data) const;
bool usingExtendedDrawBuffers() const;
......
......@@ -11,7 +11,6 @@
#include "libANGLE/Surface.h"
#include "libANGLE/Config.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/Texture.h"
#include <EGL/eglext.h>
......@@ -27,7 +26,6 @@ Surface::Surface(rx::SurfaceImpl *impl,
const AttributeMap &attributes)
: FramebufferAttachmentObject(),
mImplementation(impl),
mDefaultFramebuffer(nullptr),
mCurrentCount(0),
mDestroyed(false),
mType(surfaceType),
......@@ -57,9 +55,6 @@ Surface::Surface(rx::SurfaceImpl *impl,
mTextureFormat = attributes.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE);
mTextureTarget = attributes.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE);
}
mDefaultFramebuffer = createDefaultFramebuffer();
ASSERT(mDefaultFramebuffer != nullptr);
}
Surface::~Surface()
......@@ -218,30 +213,4 @@ GLuint Surface::getId() const
UNREACHABLE();
return 0;
}
gl::Framebuffer *Surface::createDefaultFramebuffer()
{
gl::Framebuffer *framebuffer = new gl::Framebuffer(mImplementation);
GLenum drawBufferState = GL_BACK;
framebuffer->setDrawBuffers(1, &drawBufferState);
framebuffer->setReadBuffer(GL_BACK);
framebuffer->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_BACK, gl::ImageIndex::MakeInvalid(),
this);
if (mConfig->depthSize > 0)
{
framebuffer->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, gl::ImageIndex::MakeInvalid(),
this);
}
if (mConfig->stencilSize > 0)
{
framebuffer->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_STENCIL,
gl::ImageIndex::MakeInvalid(), this);
}
return framebuffer;
}
}
......@@ -21,7 +21,6 @@
namespace gl
{
class Framebuffer;
class Texture;
}
......@@ -65,7 +64,6 @@ class Surface final : public gl::FramebufferAttachmentObject
EGLenum getTextureTarget() const;
gl::Texture *getBoundTexture() const { return mTexture.get(); }
gl::Framebuffer *getDefaultFramebuffer() { return mDefaultFramebuffer; }
EGLint isFixedSize() const;
......@@ -83,14 +81,11 @@ class Surface final : public gl::FramebufferAttachmentObject
virtual ~Surface();
rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override { return mImplementation; }
gl::Framebuffer *createDefaultFramebuffer();
// ANGLE-only method, used internally
friend class gl::Texture;
void releaseTexImageFromTexture();
rx::SurfaceImpl *mImplementation;
gl::Framebuffer *mDefaultFramebuffer;
int mCurrentCount;
bool mDestroyed;
......
......@@ -6,13 +6,9 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/AttributeMap.h"
#include "libANGLE/Config.h"
#include "libANGLE/Data.h"
#include "libANGLE/State.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/SurfaceImpl.h"
namespace
......@@ -24,8 +20,6 @@ class MockSurfaceImpl : public rx::SurfaceImpl
virtual ~MockSurfaceImpl() { destroy(); }
MOCK_METHOD0(initialize, egl::Error());
MOCK_METHOD1(createDefaultFramebuffer,
rx::FramebufferImpl *(const gl::Framebuffer::Data &data));
MOCK_METHOD0(swap, egl::Error());
MOCK_METHOD4(postSubBuffer, egl::Error(EGLint, EGLint, EGLint, EGLint));
MOCK_METHOD2(querySurfacePointerANGLE, egl::Error(EGLint, void**));
......@@ -41,71 +35,15 @@ class MockSurfaceImpl : public rx::SurfaceImpl
MOCK_METHOD0(destroy, void());
};
class MockFramebufferImpl : public rx::FramebufferImpl
{
public:
MockFramebufferImpl() : rx::FramebufferImpl(gl::Framebuffer::Data()) {}
virtual ~MockFramebufferImpl() { destroy(); }
MOCK_METHOD1(onUpdateColorAttachment, void(size_t));
MOCK_METHOD0(onUpdateDepthAttachment, void());
MOCK_METHOD0(onUpdateStencilAttachment, void());
MOCK_METHOD0(onUpdateDepthStencilAttachment, void());
MOCK_METHOD2(setDrawBuffers, void(size_t, const GLenum *));
MOCK_METHOD1(setReadBuffer, void(GLenum));
MOCK_METHOD2(discard, 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_METHOD2(clear, gl::Error(const gl::Data &, GLbitfield));
MOCK_METHOD4(clearBufferfv, gl::Error(const gl::State &, GLenum, GLint, const GLfloat *));
MOCK_METHOD4(clearBufferuiv, gl::Error(const gl::State &, GLenum, GLint, const GLuint *));
MOCK_METHOD4(clearBufferiv, gl::Error(const gl::State &, GLenum, GLint, const GLint *));
MOCK_METHOD5(clearBufferfi, gl::Error(const gl::State &, GLenum, GLint, GLfloat, GLint));
MOCK_CONST_METHOD0(getImplementationColorReadFormat, GLenum());
MOCK_CONST_METHOD0(getImplementationColorReadType, GLenum());
MOCK_CONST_METHOD5(
readPixels,
gl::Error(const gl::State &, const gl::Rectangle &, GLenum, GLenum, GLvoid *));
MOCK_METHOD6(blit,
gl::Error(const gl::State &,
const gl::Rectangle &,
const gl::Rectangle &,
GLbitfield,
GLenum,
const gl::Framebuffer *));
MOCK_CONST_METHOD0(checkStatus, GLenum());
MOCK_METHOD0(destroy, void());
};
class SurfaceTest : public testing::Test
{
protected:
virtual void SetUp()
{
MockFramebufferImpl *framebuffer = new MockFramebufferImpl;
mSurfaceImpl = new MockSurfaceImpl;
EXPECT_CALL(*mSurfaceImpl, getSwapBehavior());
EXPECT_CALL(*mSurfaceImpl, createDefaultFramebuffer(testing::_))
.WillOnce(testing::Return(framebuffer));
EXPECT_CALL(*mSurfaceImpl, destroy());
EXPECT_CALL(*framebuffer, setDrawBuffers(1, testing::_));
EXPECT_CALL(*framebuffer, setReadBuffer(GL_BACK));
EXPECT_CALL(*framebuffer, onUpdateColorAttachment(0));
mSurface = new egl::Surface(mSurfaceImpl, EGL_WINDOW_BIT, &mConfig, egl::AttributeMap());
EXPECT_CALL(*framebuffer, destroy());
SafeDelete(framebuffer);
mImpl = new MockSurfaceImpl;
EXPECT_CALL(*mImpl, getSwapBehavior());
EXPECT_CALL(*mImpl, destroy());
mSurface = new egl::Surface(mImpl, EGL_WINDOW_BIT, &mConfig, egl::AttributeMap());
}
virtual void TearDown()
......@@ -113,31 +51,20 @@ class SurfaceTest : public testing::Test
mSurface->onDestroy();
}
MockSurfaceImpl *mSurfaceImpl;
MockSurfaceImpl *mImpl;
egl::Surface *mSurface;
egl::Config mConfig;
};
TEST_F(SurfaceTest, DestructionDeletesImpl)
{
MockFramebufferImpl *framebuffer = new MockFramebufferImpl;
MockSurfaceImpl *impl = new MockSurfaceImpl;
EXPECT_CALL(*impl, getSwapBehavior());
EXPECT_CALL(*impl, createDefaultFramebuffer(testing::_)).WillOnce(testing::Return(framebuffer));
EXPECT_CALL(*framebuffer, setDrawBuffers(1, testing::_));
EXPECT_CALL(*framebuffer, setReadBuffer(GL_BACK));
EXPECT_CALL(*framebuffer, onUpdateColorAttachment(0));
EXPECT_CALL(*impl, destroy()).Times(1).RetiresOnSaturation();
egl::Surface *surface = new egl::Surface(impl, EGL_WINDOW_BIT, &mConfig, egl::AttributeMap());
surface->onDestroy();
EXPECT_CALL(*framebuffer, destroy());
SafeDelete(framebuffer);
// Only needed because the mock is leaked if bugs are present,
// which logs an error, but does not cause the test to fail.
// Ordinarily mocks are verified when destroyed.
......
......@@ -29,8 +29,8 @@ DisplayImpl::~DisplayImpl()
void DisplayImpl::destroySurface(egl::Surface *surface)
{
mSurfaceSet.erase(surface);
surface->onDestroy();
mSurfaceSet.erase(surface);
}
const egl::DisplayExtensions &DisplayImpl::getExtensions() const
......
......@@ -41,6 +41,7 @@ class ImplFactory : angle::NonCopyable
virtual ProgramImpl *createProgram(const gl::Program::Data &data) = 0;
// Framebuffer creation
virtual FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) = 0;
virtual FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) = 0;
// Texture creation
......
......@@ -11,7 +11,6 @@
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
namespace egl
......@@ -23,8 +22,6 @@ struct Config;
namespace rx
{
class FramebufferImpl;
class SurfaceImpl : public FramebufferAttachmentObjectImpl
{
public:
......@@ -32,7 +29,6 @@ class SurfaceImpl : public FramebufferAttachmentObjectImpl
virtual ~SurfaceImpl();
virtual egl::Error initialize() = 0;
virtual FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) = 0;
virtual egl::Error swap() = 0;
virtual egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) = 0;
virtual egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) = 0;
......
......@@ -519,7 +519,7 @@ size_t RendererD3D::getBoundFramebufferTextures(const gl::Data &data, Framebuffe
size_t textureCount = 0;
const gl::Framebuffer *drawFramebuffer = data.state->getDrawFramebuffer();
for (int i = 0; i < drawFramebuffer->getNumColorBuffers(); i++)
for (unsigned int i = 0; i < data.caps->maxColorAttachments; i++)
{
const gl::FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i);
if (attachment && attachment->type() == GL_TEXTURE)
......
......@@ -80,11 +80,6 @@ egl::Error SurfaceD3D::initialize()
return egl::Error(EGL_SUCCESS);
}
FramebufferImpl *SurfaceD3D::createDefaultFramebuffer(const gl::Framebuffer::Data &data)
{
return mRenderer->createFramebuffer(data);
}
egl::Error SurfaceD3D::bindTexImage(EGLint)
{
return egl::Error(EGL_SUCCESS);
......
......@@ -33,7 +33,6 @@ class SurfaceD3D : public SurfaceImpl
void releaseSwapChain();
egl::Error initialize() override;
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
egl::Error swap() override;
egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override;
......
......@@ -2962,6 +2962,11 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
return gl::Error(GL_NO_ERROR);
}
FramebufferImpl *Renderer11::createDefaultFramebuffer(const gl::Framebuffer::Data &data)
{
return createFramebuffer(data);
}
FramebufferImpl *Renderer11::createFramebuffer(const gl::Framebuffer::Data &data)
{
return new Framebuffer11(data, this);
......
......@@ -182,6 +182,7 @@ class Renderer11 : public RendererD3D
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT);
// Framebuffer creation
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Shader creation
......
......@@ -2652,6 +2652,11 @@ gl::Error Renderer9::createRenderTarget(int width, int height, GLenum format, GL
return gl::Error(GL_NO_ERROR);
}
FramebufferImpl *Renderer9::createDefaultFramebuffer(const gl::Framebuffer::Data &data)
{
return createFramebuffer(data);
}
FramebufferImpl *Renderer9::createFramebuffer(const gl::Framebuffer::Data &data)
{
return new Framebuffer9(data, this);
......
......@@ -167,6 +167,7 @@ class Renderer9 : public RendererD3D
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT);
// Framebuffer creation
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Shader creation
......
......@@ -36,7 +36,6 @@ class DisplayGL : public DisplayImpl
egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override;
protected:
RendererGL *getRenderer() const { return mRenderer; };
const gl::Version &getMaxSupportedESVersion() const;
private:
......
......@@ -181,6 +181,11 @@ ProgramImpl *RendererGL::createProgram(const gl::Program::Data &data)
return new ProgramGL(data, mFunctions, mStateManager);
}
FramebufferImpl *RendererGL::createDefaultFramebuffer(const gl::Framebuffer::Data &data)
{
return new FramebufferGL(data, mFunctions, mStateManager, true);
}
FramebufferImpl *RendererGL::createFramebuffer(const gl::Framebuffer::Data &data)
{
return new FramebufferGL(data, mFunctions, mStateManager, false);
......
......@@ -39,6 +39,7 @@ class RendererGL : public Renderer
ProgramImpl *createProgram(const gl::Program::Data &data) override;
// Framebuffer creation
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Texture creation
......@@ -79,8 +80,6 @@ class RendererGL : public Renderer
void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) override;
const gl::Version &getMaxSupportedESVersion() const;
const FunctionsGL *getFunctions() const { return mFunctions; }
StateManagerGL *getStateManager() const { return mStateManager; }
private:
void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps,
......
......@@ -8,13 +8,11 @@
#include "libANGLE/renderer/gl/SurfaceGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/RendererGL.h"
namespace rx
{
SurfaceGL::SurfaceGL(RendererGL *renderer) : SurfaceImpl(), mRenderer(renderer)
SurfaceGL::SurfaceGL()
: SurfaceImpl()
{
}
......@@ -22,8 +20,4 @@ SurfaceGL::~SurfaceGL()
{
}
FramebufferImpl *SurfaceGL::createDefaultFramebuffer(const gl::Framebuffer::Data &data)
{
return new FramebufferGL(data, mRenderer->getFunctions(), mRenderer->getStateManager(), true);
}
}
......@@ -14,12 +14,10 @@
namespace rx
{
class RendererGL;
class SurfaceGL : public SurfaceImpl
{
public:
SurfaceGL(RendererGL *renderer);
SurfaceGL();
~SurfaceGL() override;
gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
......@@ -28,12 +26,7 @@ class SurfaceGL : public SurfaceImpl
return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL");
}
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
virtual egl::Error makeCurrent() = 0;
private:
RendererGL *mRenderer;
};
}
......
......@@ -42,7 +42,7 @@ SurfaceImpl *DisplayCGL::createWindowSurface(const egl::Config *configuration,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return new WindowSurfaceCGL(this->getRenderer());
return new WindowSurfaceCGL();
}
SurfaceImpl *DisplayCGL::createPbufferSurface(const egl::Config *configuration,
......
......@@ -17,7 +17,7 @@ namespace rx
class WindowSurfaceCGL : public SurfaceGL
{
public:
WindowSurfaceCGL(RendererGL *renderer);
WindowSurfaceCGL();
~WindowSurfaceCGL() override;
egl::Error initialize() override;
......
......@@ -9,12 +9,12 @@
#include "libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h"
#include "common/debug.h"
#include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
namespace rx
{
WindowSurfaceCGL::WindowSurfaceCGL(RendererGL *renderer) : SurfaceGL(renderer)
WindowSurfaceCGL::WindowSurfaceCGL()
: SurfaceGL()
{
}
......
......@@ -197,8 +197,7 @@ SurfaceImpl *DisplayGLX::createWindowSurface(const egl::Config *configuration,
ASSERT(configIdToGLXConfig.count(configuration->configID) > 0);
glx::FBConfig fbConfig = configIdToGLXConfig[configuration->configID];
return new WindowSurfaceGLX(mGLX, this, this->getRenderer(), window, mGLX.getDisplay(),
mContext, fbConfig);
return new WindowSurfaceGLX(mGLX, *this, window, mGLX.getDisplay(), mContext, fbConfig);
}
SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::Config *configuration,
......@@ -211,8 +210,7 @@ SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::Config *configuration,
EGLint height = attribs.get(EGL_HEIGHT, 0);
bool largest = (attribs.get(EGL_LARGEST_PBUFFER, EGL_FALSE) == EGL_TRUE);
return new PbufferSurfaceGLX(this->getRenderer(), width, height, largest, mGLX, mContext,
fbConfig);
return new PbufferSurfaceGLX(width, height, largest, mGLX, mContext, fbConfig);
}
SurfaceImpl* DisplayGLX::createPbufferFromClientBuffer(const egl::Config *configuration,
......
......@@ -9,20 +9,14 @@
#include "libANGLE/renderer/gl/glx/PbufferSurfaceGLX.h"
#include "common/debug.h"
#include "libANGLE/renderer/gl/glx/DisplayGLX.h"
#include "libANGLE/renderer/gl/glx/FunctionsGLX.h"
namespace rx
{
PbufferSurfaceGLX::PbufferSurfaceGLX(RendererGL *renderer,
EGLint width,
EGLint height,
bool largest,
const FunctionsGLX &glx,
glx::Context context,
glx::FBConfig fbConfig)
: SurfaceGL(renderer),
PbufferSurfaceGLX::PbufferSurfaceGLX(EGLint width, EGLint height, bool largest, const FunctionsGLX &glx,
glx::Context context, glx::FBConfig fbConfig)
: SurfaceGL(),
mWidth(width),
mHeight(height),
mLargest(largest),
......
......@@ -15,19 +15,13 @@
namespace rx
{
class DisplayGLX;
class FunctionsGLX;
class PbufferSurfaceGLX : public SurfaceGL
{
public:
PbufferSurfaceGLX(RendererGL *renderer,
EGLint width,
EGLint height,
bool largest,
const FunctionsGLX &glx,
glx::Context context,
glx::FBConfig fbConfig);
PbufferSurfaceGLX(EGLint width, EGLint height, bool largest, const FunctionsGLX &glx,
glx::Context context, glx::FBConfig fbConfig);
~PbufferSurfaceGLX() override;
egl::Error initialize() override;
......
......@@ -16,19 +16,14 @@
namespace rx
{
WindowSurfaceGLX::WindowSurfaceGLX(const FunctionsGLX &glx,
DisplayGLX *glxDisplay,
RendererGL *renderer,
Window window,
Display *display,
glx::Context context,
glx::FBConfig fbConfig)
: SurfaceGL(renderer),
WindowSurfaceGLX::WindowSurfaceGLX(const FunctionsGLX &glx, const DisplayGLX &glxDisplay, Window window, Display *display,
glx::Context context, glx::FBConfig fbConfig)
: SurfaceGL(),
mParent(window),
mWindow(0),
mDisplay(display),
mGLX(glx),
mGLXDisplay(*glxDisplay),
mGLXDisplay(glxDisplay),
mContext(context),
mFBConfig(fbConfig),
mGLXWindow(0),
......
......@@ -21,13 +21,8 @@ class FunctionsGLX;
class WindowSurfaceGLX : public SurfaceGL
{
public:
WindowSurfaceGLX(const FunctionsGLX &glx,
DisplayGLX *glxDisplay,
RendererGL *renderer,
Window window,
Display *display,
glx::Context context,
glx::FBConfig fbConfig);
WindowSurfaceGLX(const FunctionsGLX &glx, const DisplayGLX &glxDisplay, Window window, Display *display,
glx::Context context, glx::FBConfig fbConfig);
~WindowSurfaceGLX() override;
egl::Error initialize() override;
......
......@@ -321,8 +321,7 @@ SurfaceImpl *DisplayWGL::createWindowSurface(const egl::Config *configuration,
EGLNativeWindowType window,
const egl::AttributeMap &attribs)
{
return new WindowSurfaceWGL(this->getRenderer(), window, mPixelFormat, mWGLContext,
mFunctionsWGL);
return new WindowSurfaceWGL(window, mPixelFormat, mWGLContext, mFunctionsWGL);
}
SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::Config *configuration,
......@@ -334,8 +333,8 @@ SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::Config *configuration,
EGLenum textureFormat = attribs.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE);
EGLenum textureTarget = attribs.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE);
return new PbufferSurfaceWGL(this->getRenderer(), width, height, textureFormat, textureTarget,
largest, mPixelFormat, mDeviceContext, mWGLContext, mFunctionsWGL);
return new PbufferSurfaceWGL(width, height, textureFormat, textureTarget, largest,
mPixelFormat, mDeviceContext, mWGLContext, mFunctionsWGL);
}
SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::Config *configuration,
......
......@@ -9,24 +9,16 @@
#include "libANGLE/renderer/gl/wgl/PbufferSurfaceWGL.h"
#include "common/debug.h"
#include "libANGLE/renderer/gl/RendererGL.h"
#include "libANGLE/renderer/gl/wgl/FunctionsWGL.h"
#include "libANGLE/renderer/gl/wgl/wgl_utils.h"
namespace rx
{
PbufferSurfaceWGL::PbufferSurfaceWGL(RendererGL *renderer,
EGLint width,
EGLint height,
EGLenum textureFormat,
EGLenum textureTarget,
bool largest,
int pixelFormat,
HDC deviceContext,
HGLRC wglContext,
PbufferSurfaceWGL::PbufferSurfaceWGL(EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget,
bool largest, int pixelFormat, HDC deviceContext, HGLRC wglContext,
const FunctionsWGL *functions)
: SurfaceGL(renderer),
: SurfaceGL(),
mWidth(width),
mHeight(height),
mLargest(largest),
......
......@@ -21,15 +21,8 @@ class FunctionsWGL;
class PbufferSurfaceWGL : public SurfaceGL
{
public:
PbufferSurfaceWGL(RendererGL *renderer,
EGLint width,
EGLint height,
EGLenum textureFormat,
EGLenum textureTarget,
bool largest,
int pixelFormat,
HDC deviceContext,
HGLRC wglContext,
PbufferSurfaceWGL(EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget,
bool largest, int pixelFormat, HDC deviceContext, HGLRC wglContext,
const FunctionsWGL *functions);
~PbufferSurfaceWGL() override;
......
......@@ -9,19 +9,17 @@
#include "libANGLE/renderer/gl/wgl/WindowSurfaceWGL.h"
#include "common/debug.h"
#include "libANGLE/renderer/gl/RendererGL.h"
#include "libANGLE/renderer/gl/wgl/FunctionsWGL.h"
#include "libANGLE/renderer/gl/wgl/wgl_utils.h"
namespace rx
{
WindowSurfaceWGL::WindowSurfaceWGL(RendererGL *renderer,
EGLNativeWindowType window,
WindowSurfaceWGL::WindowSurfaceWGL(EGLNativeWindowType window,
int pixelFormat,
HGLRC wglContext,
const FunctionsWGL *functions)
: SurfaceGL(renderer),
: SurfaceGL(),
mPixelFormat(pixelFormat),
mWGLContext(wglContext),
mWindow(window),
......
......@@ -21,11 +21,7 @@ class FunctionsWGL;
class WindowSurfaceWGL : public SurfaceGL
{
public:
WindowSurfaceWGL(RendererGL *renderer,
EGLNativeWindowType window,
int pixelFormat,
HGLRC wglContext,
const FunctionsWGL *functions);
WindowSurfaceWGL(EGLNativeWindowType window, int pixelFormat, HGLRC wglContext, const FunctionsWGL *functions);
~WindowSurfaceWGL() override;
egl::Error initialize() override;
......
......@@ -605,7 +605,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
GLenum readInternalFormat = readColorBuffer->getInternalFormat();
const InternalFormat &readFormatInfo = GetInternalFormatInfo(readInternalFormat);
for (size_t i = 0; i < drawFramebuffer->getNumColorBuffers(); i++)
for (GLuint i = 0; i < context->getCaps().maxColorAttachments; i++)
{
if (drawFramebuffer->isEnabledColorAttachment(i))
{
......@@ -661,8 +661,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
return false;
}
for (size_t colorAttachment = 0;
colorAttachment < drawFramebuffer->getNumColorBuffers(); ++colorAttachment)
for (GLuint colorAttachment = 0; colorAttachment < context->getCaps().maxColorAttachments; ++colorAttachment)
{
if (drawFramebuffer->isEnabledColorAttachment(colorAttachment))
{
......
......@@ -26,6 +26,7 @@ class NullFactory : public ImplFactory
ProgramImpl *createProgram(const gl::Program::Data &data) override { return nullptr; }
// Framebuffer creation
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override { return nullptr; }
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override { return nullptr; }
// Texture creation
......
......@@ -55,7 +55,7 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest
void TearDown() override
{
SafeDelete(mSourceBuffer);
ANGLETest::TearDown();
ANGLETest::TearDown();
}
void createMappableCompareBufferFromEmulatedBuffer(ID3D11Buffer *sourceBuffer, GLuint size, ID3D11Buffer **mappableBuffer)
......
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