Commit 87e63a99 by Corentin Wallez

Make the default framebuffer owned by Surface

In CGL there is no notion of default Framebuffer and MakeCurrent only makes a context current but not a drawable. Instead, everything is done via render to texture. For that reason, different surfaces will have different FBOs as default framebuffers, which causes that change. BUG=angleproject:891 Change-Id: I3f6da7b587353316026ea39a5c87f91265e0f1ba Reviewed-on: https://chromium-review.googlesource.com/289872Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 8b76e9fb
...@@ -94,15 +94,10 @@ Context::Context(const egl::Config *config, ...@@ -94,15 +94,10 @@ Context::Context(const egl::Config *config,
mState.initializeZeroTextures(mZeroTextures); mState.initializeZeroTextures(mZeroTextures);
// Allocate default FBO
mFramebufferMap[0] = new Framebuffer(mCaps, mRenderer, 0);
bindVertexArray(0); bindVertexArray(0);
bindArrayBuffer(0); bindArrayBuffer(0);
bindElementArrayBuffer(0); bindElementArrayBuffer(0);
bindReadFramebuffer(0);
bindDrawFramebuffer(0);
bindRenderbuffer(0); bindRenderbuffer(0);
bindGenericUniformBuffer(0); bindGenericUniformBuffer(0);
...@@ -136,10 +131,13 @@ Context::~Context() ...@@ -136,10 +131,13 @@ Context::~Context()
{ {
mState.reset(); mState.reset();
while (!mFramebufferMap.empty()) for (auto framebuffer : mFramebufferMap)
{ {
// Delete the framebuffer in reverse order to destroy the framebuffer zero last. // Default framebuffer are owned by their respective Surface
deleteFramebuffer(mFramebufferMap.rbegin()->first); if (framebuffer.second->id() != 0)
{
SafeDelete(framebuffer.second);
}
} }
while (!mFenceNVMap.empty()) while (!mFenceNVMap.empty())
...@@ -204,60 +202,43 @@ void Context::makeCurrent(egl::Surface *surface) ...@@ -204,60 +202,43 @@ void Context::makeCurrent(egl::Surface *surface)
{ {
releaseSurface(); releaseSurface();
} }
ASSERT(mCurrentSurface == nullptr);
mCurrentSurface = surface;
surface->setIsCurrent(true); surface->setIsCurrent(true);
mCurrentSurface = surface;
// Update default framebuffer // Update default framebuffer, the binding of the previous default
Framebuffer *defaultFBO = mFramebufferMap[0]; // framebuffer (or lack of) will have a nullptr.
GLenum drawBufferState = GL_BACK;
defaultFBO->setDrawBuffers(1, &drawBufferState);
defaultFBO->setReadBuffer(GL_BACK);
const FramebufferAttachment *backAttachment = defaultFBO->getAttachment(GL_BACK);
if (backAttachment && backAttachment->getSurface() == surface)
{
// 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); Framebuffer *newDefault = surface->getDefaultFramebuffer();
} if (mState.getReadFramebuffer() == nullptr)
else {
{ mState.setReadFramebufferBinding(newDefault);
defaultFBO->resetAttachment(GL_STENCIL); }
if (mState.getDrawFramebuffer() == nullptr)
{
mState.setDrawFramebufferBinding(newDefault);
}
mFramebufferMap[0] = newDefault;
} }
} }
void Context::releaseSurface() void Context::releaseSurface()
{ {
Framebuffer *defaultFBO = mFramebufferMap[0]; ASSERT(mCurrentSurface != nullptr);
if (defaultFBO)
// Remove the default framebuffer
{ {
defaultFBO->resetAttachment(GL_BACK); Framebuffer *currentDefault = mCurrentSurface->getDefaultFramebuffer();
defaultFBO->resetAttachment(GL_DEPTH); if (mState.getReadFramebuffer() == currentDefault)
defaultFBO->resetAttachment(GL_STENCIL); {
mState.setReadFramebufferBinding(nullptr);
}
if (mState.getDrawFramebuffer() == currentDefault)
{
mState.setDrawFramebufferBinding(nullptr);
}
mFramebufferMap.erase(0);
} }
ASSERT(mCurrentSurface != nullptr);
mCurrentSurface->setIsCurrent(false); mCurrentSurface->setIsCurrent(false);
mCurrentSurface = nullptr; mCurrentSurface = nullptr;
} }
...@@ -1400,10 +1381,19 @@ EGLenum Context::getClientType() const ...@@ -1400,10 +1381,19 @@ EGLenum Context::getClientType() const
EGLenum Context::getRenderBuffer() const EGLenum Context::getRenderBuffer() const
{ {
ASSERT(mFramebufferMap.count(0) > 0); auto framebufferIt = mFramebufferMap.find(0);
const Framebuffer *framebuffer = mFramebufferMap.find(0)->second; if (framebufferIt != mFramebufferMap.end())
const FramebufferAttachment *backAttachment = framebuffer->getAttachment(GL_BACK); {
return backAttachment ? backAttachment->getSurface()->getRenderBuffer() : EGL_NONE; const Framebuffer *framebuffer = framebufferIt->second;
const FramebufferAttachment *backAttachment = framebuffer->getAttachment(GL_BACK);
ASSERT(backAttachment != nullptr);
return backAttachment->getSurface()->getRenderBuffer();
}
else
{
return EGL_NONE;
}
} }
const Caps &Context::getCaps() const const Caps &Context::getCaps() const
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#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"
#include "libANGLE/renderer/SurfaceImpl.h"
namespace gl namespace gl
{ {
...@@ -37,6 +38,14 @@ void DetachMatchingAttachment(FramebufferAttachment *attachment, GLenum matchTyp ...@@ -37,6 +38,14 @@ 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) Framebuffer::Data::Data(const Caps &caps)
: mColorAttachments(caps.maxColorAttachments), : mColorAttachments(caps.maxColorAttachments),
mDrawBufferStates(caps.maxDrawBuffers, GL_NONE), mDrawBufferStates(caps.maxDrawBuffers, GL_NONE),
...@@ -116,18 +125,15 @@ const FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment() cons ...@@ -116,18 +125,15 @@ const FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment() cons
} }
Framebuffer::Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id) Framebuffer::Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id)
: mData(caps), : mData(caps), mImpl(factory->createFramebuffer(mData)), mId(id)
mImpl(nullptr), {
mId(id) ASSERT(mId != 0);
ASSERT(mImpl != nullptr);
}
Framebuffer::Framebuffer(rx::SurfaceImpl *surface)
: mData(), mImpl(surface->createDefaultFramebuffer(mData)), mId(0)
{ {
if (mId == 0)
{
mImpl = factory->createDefaultFramebuffer(mData);
}
else
{
mImpl = factory->createFramebuffer(mData);
}
ASSERT(mImpl != nullptr); ASSERT(mImpl != nullptr);
} }
...@@ -277,6 +283,11 @@ bool Framebuffer::hasEnabledColorAttachment() const ...@@ -277,6 +283,11 @@ bool Framebuffer::hasEnabledColorAttachment() const
return false; return false;
} }
int Framebuffer::getNumColorBuffers() const
{
return mData.mColorAttachments.size();
}
bool Framebuffer::hasStencil() const bool Framebuffer::hasStencil() const
{ {
return (mData.mStencilAttachment.isAttached() && mData.mStencilAttachment.getStencilSize() > 0); return (mData.mStencilAttachment.isAttached() && mData.mStencilAttachment.getStencilSize() > 0);
......
...@@ -23,6 +23,7 @@ namespace rx ...@@ -23,6 +23,7 @@ namespace rx
class ImplFactory; class ImplFactory;
class FramebufferImpl; class FramebufferImpl;
class RenderbufferImpl; class RenderbufferImpl;
class SurfaceImpl;
} }
namespace egl namespace egl
...@@ -50,6 +51,7 @@ class Framebuffer ...@@ -50,6 +51,7 @@ class Framebuffer
class Data final : angle::NonCopyable class Data final : angle::NonCopyable
{ {
public: public:
explicit Data();
explicit Data(const Caps &caps); explicit Data(const Caps &caps);
~Data(); ~Data();
...@@ -76,6 +78,7 @@ class Framebuffer ...@@ -76,6 +78,7 @@ class Framebuffer
}; };
Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id); Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id);
Framebuffer(rx::SurfaceImpl *surface);
virtual ~Framebuffer(); virtual ~Framebuffer();
const rx::FramebufferImpl *getImplementation() const { return mImpl; } const rx::FramebufferImpl *getImplementation() const { return mImpl; }
...@@ -111,6 +114,7 @@ class Framebuffer ...@@ -111,6 +114,7 @@ class Framebuffer
bool isEnabledColorAttachment(unsigned int colorAttachment) const; bool isEnabledColorAttachment(unsigned int colorAttachment) const;
bool hasEnabledColorAttachment() const; bool hasEnabledColorAttachment() const;
int getNumColorBuffers() const;
bool hasStencil() const; bool hasStencil() const;
int getSamples(const gl::Data &data) const; int getSamples(const gl::Data &data) const;
bool usingExtendedDrawBuffers() const; bool usingExtendedDrawBuffers() const;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
#include "libANGLE/Config.h" #include "libANGLE/Config.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
#include <EGL/eglext.h> #include <EGL/eglext.h>
...@@ -26,6 +27,7 @@ Surface::Surface(rx::SurfaceImpl *impl, ...@@ -26,6 +27,7 @@ Surface::Surface(rx::SurfaceImpl *impl,
const AttributeMap &attributes) const AttributeMap &attributes)
: FramebufferAttachmentObject(), : FramebufferAttachmentObject(),
mImplementation(impl), mImplementation(impl),
mDefaultFramebuffer(nullptr),
mCurrentCount(0), mCurrentCount(0),
mDestroyed(false), mDestroyed(false),
mType(surfaceType), mType(surfaceType),
...@@ -55,6 +57,9 @@ Surface::Surface(rx::SurfaceImpl *impl, ...@@ -55,6 +57,9 @@ Surface::Surface(rx::SurfaceImpl *impl,
mTextureFormat = attributes.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE); mTextureFormat = attributes.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE);
mTextureTarget = attributes.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE); mTextureTarget = attributes.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE);
} }
mDefaultFramebuffer = createDefaultFramebuffer();
ASSERT(mDefaultFramebuffer != nullptr);
} }
Surface::~Surface() Surface::~Surface()
...@@ -213,4 +218,30 @@ GLuint Surface::getId() const ...@@ -213,4 +218,30 @@ GLuint Surface::getId() const
UNREACHABLE(); UNREACHABLE();
return 0; 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,6 +21,7 @@ ...@@ -21,6 +21,7 @@
namespace gl namespace gl
{ {
class Framebuffer;
class Texture; class Texture;
} }
...@@ -64,6 +65,7 @@ class Surface final : public gl::FramebufferAttachmentObject ...@@ -64,6 +65,7 @@ class Surface final : public gl::FramebufferAttachmentObject
EGLenum getTextureTarget() const; EGLenum getTextureTarget() const;
gl::Texture *getBoundTexture() const { return mTexture.get(); } gl::Texture *getBoundTexture() const { return mTexture.get(); }
gl::Framebuffer *getDefaultFramebuffer() { return mDefaultFramebuffer; }
EGLint isFixedSize() const; EGLint isFixedSize() const;
...@@ -81,11 +83,14 @@ class Surface final : public gl::FramebufferAttachmentObject ...@@ -81,11 +83,14 @@ class Surface final : public gl::FramebufferAttachmentObject
virtual ~Surface(); virtual ~Surface();
rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override { return mImplementation; } rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override { return mImplementation; }
gl::Framebuffer *createDefaultFramebuffer();
// ANGLE-only method, used internally // ANGLE-only method, used internally
friend class gl::Texture; friend class gl::Texture;
void releaseTexImageFromTexture(); void releaseTexImageFromTexture();
rx::SurfaceImpl *mImplementation; rx::SurfaceImpl *mImplementation;
gl::Framebuffer *mDefaultFramebuffer;
int mCurrentCount; int mCurrentCount;
bool mDestroyed; bool mDestroyed;
......
...@@ -20,6 +20,8 @@ class MockSurfaceImpl : public rx::SurfaceImpl ...@@ -20,6 +20,8 @@ class MockSurfaceImpl : public rx::SurfaceImpl
virtual ~MockSurfaceImpl() { destroy(); } virtual ~MockSurfaceImpl() { destroy(); }
MOCK_METHOD0(initialize, egl::Error()); MOCK_METHOD0(initialize, egl::Error());
MOCK_METHOD1(createDefaultFramebuffer,
rx::FramebufferImpl *(const gl::Framebuffer::Data &data));
MOCK_METHOD0(swap, egl::Error()); MOCK_METHOD0(swap, egl::Error());
MOCK_METHOD4(postSubBuffer, egl::Error(EGLint, EGLint, EGLint, EGLint)); MOCK_METHOD4(postSubBuffer, egl::Error(EGLint, EGLint, EGLint, EGLint));
MOCK_METHOD2(querySurfacePointerANGLE, egl::Error(EGLint, void**)); MOCK_METHOD2(querySurfacePointerANGLE, egl::Error(EGLint, void**));
......
...@@ -29,8 +29,8 @@ DisplayImpl::~DisplayImpl() ...@@ -29,8 +29,8 @@ DisplayImpl::~DisplayImpl()
void DisplayImpl::destroySurface(egl::Surface *surface) void DisplayImpl::destroySurface(egl::Surface *surface)
{ {
surface->onDestroy();
mSurfaceSet.erase(surface); mSurfaceSet.erase(surface);
surface->onDestroy();
} }
const egl::DisplayExtensions &DisplayImpl::getExtensions() const const egl::DisplayExtensions &DisplayImpl::getExtensions() const
......
...@@ -40,7 +40,6 @@ class ImplFactory : angle::NonCopyable ...@@ -40,7 +40,6 @@ class ImplFactory : angle::NonCopyable
virtual ProgramImpl *createProgram() = 0; virtual ProgramImpl *createProgram() = 0;
// Framebuffer creation // Framebuffer creation
virtual FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) = 0;
virtual FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) = 0; virtual FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) = 0;
// Texture creation // Texture creation
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
namespace egl namespace egl
...@@ -22,6 +23,8 @@ struct Config; ...@@ -22,6 +23,8 @@ struct Config;
namespace rx namespace rx
{ {
class FramebufferImpl;
class SurfaceImpl : public FramebufferAttachmentObjectImpl class SurfaceImpl : public FramebufferAttachmentObjectImpl
{ {
public: public:
...@@ -29,6 +32,7 @@ class SurfaceImpl : public FramebufferAttachmentObjectImpl ...@@ -29,6 +32,7 @@ class SurfaceImpl : public FramebufferAttachmentObjectImpl
virtual ~SurfaceImpl(); virtual ~SurfaceImpl();
virtual egl::Error initialize() = 0; virtual egl::Error initialize() = 0;
virtual FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) = 0;
virtual egl::Error swap() = 0; virtual egl::Error swap() = 0;
virtual egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) = 0; virtual egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) = 0;
virtual egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) = 0; virtual egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) = 0;
......
...@@ -519,7 +519,7 @@ size_t RendererD3D::getBoundFramebufferTextures(const gl::Data &data, Framebuffe ...@@ -519,7 +519,7 @@ size_t RendererD3D::getBoundFramebufferTextures(const gl::Data &data, Framebuffe
size_t textureCount = 0; size_t textureCount = 0;
const gl::Framebuffer *drawFramebuffer = data.state->getDrawFramebuffer(); const gl::Framebuffer *drawFramebuffer = data.state->getDrawFramebuffer();
for (unsigned int i = 0; i < data.caps->maxColorAttachments; i++) for (int i = 0; i < drawFramebuffer->getNumColorBuffers(); i++)
{ {
const gl::FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i); const gl::FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(i);
if (attachment && attachment->type() == GL_TEXTURE) if (attachment && attachment->type() == GL_TEXTURE)
......
...@@ -80,6 +80,11 @@ egl::Error SurfaceD3D::initialize() ...@@ -80,6 +80,11 @@ egl::Error SurfaceD3D::initialize()
return egl::Error(EGL_SUCCESS); return egl::Error(EGL_SUCCESS);
} }
FramebufferImpl *SurfaceD3D::createDefaultFramebuffer(const gl::Framebuffer::Data &data)
{
return mRenderer->createFramebuffer(data);
}
egl::Error SurfaceD3D::bindTexImage(EGLint) egl::Error SurfaceD3D::bindTexImage(EGLint)
{ {
return egl::Error(EGL_SUCCESS); return egl::Error(EGL_SUCCESS);
......
...@@ -33,6 +33,7 @@ class SurfaceD3D : public SurfaceImpl ...@@ -33,6 +33,7 @@ class SurfaceD3D : public SurfaceImpl
void releaseSwapChain(); void releaseSwapChain();
egl::Error initialize() override; egl::Error initialize() override;
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
egl::Error swap() override; egl::Error swap() override;
egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override; egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override;
......
...@@ -2960,11 +2960,6 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -2960,11 +2960,6 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
return gl::Error(GL_NO_ERROR); 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) FramebufferImpl *Renderer11::createFramebuffer(const gl::Framebuffer::Data &data)
{ {
return new Framebuffer11(data, this); return new Framebuffer11(data, this);
......
...@@ -182,7 +182,6 @@ class Renderer11 : public RendererD3D ...@@ -182,7 +182,6 @@ class Renderer11 : public RendererD3D
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT); virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT);
// Framebuffer creation // Framebuffer creation
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override; FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Shader creation // Shader creation
......
...@@ -2645,11 +2645,6 @@ gl::Error Renderer9::createRenderTarget(int width, int height, GLenum format, GL ...@@ -2645,11 +2645,6 @@ gl::Error Renderer9::createRenderTarget(int width, int height, GLenum format, GL
return gl::Error(GL_NO_ERROR); 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) FramebufferImpl *Renderer9::createFramebuffer(const gl::Framebuffer::Data &data)
{ {
return new Framebuffer9(data, this); return new Framebuffer9(data, this);
......
...@@ -167,7 +167,6 @@ class Renderer9 : public RendererD3D ...@@ -167,7 +167,6 @@ class Renderer9 : public RendererD3D
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT); virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT);
// Framebuffer creation // Framebuffer creation
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override; FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Shader creation // Shader creation
......
...@@ -36,6 +36,7 @@ class DisplayGL : public DisplayImpl ...@@ -36,6 +36,7 @@ class DisplayGL : public DisplayImpl
egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override; egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override;
protected: protected:
RendererGL *getRenderer() const { return mRenderer; };
const gl::Version &getMaxSupportedESVersion() const; const gl::Version &getMaxSupportedESVersion() const;
private: private:
......
...@@ -181,11 +181,6 @@ ProgramImpl *RendererGL::createProgram() ...@@ -181,11 +181,6 @@ ProgramImpl *RendererGL::createProgram()
return new ProgramGL(mFunctions, mStateManager); return new ProgramGL(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) FramebufferImpl *RendererGL::createFramebuffer(const gl::Framebuffer::Data &data)
{ {
return new FramebufferGL(data, mFunctions, mStateManager, false); return new FramebufferGL(data, mFunctions, mStateManager, false);
......
...@@ -39,7 +39,6 @@ class RendererGL : public Renderer ...@@ -39,7 +39,6 @@ class RendererGL : public Renderer
ProgramImpl *createProgram() override; ProgramImpl *createProgram() override;
// Framebuffer creation // Framebuffer creation
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override; FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Texture creation // Texture creation
...@@ -80,6 +79,8 @@ class RendererGL : public Renderer ...@@ -80,6 +79,8 @@ class RendererGL : public Renderer
void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) override; void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) override;
const gl::Version &getMaxSupportedESVersion() const; const gl::Version &getMaxSupportedESVersion() const;
const FunctionsGL *getFunctions() const { return mFunctions; }
StateManagerGL *getStateManager() const { return mStateManager; }
private: private:
void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps, void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps,
......
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
#include "libANGLE/renderer/gl/SurfaceGL.h" #include "libANGLE/renderer/gl/SurfaceGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/RendererGL.h"
namespace rx namespace rx
{ {
SurfaceGL::SurfaceGL() SurfaceGL::SurfaceGL(RendererGL *renderer) : SurfaceImpl(), mRenderer(renderer)
: SurfaceImpl()
{ {
} }
...@@ -20,4 +22,8 @@ SurfaceGL::~SurfaceGL() ...@@ -20,4 +22,8 @@ SurfaceGL::~SurfaceGL()
{ {
} }
FramebufferImpl *SurfaceGL::createDefaultFramebuffer(const gl::Framebuffer::Data &data)
{
return new FramebufferGL(data, mRenderer->getFunctions(), mRenderer->getStateManager(), true);
}
} }
...@@ -14,10 +14,12 @@ ...@@ -14,10 +14,12 @@
namespace rx namespace rx
{ {
class RendererGL;
class SurfaceGL : public SurfaceImpl class SurfaceGL : public SurfaceImpl
{ {
public: public:
SurfaceGL(); SurfaceGL(RendererGL *renderer);
~SurfaceGL() override; ~SurfaceGL() override;
gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target, gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
...@@ -26,7 +28,12 @@ class SurfaceGL : public SurfaceImpl ...@@ -26,7 +28,12 @@ class SurfaceGL : public SurfaceImpl
return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL"); return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL");
} }
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override;
virtual egl::Error makeCurrent() = 0; virtual egl::Error makeCurrent() = 0;
private:
RendererGL *mRenderer;
}; };
} }
......
...@@ -42,7 +42,7 @@ SurfaceImpl *DisplayCGL::createWindowSurface(const egl::Config *configuration, ...@@ -42,7 +42,7 @@ SurfaceImpl *DisplayCGL::createWindowSurface(const egl::Config *configuration,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
return new WindowSurfaceCGL(); return new WindowSurfaceCGL(this->getRenderer());
} }
SurfaceImpl *DisplayCGL::createPbufferSurface(const egl::Config *configuration, SurfaceImpl *DisplayCGL::createPbufferSurface(const egl::Config *configuration,
......
...@@ -17,7 +17,7 @@ namespace rx ...@@ -17,7 +17,7 @@ namespace rx
class WindowSurfaceCGL : public SurfaceGL class WindowSurfaceCGL : public SurfaceGL
{ {
public: public:
WindowSurfaceCGL(); WindowSurfaceCGL(RendererGL *renderer);
~WindowSurfaceCGL() override; ~WindowSurfaceCGL() override;
egl::Error initialize() override; egl::Error initialize() override;
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#include "libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h" #include "libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h"
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
namespace rx namespace rx
{ {
WindowSurfaceCGL::WindowSurfaceCGL() WindowSurfaceCGL::WindowSurfaceCGL(RendererGL *renderer) : SurfaceGL(renderer)
: SurfaceGL()
{ {
} }
......
...@@ -197,7 +197,8 @@ SurfaceImpl *DisplayGLX::createWindowSurface(const egl::Config *configuration, ...@@ -197,7 +197,8 @@ SurfaceImpl *DisplayGLX::createWindowSurface(const egl::Config *configuration,
ASSERT(configIdToGLXConfig.count(configuration->configID) > 0); ASSERT(configIdToGLXConfig.count(configuration->configID) > 0);
glx::FBConfig fbConfig = configIdToGLXConfig[configuration->configID]; glx::FBConfig fbConfig = configIdToGLXConfig[configuration->configID];
return new WindowSurfaceGLX(mGLX, *this, window, mGLX.getDisplay(), mContext, fbConfig); return new WindowSurfaceGLX(mGLX, this, this->getRenderer(), window, mGLX.getDisplay(),
mContext, fbConfig);
} }
SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::Config *configuration, SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::Config *configuration,
...@@ -210,7 +211,8 @@ SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::Config *configuration, ...@@ -210,7 +211,8 @@ SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::Config *configuration,
EGLint height = attribs.get(EGL_HEIGHT, 0); EGLint height = attribs.get(EGL_HEIGHT, 0);
bool largest = (attribs.get(EGL_LARGEST_PBUFFER, EGL_FALSE) == EGL_TRUE); bool largest = (attribs.get(EGL_LARGEST_PBUFFER, EGL_FALSE) == EGL_TRUE);
return new PbufferSurfaceGLX(width, height, largest, mGLX, mContext, fbConfig); return new PbufferSurfaceGLX(this->getRenderer(), width, height, largest, mGLX, mContext,
fbConfig);
} }
SurfaceImpl* DisplayGLX::createPbufferFromClientBuffer(const egl::Config *configuration, SurfaceImpl* DisplayGLX::createPbufferFromClientBuffer(const egl::Config *configuration,
......
...@@ -9,14 +9,20 @@ ...@@ -9,14 +9,20 @@
#include "libANGLE/renderer/gl/glx/PbufferSurfaceGLX.h" #include "libANGLE/renderer/gl/glx/PbufferSurfaceGLX.h"
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/renderer/gl/glx/DisplayGLX.h"
#include "libANGLE/renderer/gl/glx/FunctionsGLX.h" #include "libANGLE/renderer/gl/glx/FunctionsGLX.h"
namespace rx namespace rx
{ {
PbufferSurfaceGLX::PbufferSurfaceGLX(EGLint width, EGLint height, bool largest, const FunctionsGLX &glx, PbufferSurfaceGLX::PbufferSurfaceGLX(RendererGL *renderer,
glx::Context context, glx::FBConfig fbConfig) EGLint width,
: SurfaceGL(), EGLint height,
bool largest,
const FunctionsGLX &glx,
glx::Context context,
glx::FBConfig fbConfig)
: SurfaceGL(renderer),
mWidth(width), mWidth(width),
mHeight(height), mHeight(height),
mLargest(largest), mLargest(largest),
......
...@@ -15,13 +15,19 @@ ...@@ -15,13 +15,19 @@
namespace rx namespace rx
{ {
class DisplayGLX;
class FunctionsGLX; class FunctionsGLX;
class PbufferSurfaceGLX : public SurfaceGL class PbufferSurfaceGLX : public SurfaceGL
{ {
public: public:
PbufferSurfaceGLX(EGLint width, EGLint height, bool largest, const FunctionsGLX &glx, PbufferSurfaceGLX(RendererGL *renderer,
glx::Context context, glx::FBConfig fbConfig); EGLint width,
EGLint height,
bool largest,
const FunctionsGLX &glx,
glx::Context context,
glx::FBConfig fbConfig);
~PbufferSurfaceGLX() override; ~PbufferSurfaceGLX() override;
egl::Error initialize() override; egl::Error initialize() override;
......
...@@ -16,14 +16,19 @@ ...@@ -16,14 +16,19 @@
namespace rx namespace rx
{ {
WindowSurfaceGLX::WindowSurfaceGLX(const FunctionsGLX &glx, const DisplayGLX &glxDisplay, Window window, Display *display, WindowSurfaceGLX::WindowSurfaceGLX(const FunctionsGLX &glx,
glx::Context context, glx::FBConfig fbConfig) DisplayGLX *glxDisplay,
: SurfaceGL(), RendererGL *renderer,
Window window,
Display *display,
glx::Context context,
glx::FBConfig fbConfig)
: SurfaceGL(renderer),
mParent(window), mParent(window),
mWindow(0), mWindow(0),
mDisplay(display), mDisplay(display),
mGLX(glx), mGLX(glx),
mGLXDisplay(glxDisplay), mGLXDisplay(*glxDisplay),
mContext(context), mContext(context),
mFBConfig(fbConfig), mFBConfig(fbConfig),
mGLXWindow(0), mGLXWindow(0),
......
...@@ -21,8 +21,13 @@ class FunctionsGLX; ...@@ -21,8 +21,13 @@ class FunctionsGLX;
class WindowSurfaceGLX : public SurfaceGL class WindowSurfaceGLX : public SurfaceGL
{ {
public: public:
WindowSurfaceGLX(const FunctionsGLX &glx, const DisplayGLX &glxDisplay, Window window, Display *display, WindowSurfaceGLX(const FunctionsGLX &glx,
glx::Context context, glx::FBConfig fbConfig); DisplayGLX *glxDisplay,
RendererGL *renderer,
Window window,
Display *display,
glx::Context context,
glx::FBConfig fbConfig);
~WindowSurfaceGLX() override; ~WindowSurfaceGLX() override;
egl::Error initialize() override; egl::Error initialize() override;
......
...@@ -321,7 +321,8 @@ SurfaceImpl *DisplayWGL::createWindowSurface(const egl::Config *configuration, ...@@ -321,7 +321,8 @@ SurfaceImpl *DisplayWGL::createWindowSurface(const egl::Config *configuration,
EGLNativeWindowType window, EGLNativeWindowType window,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
return new WindowSurfaceWGL(window, mPixelFormat, mWGLContext, mFunctionsWGL); return new WindowSurfaceWGL(this->getRenderer(), window, mPixelFormat, mWGLContext,
mFunctionsWGL);
} }
SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::Config *configuration, SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::Config *configuration,
...@@ -333,8 +334,8 @@ SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::Config *configuration, ...@@ -333,8 +334,8 @@ SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::Config *configuration,
EGLenum textureFormat = attribs.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE); EGLenum textureFormat = attribs.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE);
EGLenum textureTarget = attribs.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE); EGLenum textureTarget = attribs.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE);
return new PbufferSurfaceWGL(width, height, textureFormat, textureTarget, largest, return new PbufferSurfaceWGL(this->getRenderer(), width, height, textureFormat, textureTarget,
mPixelFormat, mDeviceContext, mWGLContext, mFunctionsWGL); largest, mPixelFormat, mDeviceContext, mWGLContext, mFunctionsWGL);
} }
SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::Config *configuration, SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::Config *configuration,
......
...@@ -9,16 +9,24 @@ ...@@ -9,16 +9,24 @@
#include "libANGLE/renderer/gl/wgl/PbufferSurfaceWGL.h" #include "libANGLE/renderer/gl/wgl/PbufferSurfaceWGL.h"
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/renderer/gl/RendererGL.h"
#include "libANGLE/renderer/gl/wgl/FunctionsWGL.h" #include "libANGLE/renderer/gl/wgl/FunctionsWGL.h"
#include "libANGLE/renderer/gl/wgl/wgl_utils.h" #include "libANGLE/renderer/gl/wgl/wgl_utils.h"
namespace rx namespace rx
{ {
PbufferSurfaceWGL::PbufferSurfaceWGL(EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget, PbufferSurfaceWGL::PbufferSurfaceWGL(RendererGL *renderer,
bool largest, int pixelFormat, HDC deviceContext, HGLRC wglContext, EGLint width,
EGLint height,
EGLenum textureFormat,
EGLenum textureTarget,
bool largest,
int pixelFormat,
HDC deviceContext,
HGLRC wglContext,
const FunctionsWGL *functions) const FunctionsWGL *functions)
: SurfaceGL(), : SurfaceGL(renderer),
mWidth(width), mWidth(width),
mHeight(height), mHeight(height),
mLargest(largest), mLargest(largest),
......
...@@ -21,8 +21,15 @@ class FunctionsWGL; ...@@ -21,8 +21,15 @@ class FunctionsWGL;
class PbufferSurfaceWGL : public SurfaceGL class PbufferSurfaceWGL : public SurfaceGL
{ {
public: public:
PbufferSurfaceWGL(EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget, PbufferSurfaceWGL(RendererGL *renderer,
bool largest, int pixelFormat, HDC deviceContext, HGLRC wglContext, EGLint width,
EGLint height,
EGLenum textureFormat,
EGLenum textureTarget,
bool largest,
int pixelFormat,
HDC deviceContext,
HGLRC wglContext,
const FunctionsWGL *functions); const FunctionsWGL *functions);
~PbufferSurfaceWGL() override; ~PbufferSurfaceWGL() override;
......
...@@ -9,17 +9,19 @@ ...@@ -9,17 +9,19 @@
#include "libANGLE/renderer/gl/wgl/WindowSurfaceWGL.h" #include "libANGLE/renderer/gl/wgl/WindowSurfaceWGL.h"
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/renderer/gl/RendererGL.h"
#include "libANGLE/renderer/gl/wgl/FunctionsWGL.h" #include "libANGLE/renderer/gl/wgl/FunctionsWGL.h"
#include "libANGLE/renderer/gl/wgl/wgl_utils.h" #include "libANGLE/renderer/gl/wgl/wgl_utils.h"
namespace rx namespace rx
{ {
WindowSurfaceWGL::WindowSurfaceWGL(EGLNativeWindowType window, WindowSurfaceWGL::WindowSurfaceWGL(RendererGL *renderer,
EGLNativeWindowType window,
int pixelFormat, int pixelFormat,
HGLRC wglContext, HGLRC wglContext,
const FunctionsWGL *functions) const FunctionsWGL *functions)
: SurfaceGL(), : SurfaceGL(renderer),
mPixelFormat(pixelFormat), mPixelFormat(pixelFormat),
mWGLContext(wglContext), mWGLContext(wglContext),
mWindow(window), mWindow(window),
......
...@@ -21,7 +21,11 @@ class FunctionsWGL; ...@@ -21,7 +21,11 @@ class FunctionsWGL;
class WindowSurfaceWGL : public SurfaceGL class WindowSurfaceWGL : public SurfaceGL
{ {
public: public:
WindowSurfaceWGL(EGLNativeWindowType window, int pixelFormat, HGLRC wglContext, const FunctionsWGL *functions); WindowSurfaceWGL(RendererGL *renderer,
EGLNativeWindowType window,
int pixelFormat,
HGLRC wglContext,
const FunctionsWGL *functions);
~WindowSurfaceWGL() override; ~WindowSurfaceWGL() override;
egl::Error initialize() override; egl::Error initialize() override;
......
...@@ -605,7 +605,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -605,7 +605,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
GLenum readInternalFormat = readColorBuffer->getInternalFormat(); GLenum readInternalFormat = readColorBuffer->getInternalFormat();
const InternalFormat &readFormatInfo = GetInternalFormatInfo(readInternalFormat); const InternalFormat &readFormatInfo = GetInternalFormatInfo(readInternalFormat);
for (GLuint i = 0; i < context->getCaps().maxColorAttachments; i++) for (int i = 0; i < drawFramebuffer->getNumColorBuffers(); i++)
{ {
if (drawFramebuffer->isEnabledColorAttachment(i)) if (drawFramebuffer->isEnabledColorAttachment(i))
{ {
...@@ -661,7 +661,8 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -661,7 +661,8 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
return false; return false;
} }
for (GLuint colorAttachment = 0; colorAttachment < context->getCaps().maxColorAttachments; ++colorAttachment) for (int colorAttachment = 0;
colorAttachment < drawFramebuffer->getNumColorBuffers(); ++colorAttachment)
{ {
if (drawFramebuffer->isEnabledColorAttachment(colorAttachment)) if (drawFramebuffer->isEnabledColorAttachment(colorAttachment))
{ {
......
...@@ -26,7 +26,6 @@ class NullFactory : public ImplFactory ...@@ -26,7 +26,6 @@ class NullFactory : public ImplFactory
ProgramImpl *createProgram() override { return nullptr; } ProgramImpl *createProgram() override { return nullptr; }
// Framebuffer creation // Framebuffer creation
FramebufferImpl *createDefaultFramebuffer(const gl::Framebuffer::Data &data) override { return nullptr; }
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override { return nullptr; } FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override { return nullptr; }
// Texture creation // Texture creation
......
...@@ -55,7 +55,7 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest ...@@ -55,7 +55,7 @@ class D3D11EmulatedIndexedBufferTest : public ANGLETest
void TearDown() override void TearDown() override
{ {
SafeDelete(mSourceBuffer); SafeDelete(mSourceBuffer);
ANGLETest::TearDown(); ANGLETest::TearDown();
} }
void createMappableCompareBufferFromEmulatedBuffer(ID3D11Buffer *sourceBuffer, GLuint size, ID3D11Buffer **mappableBuffer) 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