Commit d1405e51 by Jamie Madill

Share FBO state with object and Impl.

This patch introduces a new Framebuffer::Data class, which stores attachment related state. This will eliminate the need to store duplicated state between the classes. BUG=angleproject:930 Change-Id: I80de4db39ab99d623b0ad8306bf3cbb794cd8bd5 Reviewed-on: https://chromium-review.googlesource.com/254100Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 0af26e10
...@@ -184,10 +184,8 @@ void Context::makeCurrent(egl::Surface *surface) ...@@ -184,10 +184,8 @@ void Context::makeCurrent(egl::Surface *surface)
mHasBeenCurrent = true; mHasBeenCurrent = true;
} }
Framebuffer *framebufferZero = new DefaultFramebuffer(mRenderer->createFramebuffer(), // TODO(jmadill): do not allocate new pointers here
mRenderer->createDefaultAttachment(GL_BACK, surface), Framebuffer *framebufferZero = new DefaultFramebuffer(mCaps, mRenderer, surface);
mRenderer->createDefaultAttachment(GL_DEPTH, surface),
mRenderer->createDefaultAttachment(GL_STENCIL, surface));
setFramebufferZero(framebufferZero); setFramebufferZero(framebufferZero);
...@@ -523,7 +521,7 @@ void Context::bindReadFramebuffer(GLuint framebuffer) ...@@ -523,7 +521,7 @@ void Context::bindReadFramebuffer(GLuint framebuffer)
{ {
if (!getFramebuffer(framebuffer)) if (!getFramebuffer(framebuffer))
{ {
mFramebufferMap[framebuffer] = new Framebuffer(mRenderer->createFramebuffer(), framebuffer); mFramebufferMap[framebuffer] = new Framebuffer(mCaps, mRenderer, framebuffer);
} }
mState.setReadFramebufferBinding(getFramebuffer(framebuffer)); mState.setReadFramebufferBinding(getFramebuffer(framebuffer));
...@@ -533,7 +531,7 @@ void Context::bindDrawFramebuffer(GLuint framebuffer) ...@@ -533,7 +531,7 @@ void Context::bindDrawFramebuffer(GLuint framebuffer)
{ {
if (!getFramebuffer(framebuffer)) if (!getFramebuffer(framebuffer))
{ {
mFramebufferMap[framebuffer] = new Framebuffer(mRenderer->createFramebuffer(), framebuffer); mFramebufferMap[framebuffer] = new Framebuffer(mCaps, mRenderer, framebuffer);
} }
mState.setDrawFramebufferBinding(getFramebuffer(framebuffer)); mState.setDrawFramebufferBinding(getFramebuffer(framebuffer));
......
...@@ -23,118 +23,103 @@ ...@@ -23,118 +23,103 @@
namespace gl namespace gl
{ {
Framebuffer::Framebuffer(rx::FramebufferImpl *impl, GLuint id) namespace
: mImpl(impl),
mId(id),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT),
mDepthbuffer(NULL),
mStencilbuffer(NULL)
{ {
ASSERT(mImpl != nullptr); void DeleteMatchingAttachment(FramebufferAttachment *&attachment, GLenum matchType, GLuint matchId)
{
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) if (attachment && attachment->type() == matchType && attachment->id() == matchId)
{ {
mColorbuffers[colorAttachment] = NULL; SafeDelete(attachment);
mDrawBufferStates[colorAttachment] = GL_NONE;
} }
}
}
Framebuffer::Data::Data(const Caps &caps)
: mColorAttachments(caps.maxColorAttachments, nullptr),
mDepthAttachment(nullptr),
mStencilAttachment(nullptr),
mDrawBufferStates(caps.maxDrawBuffers, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT)
{
mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT; mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
} }
Framebuffer::~Framebuffer() Framebuffer::Data::~Data()
{ {
SafeDelete(mImpl); for (auto &colorAttachment : mColorAttachments)
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{ {
SafeDelete(mColorbuffers[colorAttachment]); SafeDelete(colorAttachment);
} }
SafeDelete(mDepthbuffer); SafeDelete(mDepthAttachment);
SafeDelete(mStencilbuffer); SafeDelete(mStencilAttachment);
} }
void Framebuffer::detachTexture(GLuint textureId) Framebuffer::Framebuffer(const Caps &caps, rx::Renderer *renderer, GLuint id)
: mData(caps),
mImpl(renderer->createFramebuffer(mData)),
mId(id)
{ {
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) ASSERT(mImpl != nullptr);
{ }
FramebufferAttachment *attachment = mColorbuffers[colorAttachment];
if (attachment && attachment->isTextureWithId(textureId))
{
SafeDelete(mColorbuffers[colorAttachment]);
}
}
if (mDepthbuffer && mDepthbuffer->isTextureWithId(textureId)) Framebuffer::~Framebuffer()
{ {
SafeDelete(mDepthbuffer); SafeDelete(mImpl);
} }
if (mStencilbuffer && mStencilbuffer->isTextureWithId(textureId)) void Framebuffer::detachTexture(GLuint textureId)
{ {
SafeDelete(mStencilbuffer); detachResourceById(GL_TEXTURE, textureId);
}
} }
void Framebuffer::detachRenderbuffer(GLuint renderbufferId) void Framebuffer::detachRenderbuffer(GLuint renderbufferId)
{ {
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) detachResourceById(GL_RENDERBUFFER, renderbufferId);
{ }
FramebufferAttachment *attachment = mColorbuffers[colorAttachment];
if (attachment && attachment->isRenderbufferWithId(renderbufferId))
{
SafeDelete(mColorbuffers[colorAttachment]);
}
}
if (mDepthbuffer && mDepthbuffer->isRenderbufferWithId(renderbufferId)) void Framebuffer::detachResourceById(GLenum resourceType, GLuint resourceId)
{
for (auto &colorAttachment : mData.mColorAttachments)
{ {
SafeDelete(mDepthbuffer); DeleteMatchingAttachment(colorAttachment, resourceType, resourceId);
} }
if (mStencilbuffer && mStencilbuffer->isRenderbufferWithId(renderbufferId)) DeleteMatchingAttachment(mData.mDepthAttachment, resourceType, resourceId);
{ DeleteMatchingAttachment(mData.mStencilAttachment, resourceType, resourceId);
SafeDelete(mStencilbuffer);
}
} }
FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment) const FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment) const
{ {
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); ASSERT(colorAttachment < mData.mColorAttachments.size());
return mColorbuffers[colorAttachment]; return mData.mColorAttachments[colorAttachment];
} }
FramebufferAttachment *Framebuffer::getDepthbuffer() const FramebufferAttachment *Framebuffer::getDepthbuffer() const
{ {
return mDepthbuffer; return mData.mDepthAttachment;
} }
FramebufferAttachment *Framebuffer::getStencilbuffer() const FramebufferAttachment *Framebuffer::getStencilbuffer() const
{ {
return mStencilbuffer; return mData.mStencilAttachment;
} }
FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const
{ {
return (hasValidDepthStencil() ? mDepthbuffer : NULL); return (hasValidDepthStencil() ? mData.mDepthAttachment : NULL);
} }
FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const
{ {
FramebufferAttachment *depthstencilbuffer = mDepthbuffer; return (mData.mDepthAttachment != nullptr ? mData.mDepthAttachment : mData.mStencilAttachment);
if (!depthstencilbuffer)
{
depthstencilbuffer = mStencilbuffer;
}
return depthstencilbuffer;
} }
FramebufferAttachment *Framebuffer::getReadColorbuffer() const FramebufferAttachment *Framebuffer::getReadColorbuffer() const
{ {
size_t readIndex = (mReadBufferState == GL_BACK ? 0 : static_cast<size_t>(mReadBufferState - GL_COLOR_ATTACHMENT0)); size_t readIndex = (mData.mReadBufferState == GL_BACK ? 0 :
ASSERT(readIndex < IMPLEMENTATION_MAX_DRAW_BUFFERS); static_cast<size_t>(mData.mReadBufferState - GL_COLOR_ATTACHMENT0));
return mColorbuffers[readIndex]; ASSERT(readIndex < mData.mColorAttachments.size());
return mData.mColorAttachments[readIndex];
} }
GLenum Framebuffer::getReadColorbufferType() const GLenum Framebuffer::getReadColorbufferType() const
...@@ -145,15 +130,15 @@ GLenum Framebuffer::getReadColorbufferType() const ...@@ -145,15 +130,15 @@ GLenum Framebuffer::getReadColorbufferType() const
FramebufferAttachment *Framebuffer::getFirstColorbuffer() const FramebufferAttachment *Framebuffer::getFirstColorbuffer() const
{ {
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) for (FramebufferAttachment *colorAttachment : mData.mColorAttachments)
{ {
if (mColorbuffers[colorAttachment]) if (colorAttachment != nullptr)
{ {
return mColorbuffers[colorAttachment]; return colorAttachment;
} }
} }
return NULL; return nullptr;
} }
FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
...@@ -187,39 +172,44 @@ FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const ...@@ -187,39 +172,44 @@ FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const
{ {
return mDrawBufferStates[colorAttachment]; ASSERT(colorAttachment < mData.mDrawBufferStates.size());
return mData.mDrawBufferStates[colorAttachment];
} }
void Framebuffer::setDrawBuffers(size_t count, const GLenum *buffers) void Framebuffer::setDrawBuffers(size_t count, const GLenum *buffers)
{ {
ASSERT(count <= ArraySize(mDrawBufferStates)); auto &drawStates = mData.mDrawBufferStates;
std::copy(buffers, buffers + count, mDrawBufferStates);
std::fill(mDrawBufferStates + count, mDrawBufferStates + ArraySize(mDrawBufferStates), GL_NONE); ASSERT(count <= drawStates.size());
std::copy(buffers, buffers + count, drawStates.begin());
std::fill(drawStates.begin() + count, drawStates.end(), GL_NONE);
mImpl->setDrawBuffers(count, buffers); mImpl->setDrawBuffers(count, buffers);
} }
GLenum Framebuffer::getReadBufferState() const GLenum Framebuffer::getReadBufferState() const
{ {
return mReadBufferState; return mData.mReadBufferState;
} }
void Framebuffer::setReadBuffer(GLenum buffer) void Framebuffer::setReadBuffer(GLenum buffer)
{ {
ASSERT(buffer == GL_BACK || buffer == GL_NONE || ASSERT(buffer == GL_BACK || buffer == GL_NONE ||
(buffer >= GL_COLOR_ATTACHMENT0 && (buffer >= GL_COLOR_ATTACHMENT0 &&
(buffer - GL_COLOR_ATTACHMENT0) < IMPLEMENTATION_MAX_DRAW_BUFFERS)); (buffer - GL_COLOR_ATTACHMENT0) < mData.mColorAttachments.size()));
mReadBufferState = buffer; mData.mReadBufferState = buffer;
mImpl->setReadBuffer(buffer); mImpl->setReadBuffer(buffer);
} }
bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const
{ {
return (mColorbuffers[colorAttachment] && mDrawBufferStates[colorAttachment] != GL_NONE); ASSERT(colorAttachment < mData.mColorAttachments.size());
return (mData.mColorAttachments[colorAttachment] &&
mData.mDrawBufferStates[colorAttachment] != GL_NONE);
} }
bool Framebuffer::hasEnabledColorAttachment() const bool Framebuffer::hasEnabledColorAttachment() const
{ {
for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) for (size_t colorAttachment = 0; colorAttachment < mData.mColorAttachments.size(); ++colorAttachment)
{ {
if (isEnabledColorAttachment(colorAttachment)) if (isEnabledColorAttachment(colorAttachment))
{ {
...@@ -232,12 +222,12 @@ bool Framebuffer::hasEnabledColorAttachment() const ...@@ -232,12 +222,12 @@ bool Framebuffer::hasEnabledColorAttachment() const
bool Framebuffer::hasStencil() const bool Framebuffer::hasStencil() const
{ {
return (mStencilbuffer && mStencilbuffer->getStencilSize() > 0); return (mData.mStencilAttachment && mData.mStencilAttachment->getStencilSize() > 0);
} }
bool Framebuffer::usingExtendedDrawBuffers() const bool Framebuffer::usingExtendedDrawBuffers() const
{ {
for (unsigned int colorAttachment = 1; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) for (size_t colorAttachment = 1; colorAttachment < mData.mColorAttachments.size(); ++colorAttachment)
{ {
if (isEnabledColorAttachment(colorAttachment)) if (isEnabledColorAttachment(colorAttachment))
{ {
...@@ -263,21 +253,19 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const ...@@ -263,21 +253,19 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const
int samples = -1; int samples = -1;
bool missingAttachment = true; bool missingAttachment = true;
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) for (const FramebufferAttachment *colorAttachment : mData.mColorAttachments)
{ {
const FramebufferAttachment *colorbuffer = mColorbuffers[colorAttachment]; if (colorAttachment != nullptr)
if (colorbuffer)
{ {
if (colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0) if (colorAttachment->getWidth() == 0 || colorAttachment->getHeight() == 0)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
GLenum internalformat = colorbuffer->getInternalFormat(); GLenum internalformat = colorAttachment->getInternalFormat();
const TextureCaps &formatCaps = data.textureCaps->get(internalformat); const TextureCaps &formatCaps = data.textureCaps->get(internalformat);
const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat); const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
if (colorbuffer->type() == GL_TEXTURE) if (colorAttachment->type() == GL_TEXTURE)
{ {
if (!formatCaps.renderable) if (!formatCaps.renderable)
{ {
...@@ -289,7 +277,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const ...@@ -289,7 +277,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
} }
else if (colorbuffer->type() == GL_RENDERBUFFER) else if (colorAttachment->type() == GL_RENDERBUFFER)
{ {
if (!formatCaps.renderable || formatInfo.depthBits > 0 || formatInfo.stencilBits > 0) if (!formatCaps.renderable || formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
{ {
...@@ -300,14 +288,14 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const ...@@ -300,14 +288,14 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const
if (!missingAttachment) if (!missingAttachment)
{ {
// all color attachments must have the same width and height // all color attachments must have the same width and height
if (colorbuffer->getWidth() != width || colorbuffer->getHeight() != height) if (colorAttachment->getWidth() != width || colorAttachment->getHeight() != height)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
} }
// APPLE_framebuffer_multisample, which EXT_draw_buffers refers to, requires that // APPLE_framebuffer_multisample, which EXT_draw_buffers refers to, requires that
// all color attachments have the same number of samples for the FBO to be complete. // all color attachments have the same number of samples for the FBO to be complete.
if (colorbuffer->getSamples() != samples) if (colorAttachment->getSamples() != samples)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT; return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT;
} }
...@@ -324,26 +312,27 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const ...@@ -324,26 +312,27 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const
} }
else else
{ {
width = colorbuffer->getWidth(); width = colorAttachment->getWidth();
height = colorbuffer->getHeight(); height = colorAttachment->getHeight();
samples = colorbuffer->getSamples(); samples = colorAttachment->getSamples();
colorbufferSize = formatInfo.pixelBytes; colorbufferSize = formatInfo.pixelBytes;
missingAttachment = false; missingAttachment = false;
} }
} }
} }
if (mDepthbuffer) const FramebufferAttachment *depthAttachment = mData.mDepthAttachment;
if (depthAttachment != nullptr)
{ {
if (mDepthbuffer->getWidth() == 0 || mDepthbuffer->getHeight() == 0) if (depthAttachment->getWidth() == 0 || depthAttachment->getHeight() == 0)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
GLenum internalformat = mDepthbuffer->getInternalFormat(); GLenum internalformat = depthAttachment->getInternalFormat();
const TextureCaps &formatCaps = data.textureCaps->get(internalformat); const TextureCaps &formatCaps = data.textureCaps->get(internalformat);
const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat); const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
if (mDepthbuffer->type() == GL_TEXTURE) if (depthAttachment->type() == GL_TEXTURE)
{ {
// depth texture attachments require OES/ANGLE_depth_texture // depth texture attachments require OES/ANGLE_depth_texture
if (!data.extensions->depthTextures) if (!data.extensions->depthTextures)
...@@ -361,7 +350,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const ...@@ -361,7 +350,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
} }
else if (mDepthbuffer->type() == GL_RENDERBUFFER) else if (depthAttachment->type() == GL_RENDERBUFFER)
{ {
if (!formatCaps.renderable || formatInfo.depthBits == 0) if (!formatCaps.renderable || formatInfo.depthBits == 0)
{ {
...@@ -371,32 +360,33 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const ...@@ -371,32 +360,33 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const
if (missingAttachment) if (missingAttachment)
{ {
width = mDepthbuffer->getWidth(); width = depthAttachment->getWidth();
height = mDepthbuffer->getHeight(); height = depthAttachment->getHeight();
samples = mDepthbuffer->getSamples(); samples = depthAttachment->getSamples();
missingAttachment = false; missingAttachment = false;
} }
else if (width != mDepthbuffer->getWidth() || height != mDepthbuffer->getHeight()) else if (width != depthAttachment->getWidth() || height != depthAttachment->getHeight())
{ {
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
} }
else if (samples != mDepthbuffer->getSamples()) else if (samples != depthAttachment->getSamples())
{ {
return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
} }
} }
if (mStencilbuffer) const FramebufferAttachment *stencilAttachment = mData.mStencilAttachment;
if (stencilAttachment)
{ {
if (mStencilbuffer->getWidth() == 0 || mStencilbuffer->getHeight() == 0) if (stencilAttachment->getWidth() == 0 || stencilAttachment->getHeight() == 0)
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
GLenum internalformat = mStencilbuffer->getInternalFormat(); GLenum internalformat = stencilAttachment->getInternalFormat();
const TextureCaps &formatCaps = data.textureCaps->get(internalformat); const TextureCaps &formatCaps = data.textureCaps->get(internalformat);
const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat); const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
if (mStencilbuffer->type() == GL_TEXTURE) if (stencilAttachment->type() == GL_TEXTURE)
{ {
// texture stencil attachments come along as part // texture stencil attachments come along as part
// of OES_packed_depth_stencil + OES/ANGLE_depth_texture // of OES_packed_depth_stencil + OES/ANGLE_depth_texture
...@@ -415,7 +405,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const ...@@ -415,7 +405,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
} }
else if (mStencilbuffer->type() == GL_RENDERBUFFER) else if (stencilAttachment->type() == GL_RENDERBUFFER)
{ {
if (!formatCaps.renderable || formatInfo.stencilBits == 0) if (!formatCaps.renderable || formatInfo.stencilBits == 0)
{ {
...@@ -425,16 +415,16 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const ...@@ -425,16 +415,16 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const
if (missingAttachment) if (missingAttachment)
{ {
width = mStencilbuffer->getWidth(); width = stencilAttachment->getWidth();
height = mStencilbuffer->getHeight(); height = stencilAttachment->getHeight();
samples = mStencilbuffer->getSamples(); samples = stencilAttachment->getSamples();
missingAttachment = false; missingAttachment = false;
} }
else if (width != mStencilbuffer->getWidth() || height != mStencilbuffer->getHeight()) else if (width != stencilAttachment->getWidth() || height != stencilAttachment->getHeight())
{ {
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
} }
else if (samples != mStencilbuffer->getSamples()) else if (samples != stencilAttachment->getSamples())
{ {
return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE; return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
} }
...@@ -442,7 +432,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const ...@@ -442,7 +432,7 @@ GLenum Framebuffer::checkStatus(const gl::Data &data) const
// if we have both a depth and stencil buffer, they must refer to the same object // if we have both a depth and stencil buffer, they must refer to the same object
// since we only support packed_depth_stencil and not separate depth and stencil // since we only support packed_depth_stencil and not separate depth and stencil
if (mDepthbuffer && mStencilbuffer && !hasValidDepthStencil()) if (depthAttachment && stencilAttachment && !hasValidDepthStencil())
{ {
return GL_FRAMEBUFFER_UNSUPPORTED; return GL_FRAMEBUFFER_UNSUPPORTED;
} }
...@@ -518,11 +508,11 @@ int Framebuffer::getSamples(const gl::Data &data) const ...@@ -518,11 +508,11 @@ int Framebuffer::getSamples(const gl::Data &data) const
{ {
// for a complete framebuffer, all attachments must have the same sample count // for a complete framebuffer, all attachments must have the same sample count
// in this case return the first nonzero sample size // in this case return the first nonzero sample size
for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) for (const FramebufferAttachment *colorAttachment : mData.mColorAttachments)
{ {
if (mColorbuffers[colorAttachment]) if (colorAttachment != nullptr)
{ {
return mColorbuffers[colorAttachment]->getSamples(); return colorAttachment->getSamples();
} }
} }
} }
...@@ -534,28 +524,28 @@ bool Framebuffer::hasValidDepthStencil() const ...@@ -534,28 +524,28 @@ bool Framebuffer::hasValidDepthStencil() const
{ {
// A valid depth-stencil attachment has the same resource bound to both the // A valid depth-stencil attachment has the same resource bound to both the
// depth and stencil attachment points. // depth and stencil attachment points.
return (mDepthbuffer && mStencilbuffer && return (mData.mDepthAttachment && mData.mStencilAttachment &&
mDepthbuffer->type() == mStencilbuffer->type() && mData.mDepthAttachment->type() == mData.mStencilAttachment->type() &&
mDepthbuffer->id() == mStencilbuffer->id()); mData.mDepthAttachment->id() == mData.mStencilAttachment->id());
} }
ColorbufferInfo Framebuffer::getColorbuffersForRender(const rx::Workarounds &workarounds) const ColorbufferInfo Framebuffer::getColorbuffersForRender(const rx::Workarounds &workarounds) const
{ {
ColorbufferInfo colorbuffersForRender; ColorbufferInfo colorbuffersForRender;
for (size_t colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; ++colorAttachment) for (size_t attachmentIndex = 0; attachmentIndex < mData.mColorAttachments.size(); ++attachmentIndex)
{ {
GLenum drawBufferState = mDrawBufferStates[colorAttachment]; GLenum drawBufferState = mData.mDrawBufferStates[attachmentIndex];
FramebufferAttachment *colorbuffer = mColorbuffers[colorAttachment]; FramebufferAttachment *colorAttachment = mData.mColorAttachments[attachmentIndex];
if (colorbuffer != NULL && drawBufferState != GL_NONE) if (colorAttachment != nullptr && drawBufferState != GL_NONE)
{ {
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + colorAttachment)); ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex));
colorbuffersForRender.push_back(colorbuffer); colorbuffersForRender.push_back(colorAttachment);
} }
else if (!workarounds.mrtPerfWorkaround) else if (!workarounds.mrtPerfWorkaround)
{ {
colorbuffersForRender.push_back(NULL); colorbuffersForRender.push_back(nullptr);
} }
} }
...@@ -579,54 +569,54 @@ void Framebuffer::setNULLAttachment(GLenum attachment) ...@@ -579,54 +569,54 @@ void Framebuffer::setNULLAttachment(GLenum attachment)
void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj) void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj)
{ {
if (attachment >= GL_COLOR_ATTACHMENT0 && attachment < (GL_COLOR_ATTACHMENT0 + IMPLEMENTATION_MAX_DRAW_BUFFERS)) if (attachment >= GL_COLOR_ATTACHMENT0 && attachment < (GL_COLOR_ATTACHMENT0 + mData.mColorAttachments.size()))
{ {
size_t colorAttachment = attachment - GL_COLOR_ATTACHMENT0; size_t colorAttachment = attachment - GL_COLOR_ATTACHMENT0;
SafeDelete(mColorbuffers[colorAttachment]); SafeDelete(mData.mColorAttachments[colorAttachment]);
mColorbuffers[colorAttachment] = attachmentObj; mData.mColorAttachments[colorAttachment] = attachmentObj;
mImpl->setColorAttachment(colorAttachment, attachmentObj); mImpl->setColorAttachment(colorAttachment, attachmentObj);
} }
else if (attachment == GL_BACK) else if (attachment == GL_BACK)
{ {
SafeDelete(mColorbuffers[0]); SafeDelete(mData.mColorAttachments[0]);
mColorbuffers[0] = attachmentObj; mData.mColorAttachments[0] = attachmentObj;
mImpl->setColorAttachment(0, attachmentObj); mImpl->setColorAttachment(0, attachmentObj);
} }
else if (attachment == GL_DEPTH_ATTACHMENT || attachment == GL_DEPTH) else if (attachment == GL_DEPTH_ATTACHMENT || attachment == GL_DEPTH)
{ {
SafeDelete(mDepthbuffer); SafeDelete(mData.mDepthAttachment);
mDepthbuffer = attachmentObj; mData.mDepthAttachment = attachmentObj;
mImpl->setDepthttachment(attachmentObj); mImpl->setDepthttachment(attachmentObj);
} }
else if (attachment == GL_STENCIL_ATTACHMENT || attachment == GL_STENCIL) else if (attachment == GL_STENCIL_ATTACHMENT || attachment == GL_STENCIL)
{ {
SafeDelete(mStencilbuffer); SafeDelete(mData.mStencilAttachment);
mStencilbuffer = attachmentObj; mData.mStencilAttachment = attachmentObj;
mImpl->setStencilAttachment(attachmentObj); mImpl->setStencilAttachment(attachmentObj);
} }
else if (attachment == GL_DEPTH_STENCIL_ATTACHMENT || attachment == GL_DEPTH_STENCIL) else if (attachment == GL_DEPTH_STENCIL_ATTACHMENT || attachment == GL_DEPTH_STENCIL)
{ {
SafeDelete(mDepthbuffer); SafeDelete(mData.mDepthAttachment);
SafeDelete(mStencilbuffer); SafeDelete(mData.mStencilAttachment);
// ensure this is a legitimate depth+stencil format // ensure this is a legitimate depth+stencil format
if (attachmentObj && attachmentObj->getDepthSize() > 0 && attachmentObj->getStencilSize() > 0) if (attachmentObj && attachmentObj->getDepthSize() > 0 && attachmentObj->getStencilSize() > 0)
{ {
mDepthbuffer = attachmentObj; mData.mDepthAttachment = attachmentObj;
mImpl->setDepthttachment(attachmentObj); mImpl->setDepthttachment(attachmentObj);
// Make a new attachment object to ensure we do not double-delete // Make a new attachment object to ensure we do not double-delete
// See angle issue 686 // See angle issue 686
if (attachmentObj->type() == GL_TEXTURE) if (attachmentObj->type() == GL_TEXTURE)
{ {
mStencilbuffer = new TextureAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getTexture(), mData.mStencilAttachment = new TextureAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getTexture(),
*attachmentObj->getTextureImageIndex()); *attachmentObj->getTextureImageIndex());
mImpl->setStencilAttachment(mStencilbuffer); mImpl->setStencilAttachment(mData.mStencilAttachment);
} }
else if (attachmentObj->type() == GL_RENDERBUFFER) else if (attachmentObj->type() == GL_RENDERBUFFER)
{ {
mStencilbuffer = new RenderbufferAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getRenderbuffer()); mData.mStencilAttachment = new RenderbufferAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getRenderbuffer());
mImpl->setStencilAttachment(mStencilbuffer); mImpl->setStencilAttachment(mData.mStencilAttachment);
} }
else else
{ {
...@@ -640,10 +630,13 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach ...@@ -640,10 +630,13 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach
} }
} }
DefaultFramebuffer::DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAttachmentImpl *colorAttachment, DefaultFramebuffer::DefaultFramebuffer(const Caps &caps, rx::Renderer *renderer, egl::Surface *surface)
rx::DefaultAttachmentImpl *depthAttachment, rx::DefaultAttachmentImpl *stencilAttachment) : Framebuffer(caps, renderer, 0)
: Framebuffer(impl, 0)
{ {
rx::DefaultAttachmentImpl *colorAttachment = renderer->createDefaultAttachment(GL_BACK, surface);
rx::DefaultAttachmentImpl *depthAttachment = renderer->createDefaultAttachment(GL_DEPTH, surface);
rx::DefaultAttachmentImpl *stencilAttachment = renderer->createDefaultAttachment(GL_STENCIL, surface);
ASSERT(colorAttachment); ASSERT(colorAttachment);
setAttachment(GL_BACK, new DefaultAttachment(GL_BACK, colorAttachment)); setAttachment(GL_BACK, new DefaultAttachment(GL_BACK, colorAttachment));
......
...@@ -20,23 +20,29 @@ ...@@ -20,23 +20,29 @@
namespace rx namespace rx
{ {
class RenderbufferImpl;
struct Workarounds;
class DefaultAttachmentImpl; class DefaultAttachmentImpl;
class FramebufferImpl; class FramebufferImpl;
class RenderbufferImpl;
class Renderer;
struct Workarounds;
}
namespace egl
{
class Surface;
} }
namespace gl namespace gl
{ {
class FramebufferAttachment; class FramebufferAttachment;
class Texture;
class Renderbuffer; class Renderbuffer;
struct ImageIndex; class State;
struct Caps; class Texture;
struct Extensions;
class TextureCapsMap; class TextureCapsMap;
struct Caps;
struct Data; struct Data;
class State; struct Extensions;
struct ImageIndex;
struct Rectangle; struct Rectangle;
typedef std::vector<FramebufferAttachment *> ColorbufferInfo; typedef std::vector<FramebufferAttachment *> ColorbufferInfo;
...@@ -44,7 +50,25 @@ typedef std::vector<FramebufferAttachment *> ColorbufferInfo; ...@@ -44,7 +50,25 @@ typedef std::vector<FramebufferAttachment *> ColorbufferInfo;
class Framebuffer class Framebuffer
{ {
public: public:
Framebuffer(rx::FramebufferImpl *impl, GLuint id);
class Data final
{
public:
Data(const Caps &caps);
~Data();
std::vector<FramebufferAttachment *> mColorAttachments;
FramebufferAttachment *mDepthAttachment;
FramebufferAttachment *mStencilAttachment;
std::vector<GLenum> mDrawBufferStates;
GLenum mReadBufferState;
private:
DISALLOW_COPY_AND_ASSIGN(Data);
};
Framebuffer(const Caps &caps, rx::Renderer *renderer, GLuint id);
virtual ~Framebuffer(); virtual ~Framebuffer();
const rx::FramebufferImpl *getImplementation() const { return mImpl; } const rx::FramebufferImpl *getImplementation() const { return mImpl; }
...@@ -108,17 +132,12 @@ class Framebuffer ...@@ -108,17 +132,12 @@ class Framebuffer
protected: protected:
void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj); void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj);
void detachResourceById(GLenum resourceType, GLuint resourceId);
Data mData;
rx::FramebufferImpl *mImpl; rx::FramebufferImpl *mImpl;
GLuint mId; GLuint mId;
FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
GLenum mReadBufferState;
FramebufferAttachment *mDepthbuffer;
FramebufferAttachment *mStencilbuffer;
private: private:
DISALLOW_COPY_AND_ASSIGN(Framebuffer); DISALLOW_COPY_AND_ASSIGN(Framebuffer);
}; };
...@@ -126,8 +145,7 @@ class Framebuffer ...@@ -126,8 +145,7 @@ class Framebuffer
class DefaultFramebuffer : public Framebuffer class DefaultFramebuffer : public Framebuffer
{ {
public: public:
DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAttachmentImpl *colorAttachment, DefaultFramebuffer(const gl::Caps &caps, rx::Renderer *renderer, egl::Surface *surface);
rx::DefaultAttachmentImpl *depthAttachment, rx::DefaultAttachmentImpl *stencilAttachment);
private: private:
DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer); DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "angle_gl.h" #include "angle_gl.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/Framebuffer.h"
namespace gl namespace gl
{ {
...@@ -27,8 +28,8 @@ namespace rx ...@@ -27,8 +28,8 @@ namespace rx
class FramebufferImpl class FramebufferImpl
{ {
public: public:
FramebufferImpl() {} FramebufferImpl(const gl::Framebuffer::Data &data) : mData(data) { }
virtual ~FramebufferImpl() {}; virtual ~FramebufferImpl() { }
virtual void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) = 0; virtual void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) = 0;
virtual void setDepthttachment(const gl::FramebufferAttachment *attachment) = 0; virtual void setDepthttachment(const gl::FramebufferAttachment *attachment) = 0;
...@@ -56,6 +57,11 @@ class FramebufferImpl ...@@ -56,6 +57,11 @@ class FramebufferImpl
virtual GLenum checkStatus() const = 0; virtual GLenum checkStatus() const = 0;
const gl::Framebuffer::Data &getData() const { return mData; }
protected:
const gl::Framebuffer::Data &mData;
private: private:
DISALLOW_COPY_AND_ASSIGN(FramebufferImpl); DISALLOW_COPY_AND_ASSIGN(FramebufferImpl);
}; };
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/Uniform.h" #include "libANGLE/Uniform.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/renderer/Workarounds.h" #include "libANGLE/renderer/Workarounds.h"
...@@ -31,7 +32,6 @@ class Surface; ...@@ -31,7 +32,6 @@ class Surface;
namespace gl namespace gl
{ {
class Buffer; class Buffer;
class Framebuffer;
struct Data; struct Data;
} }
...@@ -76,7 +76,7 @@ class Renderer ...@@ -76,7 +76,7 @@ class Renderer
// Framebuffer creation // Framebuffer creation
virtual DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) = 0; virtual DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) = 0;
virtual FramebufferImpl *createFramebuffer() = 0; virtual FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) = 0;
// Texture creation // Texture creation
virtual TextureImpl *createTexture(GLenum target) = 0; virtual TextureImpl *createTexture(GLenum target) = 0;
......
...@@ -61,8 +61,9 @@ RenderTargetD3D *DefaultAttachmentD3D::getRenderTarget() const ...@@ -61,8 +61,9 @@ RenderTargetD3D *DefaultAttachmentD3D::getRenderTarget() const
} }
FramebufferD3D::FramebufferD3D(RendererD3D *renderer) FramebufferD3D::FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer)
: mRenderer(renderer), : FramebufferImpl(data),
mRenderer(renderer),
mColorBuffers(renderer->getRendererCaps().maxColorAttachments), mColorBuffers(renderer->getRendererCaps().maxColorAttachments),
mDepthbuffer(nullptr), mDepthbuffer(nullptr),
mStencilbuffer(nullptr), mStencilbuffer(nullptr),
......
...@@ -51,7 +51,7 @@ class DefaultAttachmentD3D : public DefaultAttachmentImpl ...@@ -51,7 +51,7 @@ class DefaultAttachmentD3D : public DefaultAttachmentImpl
class FramebufferD3D : public FramebufferImpl class FramebufferD3D : public FramebufferImpl
{ {
public: public:
FramebufferD3D(RendererD3D *renderer); FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer);
virtual ~FramebufferD3D(); virtual ~FramebufferD3D();
void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override; void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override;
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
namespace rx namespace rx
{ {
Framebuffer11::Framebuffer11(Renderer11 *renderer) Framebuffer11::Framebuffer11(const gl::Framebuffer::Data &data, Renderer11 *renderer)
: FramebufferD3D(renderer), : FramebufferD3D(data, renderer),
mRenderer(renderer) mRenderer(renderer)
{ {
ASSERT(mRenderer != nullptr); ASSERT(mRenderer != nullptr);
......
...@@ -18,7 +18,7 @@ class Renderer11; ...@@ -18,7 +18,7 @@ class Renderer11;
class Framebuffer11 : public FramebufferD3D class Framebuffer11 : public FramebufferD3D
{ {
public: public:
Framebuffer11(Renderer11 *renderer); Framebuffer11(const gl::Framebuffer::Data &data, Renderer11 *renderer);
virtual ~Framebuffer11(); virtual ~Framebuffer11();
// Invalidate the cached swizzles of all bound texture attachments. // Invalidate the cached swizzles of all bound texture attachments.
......
...@@ -2626,9 +2626,9 @@ DefaultAttachmentImpl *Renderer11::createDefaultAttachment(GLenum type, egl::Sur ...@@ -2626,9 +2626,9 @@ DefaultAttachmentImpl *Renderer11::createDefaultAttachment(GLenum type, egl::Sur
} }
} }
FramebufferImpl *Renderer11::createFramebuffer() FramebufferImpl *Renderer11::createFramebuffer(const gl::Framebuffer::Data &data)
{ {
return new Framebuffer11(this); return new Framebuffer11(data, this);
} }
CompilerImpl *Renderer11::createCompiler(const gl::Data &data) CompilerImpl *Renderer11::createCompiler(const gl::Data &data)
......
...@@ -149,8 +149,8 @@ class Renderer11 : public RendererD3D ...@@ -149,8 +149,8 @@ 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
virtual DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override; DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override;
virtual FramebufferImpl *createFramebuffer() override; FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Shader creation // Shader creation
virtual CompilerImpl *createCompiler(const gl::Data &data); virtual CompilerImpl *createCompiler(const gl::Data &data);
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
namespace rx namespace rx
{ {
Framebuffer9::Framebuffer9(Renderer9 *renderer) Framebuffer9::Framebuffer9(const gl::Framebuffer::Data &data, Renderer9 *renderer)
: FramebufferD3D(renderer), : FramebufferD3D(data, renderer),
mRenderer(renderer) mRenderer(renderer)
{ {
ASSERT(mRenderer != nullptr); ASSERT(mRenderer != nullptr);
......
...@@ -18,7 +18,7 @@ class Renderer9; ...@@ -18,7 +18,7 @@ class Renderer9;
class Framebuffer9 : public FramebufferD3D class Framebuffer9 : public FramebufferD3D
{ {
public: public:
Framebuffer9(Renderer9 *renderer); Framebuffer9(const gl::Framebuffer::Data &data, Renderer9 *renderer);
virtual ~Framebuffer9(); virtual ~Framebuffer9();
private: private:
......
...@@ -2650,9 +2650,9 @@ DefaultAttachmentImpl *Renderer9::createDefaultAttachment(GLenum type, egl::Surf ...@@ -2650,9 +2650,9 @@ DefaultAttachmentImpl *Renderer9::createDefaultAttachment(GLenum type, egl::Surf
} }
} }
FramebufferImpl *Renderer9::createFramebuffer() FramebufferImpl *Renderer9::createFramebuffer(const gl::Framebuffer::Data &data)
{ {
return new Framebuffer9(this); return new Framebuffer9(data, this);
} }
CompilerImpl *Renderer9::createCompiler(const gl::Data &data) CompilerImpl *Renderer9::createCompiler(const gl::Data &data)
......
...@@ -158,8 +158,8 @@ class Renderer9 : public RendererD3D ...@@ -158,8 +158,8 @@ 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
virtual DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override; DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override;
virtual FramebufferImpl *createFramebuffer() override; FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Shader creation // Shader creation
virtual CompilerImpl *createCompiler(const gl::Data &data); virtual CompilerImpl *createCompiler(const gl::Data &data);
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
namespace rx namespace rx
{ {
FramebufferGL::FramebufferGL() FramebufferGL::FramebufferGL(const gl::Framebuffer::Data &data)
: FramebufferImpl() : FramebufferImpl(data)
{} {}
FramebufferGL::~FramebufferGL() FramebufferGL::~FramebufferGL()
......
...@@ -17,7 +17,7 @@ namespace rx ...@@ -17,7 +17,7 @@ namespace rx
class FramebufferGL : public FramebufferImpl class FramebufferGL : public FramebufferImpl
{ {
public: public:
FramebufferGL(); FramebufferGL(const gl::Framebuffer::Data &data);
~FramebufferGL() override; ~FramebufferGL() override;
void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override; void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override;
......
...@@ -100,9 +100,9 @@ DefaultAttachmentImpl *RendererGL::createDefaultAttachment(GLenum type, egl::Sur ...@@ -100,9 +100,9 @@ DefaultAttachmentImpl *RendererGL::createDefaultAttachment(GLenum type, egl::Sur
return new DefaultAttachmentGL(); return new DefaultAttachmentGL();
} }
FramebufferImpl *RendererGL::createFramebuffer() FramebufferImpl *RendererGL::createFramebuffer(const gl::Framebuffer::Data &data)
{ {
return new FramebufferGL(); return new FramebufferGL(data);
} }
TextureImpl *RendererGL::createTexture(GLenum target) TextureImpl *RendererGL::createTexture(GLenum target)
......
...@@ -38,7 +38,7 @@ class RendererGL : public Renderer ...@@ -38,7 +38,7 @@ class RendererGL : public Renderer
// Framebuffer creation // Framebuffer creation
DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override; DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override;
FramebufferImpl *createFramebuffer() override; FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Texture creation // Texture creation
TextureImpl *createTexture(GLenum target) override; TextureImpl *createTexture(GLenum target) override;
......
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