Commit b6bda4af by Jamie Madill

Make Framebuffer::Data members private.

This makes "Data" a proper class, and enforces access control when used in FramebufferImpl. This gives a cleaner refactor when we switch the internals of the class to use value types to store attachments instead of pointer types. BUG=angleproject:963 Change-Id: If825095458eaf9367f616f0bb54084025efb9882 Reviewed-on: https://chromium-review.googlesource.com/265937Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent ad0a486b
...@@ -56,7 +56,7 @@ Framebuffer::Data::~Data() ...@@ -56,7 +56,7 @@ Framebuffer::Data::~Data()
SafeDelete(mStencilAttachment); SafeDelete(mStencilAttachment);
} }
FramebufferAttachment *Framebuffer::Data::getReadAttachment() const const FramebufferAttachment *Framebuffer::Data::getReadAttachment() const
{ {
ASSERT(mReadBufferState == GL_BACK || (mReadBufferState >= GL_COLOR_ATTACHMENT0 && mReadBufferState <= GL_COLOR_ATTACHMENT15)); ASSERT(mReadBufferState == GL_BACK || (mReadBufferState >= GL_COLOR_ATTACHMENT0 && mReadBufferState <= GL_COLOR_ATTACHMENT15));
size_t readIndex = (mReadBufferState == GL_BACK ? 0 : static_cast<size_t>(mReadBufferState - GL_COLOR_ATTACHMENT0)); size_t readIndex = (mReadBufferState == GL_BACK ? 0 : static_cast<size_t>(mReadBufferState - GL_COLOR_ATTACHMENT0));
...@@ -64,7 +64,7 @@ FramebufferAttachment *Framebuffer::Data::getReadAttachment() const ...@@ -64,7 +64,7 @@ FramebufferAttachment *Framebuffer::Data::getReadAttachment() const
return mColorAttachments[readIndex]; return mColorAttachments[readIndex];
} }
FramebufferAttachment *Framebuffer::Data::getFirstColorAttachment() const const FramebufferAttachment *Framebuffer::Data::getFirstColorAttachment() const
{ {
for (FramebufferAttachment *colorAttachment : mColorAttachments) for (FramebufferAttachment *colorAttachment : mColorAttachments)
{ {
...@@ -77,11 +77,61 @@ FramebufferAttachment *Framebuffer::Data::getFirstColorAttachment() const ...@@ -77,11 +77,61 @@ FramebufferAttachment *Framebuffer::Data::getFirstColorAttachment() const
return nullptr; return nullptr;
} }
FramebufferAttachment *Framebuffer::Data::getDepthOrStencilAttachment() const const FramebufferAttachment *Framebuffer::Data::getDepthOrStencilAttachment() const
{ {
return (mDepthAttachment != nullptr ? mDepthAttachment : mStencilAttachment); return (mDepthAttachment != nullptr ? mDepthAttachment : mStencilAttachment);
} }
FramebufferAttachment *Framebuffer::Data::getColorAttachment(unsigned int colorAttachment)
{
ASSERT(colorAttachment < mColorAttachments.size());
return mColorAttachments[colorAttachment];
}
const FramebufferAttachment *Framebuffer::Data::getColorAttachment(unsigned int colorAttachment) const
{
return const_cast<Framebuffer::Data *>(this)->getColorAttachment(colorAttachment);
}
FramebufferAttachment *Framebuffer::Data::getDepthAttachment()
{
return mDepthAttachment;
}
const FramebufferAttachment *Framebuffer::Data::getDepthAttachment() const
{
return const_cast<Framebuffer::Data *>(this)->getDepthAttachment();
}
FramebufferAttachment *Framebuffer::Data::getStencilAttachment()
{
return mStencilAttachment;
}
const FramebufferAttachment *Framebuffer::Data::getStencilAttachment() const
{
return const_cast<Framebuffer::Data *>(this)->getStencilAttachment();
}
FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment()
{
// A valid depth-stencil attachment has the same resource bound to both the
// depth and stencil attachment points.
if (mDepthAttachment && mStencilAttachment &&
mDepthAttachment->type() == mStencilAttachment->type() &&
mDepthAttachment->id() == mStencilAttachment->id())
{
return mDepthAttachment;
}
return nullptr;
}
const FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment() const
{
return const_cast<Framebuffer::Data *>(this)->getDepthStencilAttachment();
}
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(nullptr), mImpl(nullptr),
...@@ -124,49 +174,68 @@ void Framebuffer::detachResourceById(GLenum resourceType, GLuint resourceId) ...@@ -124,49 +174,68 @@ void Framebuffer::detachResourceById(GLenum resourceType, GLuint resourceId)
DeleteMatchingAttachment(mData.mStencilAttachment, resourceType, resourceId); DeleteMatchingAttachment(mData.mStencilAttachment, resourceType, resourceId);
} }
FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment) const FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment)
{ {
ASSERT(colorAttachment < mData.mColorAttachments.size()); return mData.getColorAttachment(colorAttachment);
return mData.mColorAttachments[colorAttachment]; }
const FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment) const
{
return mData.getColorAttachment(colorAttachment);
}
FramebufferAttachment *Framebuffer::getDepthbuffer()
{
return mData.getDepthAttachment();
}
const FramebufferAttachment *Framebuffer::getDepthbuffer() const
{
return mData.getDepthAttachment();
}
FramebufferAttachment *Framebuffer::getStencilbuffer()
{
return mData.getStencilAttachment();
} }
FramebufferAttachment *Framebuffer::getDepthbuffer() const const FramebufferAttachment *Framebuffer::getStencilbuffer() const
{ {
return mData.mDepthAttachment; return mData.getStencilAttachment();
} }
FramebufferAttachment *Framebuffer::getStencilbuffer() const FramebufferAttachment *Framebuffer::getDepthStencilBuffer()
{ {
return mData.mStencilAttachment; return mData.getDepthStencilAttachment();
} }
FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const const FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const
{ {
return (hasValidDepthStencil() ? mData.mDepthAttachment : NULL); return mData.getDepthStencilAttachment();
} }
FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const const FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const
{ {
return mData.getDepthOrStencilAttachment(); return mData.getDepthOrStencilAttachment();
} }
FramebufferAttachment *Framebuffer::getReadColorbuffer() const const FramebufferAttachment *Framebuffer::getReadColorbuffer() const
{ {
return mData.getReadAttachment(); return mData.getReadAttachment();
} }
GLenum Framebuffer::getReadColorbufferType() const GLenum Framebuffer::getReadColorbufferType() const
{ {
FramebufferAttachment *readAttachment = mData.getReadAttachment(); const FramebufferAttachment *readAttachment = mData.getReadAttachment();
return (readAttachment ? readAttachment->type() : GL_NONE); return (readAttachment != nullptr ? readAttachment->type() : GL_NONE);
} }
FramebufferAttachment *Framebuffer::getFirstColorbuffer() const const FramebufferAttachment *Framebuffer::getFirstColorbuffer() const
{ {
return mData.getFirstColorAttachment(); return mData.getFirstColorAttachment();
} }
FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment)
{ {
if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15) if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15)
{ {
...@@ -190,11 +259,16 @@ FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const ...@@ -190,11 +259,16 @@ FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
return getDepthStencilBuffer(); return getDepthStencilBuffer();
default: default:
UNREACHABLE(); UNREACHABLE();
return NULL; return nullptr;
} }
} }
} }
const FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
{
return const_cast<Framebuffer*>(this)->getAttachment(attachment);
}
GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const
{ {
ASSERT(colorAttachment < mData.mDrawBufferStates.size()); ASSERT(colorAttachment < mData.mDrawBufferStates.size());
...@@ -547,11 +621,7 @@ int Framebuffer::getSamples(const gl::Data &data) const ...@@ -547,11 +621,7 @@ int Framebuffer::getSamples(const gl::Data &data) const
bool Framebuffer::hasValidDepthStencil() const bool Framebuffer::hasValidDepthStencil() const
{ {
// A valid depth-stencil attachment has the same resource bound to both the return mData.getDepthStencilAttachment() != nullptr;
// depth and stencil attachment points.
return (mData.mDepthAttachment && mData.mStencilAttachment &&
mData.mDepthAttachment->type() == mData.mStencilAttachment->type() &&
mData.mDepthAttachment->id() == mData.mStencilAttachment->id());
} }
void Framebuffer::setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex) void Framebuffer::setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex)
......
...@@ -43,7 +43,7 @@ struct Extensions; ...@@ -43,7 +43,7 @@ struct Extensions;
struct ImageIndex; struct ImageIndex;
struct Rectangle; struct Rectangle;
typedef std::vector<FramebufferAttachment *> AttachmentList; typedef std::vector<const FramebufferAttachment *> AttachmentList;
class Framebuffer class Framebuffer
{ {
...@@ -55,11 +55,25 @@ class Framebuffer ...@@ -55,11 +55,25 @@ class Framebuffer
explicit Data(const Caps &caps); explicit Data(const Caps &caps);
~Data(); ~Data();
FramebufferAttachment *getReadAttachment() const; const FramebufferAttachment *getReadAttachment() const;
FramebufferAttachment *getFirstColorAttachment() const; const FramebufferAttachment *getFirstColorAttachment() const;
FramebufferAttachment *getDepthOrStencilAttachment() const; const FramebufferAttachment *getDepthOrStencilAttachment() const;
const FramebufferAttachment *getColorAttachment(unsigned int colorAttachment) const;
AttachmentList mColorAttachments; const FramebufferAttachment *getDepthAttachment() const;
const FramebufferAttachment *getStencilAttachment() const;
const FramebufferAttachment *getDepthStencilAttachment() const;
const std::vector<GLenum> &getDrawBufferStates() const { return mDrawBufferStates; }
const std::vector<FramebufferAttachment *> &getColorAttachments() const { return mColorAttachments; }
private:
friend class Framebuffer;
FramebufferAttachment *getColorAttachment(unsigned int colorAttachment);
FramebufferAttachment *getDepthAttachment();
FramebufferAttachment *getStencilAttachment();
FramebufferAttachment *getDepthStencilAttachment();
std::vector<FramebufferAttachment *> mColorAttachments;
FramebufferAttachment *mDepthAttachment; FramebufferAttachment *mDepthAttachment;
FramebufferAttachment *mStencilAttachment; FramebufferAttachment *mStencilAttachment;
...@@ -82,16 +96,21 @@ class Framebuffer ...@@ -82,16 +96,21 @@ class Framebuffer
void detachTexture(GLuint texture); void detachTexture(GLuint texture);
void detachRenderbuffer(GLuint renderbuffer); void detachRenderbuffer(GLuint renderbuffer);
FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const; FramebufferAttachment *getColorbuffer(unsigned int colorAttachment);
FramebufferAttachment *getDepthbuffer() const; const FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
FramebufferAttachment *getStencilbuffer() const; FramebufferAttachment *getDepthbuffer();
FramebufferAttachment *getDepthStencilBuffer() const; const FramebufferAttachment *getDepthbuffer() const;
FramebufferAttachment *getDepthOrStencilbuffer() const; FramebufferAttachment *getStencilbuffer();
FramebufferAttachment *getReadColorbuffer() const; const FramebufferAttachment *getStencilbuffer() const;
FramebufferAttachment *getDepthStencilBuffer();
const FramebufferAttachment *getDepthStencilBuffer() const;
const FramebufferAttachment *getDepthOrStencilbuffer() const;
const FramebufferAttachment *getReadColorbuffer() const;
GLenum getReadColorbufferType() const; GLenum getReadColorbufferType() const;
FramebufferAttachment *getFirstColorbuffer() const; const FramebufferAttachment *getFirstColorbuffer() const;
FramebufferAttachment *getAttachment(GLenum attachment) const; FramebufferAttachment *getAttachment(GLenum attachment);
const FramebufferAttachment *getAttachment(GLenum attachment) const;
GLenum getDrawBufferState(unsigned int colorAttachment) const; GLenum getDrawBufferState(unsigned int colorAttachment) const;
void setDrawBuffers(size_t count, const GLenum *buffers); void setDrawBuffers(size_t count, const GLenum *buffers);
......
...@@ -1255,7 +1255,7 @@ void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params) ...@@ -1255,7 +1255,7 @@ void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params)
case GL_ALPHA_BITS: case GL_ALPHA_BITS:
{ {
gl::Framebuffer *framebuffer = getDrawFramebuffer(); gl::Framebuffer *framebuffer = getDrawFramebuffer();
gl::FramebufferAttachment *colorbuffer = framebuffer->getFirstColorbuffer(); const gl::FramebufferAttachment *colorbuffer = framebuffer->getFirstColorbuffer();
if (colorbuffer) if (colorbuffer)
{ {
......
...@@ -87,7 +87,7 @@ ClearParameters GetClearParameters(const gl::State &state, GLbitfield mask) ...@@ -87,7 +87,7 @@ ClearParameters GetClearParameters(const gl::State &state, GLbitfield mask)
FramebufferD3D::FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer) FramebufferD3D::FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer)
: FramebufferImpl(data), : FramebufferImpl(data),
mRenderer(renderer), mRenderer(renderer),
mColorAttachmentsForRender(mData.mColorAttachments.size(), nullptr), mColorAttachmentsForRender(mData.getColorAttachments().size(), nullptr),
mInvalidateColorAttachmentCache(true) mInvalidateColorAttachmentCache(true)
{ {
ASSERT(mRenderer != nullptr); ASSERT(mRenderer != nullptr);
...@@ -291,7 +291,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour ...@@ -291,7 +291,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour
bool blitStencil = false; bool blitStencil = false;
if ((mask & GL_STENCIL_BUFFER_BIT) && if ((mask & GL_STENCIL_BUFFER_BIT) &&
sourceFramebuffer->getStencilbuffer() != nullptr && sourceFramebuffer->getStencilbuffer() != nullptr &&
mData.mStencilAttachment != nullptr) mData.getStencilAttachment() != nullptr)
{ {
blitStencil = true; blitStencil = true;
} }
...@@ -299,7 +299,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour ...@@ -299,7 +299,7 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour
bool blitDepth = false; bool blitDepth = false;
if ((mask & GL_DEPTH_BUFFER_BIT) && if ((mask & GL_DEPTH_BUFFER_BIT) &&
sourceFramebuffer->getDepthbuffer() != nullptr && sourceFramebuffer->getDepthbuffer() != nullptr &&
mData.mDepthAttachment != nullptr) mData.getDepthAttachment() != nullptr)
{ {
blitDepth = true; blitDepth = true;
} }
...@@ -321,14 +321,15 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour ...@@ -321,14 +321,15 @@ gl::Error FramebufferD3D::blit(const gl::State &state, const gl::Rectangle &sour
GLenum FramebufferD3D::checkStatus() const GLenum FramebufferD3D::checkStatus() const
{ {
// D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness // D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness
for (size_t colorAttachment = 0; colorAttachment < mData.mColorAttachments.size(); colorAttachment++) const auto &colorAttachments = mData.getColorAttachments();
for (size_t colorAttachment = 0; colorAttachment < colorAttachments.size(); colorAttachment++)
{ {
const gl::FramebufferAttachment *attachment = mData.mColorAttachments[colorAttachment]; const gl::FramebufferAttachment *attachment = colorAttachments[colorAttachment];
if (attachment != nullptr) if (attachment != nullptr)
{ {
for (size_t prevColorAttachment = 0; prevColorAttachment < colorAttachment; prevColorAttachment++) for (size_t prevColorAttachment = 0; prevColorAttachment < colorAttachment; prevColorAttachment++)
{ {
const gl::FramebufferAttachment *prevAttachment = mData.mColorAttachments[prevColorAttachment]; const gl::FramebufferAttachment *prevAttachment = colorAttachments[prevColorAttachment];
if (prevAttachment != nullptr && if (prevAttachment != nullptr &&
(attachment->id() == prevAttachment->id() && (attachment->id() == prevAttachment->id() &&
attachment->type() == prevAttachment->type())) attachment->type() == prevAttachment->type()))
...@@ -344,11 +345,6 @@ GLenum FramebufferD3D::checkStatus() const ...@@ -344,11 +345,6 @@ GLenum FramebufferD3D::checkStatus() const
const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Workarounds &workarounds) const const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Workarounds &workarounds) const
{ {
if (!workarounds.mrtPerfWorkaround)
{
return mData.mColorAttachments;
}
if (!mInvalidateColorAttachmentCache) if (!mInvalidateColorAttachmentCache)
{ {
return mColorAttachmentsForRender; return mColorAttachmentsForRender;
...@@ -357,16 +353,22 @@ const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Wor ...@@ -357,16 +353,22 @@ const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const Wor
// Does not actually free memory // Does not actually free memory
mColorAttachmentsForRender.clear(); mColorAttachmentsForRender.clear();
for (size_t attachmentIndex = 0; attachmentIndex < mData.mColorAttachments.size(); ++attachmentIndex) const auto &colorAttachments = mData.getColorAttachments();
const auto &drawBufferStates = mData.getDrawBufferStates();
for (size_t attachmentIndex = 0; attachmentIndex < colorAttachments.size(); ++attachmentIndex)
{ {
GLenum drawBufferState = mData.mDrawBufferStates[attachmentIndex]; GLenum drawBufferState = drawBufferStates[attachmentIndex];
gl::FramebufferAttachment *colorAttachment = mData.mColorAttachments[attachmentIndex]; const gl::FramebufferAttachment *colorAttachment = colorAttachments[attachmentIndex];
if (colorAttachment != nullptr && drawBufferState != GL_NONE) if (colorAttachment != nullptr && drawBufferState != GL_NONE)
{ {
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex)); ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex));
mColorAttachmentsForRender.push_back(colorAttachment); mColorAttachmentsForRender.push_back(colorAttachment);
} }
else if (!workarounds.mrtPerfWorkaround)
{
mColorAttachmentsForRender.push_back(nullptr);
}
} }
mInvalidateColorAttachmentCache = false; mInvalidateColorAttachmentCache = false;
......
...@@ -30,7 +30,7 @@ ImageD3D::ImageD3D() ...@@ -30,7 +30,7 @@ ImageD3D::ImageD3D()
gl::Error ImageD3D::copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, const gl::Framebuffer *source) gl::Error ImageD3D::copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, const gl::Framebuffer *source)
{ {
gl::FramebufferAttachment *colorbuffer = source->getReadColorbuffer(); const gl::FramebufferAttachment *colorbuffer = source->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
RenderTargetD3D *renderTarget = NULL; RenderTargetD3D *renderTarget = NULL;
......
...@@ -516,7 +516,7 @@ size_t RendererD3D::getBoundFramebufferTextureSerials(const gl::Data &data, ...@@ -516,7 +516,7 @@ size_t RendererD3D::getBoundFramebufferTextureSerials(const gl::Data &data,
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 (unsigned int i = 0; i < data.caps->maxColorAttachments; i++)
{ {
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)
{ {
gl::Texture *texture = attachment->getTexture(); gl::Texture *texture = attachment->getTexture();
...@@ -524,7 +524,7 @@ size_t RendererD3D::getBoundFramebufferTextureSerials(const gl::Data &data, ...@@ -524,7 +524,7 @@ size_t RendererD3D::getBoundFramebufferTextureSerials(const gl::Data &data,
} }
} }
gl::FramebufferAttachment *depthStencilAttachment = drawFramebuffer->getDepthOrStencilbuffer(); const gl::FramebufferAttachment *depthStencilAttachment = drawFramebuffer->getDepthOrStencilbuffer();
if (depthStencilAttachment && depthStencilAttachment->type() == GL_TEXTURE) if (depthStencilAttachment && depthStencilAttachment->type() == GL_TEXTURE)
{ {
gl::Texture *depthStencilTexture = depthStencilAttachment->getTexture(); gl::Texture *depthStencilTexture = depthStencilAttachment->getTexture();
......
...@@ -179,10 +179,10 @@ Clear11::~Clear11() ...@@ -179,10 +179,10 @@ Clear11::~Clear11()
gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl::Framebuffer::Data &fboData) gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl::Framebuffer::Data &fboData)
{ {
const auto &colorAttachments = fboData.mColorAttachments; const auto &colorAttachments = fboData.getColorAttachments();
const auto &drawBufferStates = fboData.mDrawBufferStates; const auto &drawBufferStates = fboData.getDrawBufferStates();
const auto *depthAttachment = fboData.mDepthAttachment; const auto *depthAttachment = fboData.getDepthAttachment();
const auto *stencilAttachment = fboData.mStencilAttachment; const auto *stencilAttachment = fboData.getStencilAttachment();
ASSERT(colorAttachments.size() == drawBufferStates.size()); ASSERT(colorAttachments.size() == drawBufferStates.size());
...@@ -207,11 +207,11 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl ...@@ -207,11 +207,11 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, const gl
gl::Extents framebufferSize; gl::Extents framebufferSize;
auto iter = std::find_if(colorAttachments.begin(), colorAttachments.end(), [](const gl::FramebufferAttachment *attachment) { return attachment != nullptr; }); const gl::FramebufferAttachment *colorAttachment = fboData.getFirstColorAttachment();
if (iter != colorAttachments.end()) if (colorAttachment != nullptr)
{ {
framebufferSize.width = (*iter)->getWidth(); framebufferSize.width = colorAttachment->getWidth();
framebufferSize.height = (*iter)->getHeight(); framebufferSize.height = colorAttachment->getHeight();
framebufferSize.depth = 1; framebufferSize.depth = 1;
} }
else if (depthAttachment != nullptr) else if (depthAttachment != nullptr)
......
...@@ -64,7 +64,7 @@ static gl::Error InvalidateAttachmentSwizzles(const gl::FramebufferAttachment *a ...@@ -64,7 +64,7 @@ static gl::Error InvalidateAttachmentSwizzles(const gl::FramebufferAttachment *a
gl::Error Framebuffer11::invalidateSwizzles() const gl::Error Framebuffer11::invalidateSwizzles() const
{ {
for (gl::FramebufferAttachment *colorAttachment : mData.mColorAttachments) for (const auto *colorAttachment : mData.getColorAttachments())
{ {
gl::Error error = InvalidateAttachmentSwizzles(colorAttachment); gl::Error error = InvalidateAttachmentSwizzles(colorAttachment);
if (error.isError()) if (error.isError())
...@@ -73,13 +73,13 @@ gl::Error Framebuffer11::invalidateSwizzles() const ...@@ -73,13 +73,13 @@ gl::Error Framebuffer11::invalidateSwizzles() const
} }
} }
gl::Error error = InvalidateAttachmentSwizzles(mData.mDepthAttachment); gl::Error error = InvalidateAttachmentSwizzles(mData.getDepthAttachment());
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
error = InvalidateAttachmentSwizzles(mData.mStencilAttachment); error = InvalidateAttachmentSwizzles(mData.getStencilAttachment());
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -193,12 +193,14 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang ...@@ -193,12 +193,14 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang
} }
ASSERT(readRenderTarget); ASSERT(readRenderTarget);
for (size_t colorAttachment = 0; colorAttachment < mData.mColorAttachments.size(); colorAttachment++) const auto &colorAttachments = mData.getColorAttachments();
const auto &drawBufferStates = mData.getDrawBufferStates();
for (size_t colorAttachment = 0; colorAttachment < colorAttachments.size(); colorAttachment++)
{ {
if (mData.mColorAttachments[colorAttachment] != nullptr && if (colorAttachments[colorAttachment] != nullptr &&
mData.mDrawBufferStates[colorAttachment] != GL_NONE) drawBufferStates[colorAttachment] != GL_NONE)
{ {
const gl::FramebufferAttachment *drawBuffer = mData.mColorAttachments[colorAttachment]; const gl::FramebufferAttachment *drawBuffer = colorAttachments[colorAttachment];
RenderTargetD3D *drawRenderTarget = NULL; RenderTargetD3D *drawRenderTarget = NULL;
error = GetAttachmentRenderTarget(drawBuffer, &drawRenderTarget); error = GetAttachmentRenderTarget(drawBuffer, &drawRenderTarget);
...@@ -220,7 +222,7 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang ...@@ -220,7 +222,7 @@ gl::Error Framebuffer11::blit(const gl::Rectangle &sourceArea, const gl::Rectang
if (blitDepth || blitStencil) if (blitDepth || blitStencil)
{ {
gl::FramebufferAttachment *readBuffer = sourceFramebuffer->getDepthOrStencilbuffer(); const gl::FramebufferAttachment *readBuffer = sourceFramebuffer->getDepthOrStencilbuffer();
ASSERT(readBuffer); ASSERT(readBuffer);
RenderTargetD3D *readRenderTarget = NULL; RenderTargetD3D *readRenderTarget = NULL;
......
...@@ -1277,7 +1277,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer) ...@@ -1277,7 +1277,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment) for (size_t colorAttachment = 0; colorAttachment < colorbuffers.size(); ++colorAttachment)
{ {
gl::FramebufferAttachment *colorbuffer = colorbuffers[colorAttachment]; const gl::FramebufferAttachment *colorbuffer = colorbuffers[colorAttachment];
if (colorbuffer) if (colorbuffer)
{ {
...@@ -1326,7 +1326,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer) ...@@ -1326,7 +1326,7 @@ gl::Error Renderer11::applyRenderTarget(const gl::Framebuffer *framebuffer)
// Get the depth stencil buffers // Get the depth stencil buffers
ID3D11DepthStencilView* framebufferDSV = NULL; ID3D11DepthStencilView* framebufferDSV = NULL;
gl::FramebufferAttachment *depthStencil = framebuffer->getDepthOrStencilbuffer(); const gl::FramebufferAttachment *depthStencil = framebuffer->getDepthOrStencilbuffer();
if (depthStencil) if (depthStencil)
{ {
RenderTarget11 *depthStencilRenderTarget = NULL; RenderTarget11 *depthStencilRenderTarget = NULL;
...@@ -2422,7 +2422,7 @@ std::string Renderer11::getShaderModelSuffix() const ...@@ -2422,7 +2422,7 @@ std::string Renderer11::getShaderModelSuffix() const
gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); const gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
RenderTarget11 *sourceRenderTarget = NULL; RenderTarget11 *sourceRenderTarget = NULL;
...@@ -2473,7 +2473,7 @@ gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer, const gl:: ...@@ -2473,7 +2473,7 @@ gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer, const gl::
gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level)
{ {
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); const gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
RenderTarget11 *sourceRenderTarget = NULL; RenderTarget11 *sourceRenderTarget = NULL;
...@@ -2524,7 +2524,7 @@ gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl ...@@ -2524,7 +2524,7 @@ gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl
gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); const gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
RenderTarget11 *sourceRenderTarget = NULL; RenderTarget11 *sourceRenderTarget = NULL;
...@@ -2575,7 +2575,7 @@ gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl:: ...@@ -2575,7 +2575,7 @@ gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl::
gl::Error Renderer11::copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer11::copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); const gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
RenderTarget11 *sourceRenderTarget = NULL; RenderTarget11 *sourceRenderTarget = NULL;
......
...@@ -236,7 +236,7 @@ gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRe ...@@ -236,7 +236,7 @@ gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRe
return error; return error;
} }
gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0); const gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0);
ASSERT(colorbuffer); ASSERT(colorbuffer);
RenderTarget9 *renderTarget9 = NULL; RenderTarget9 *renderTarget9 = NULL;
...@@ -275,7 +275,7 @@ gl::Error Blit9::copyCube(const gl::Framebuffer *framebuffer, const RECT &source ...@@ -275,7 +275,7 @@ gl::Error Blit9::copyCube(const gl::Framebuffer *framebuffer, const RECT &source
return error; return error;
} }
gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0); const gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(0);
ASSERT(colorbuffer); ASSERT(colorbuffer);
RenderTarget9 *renderTarget9 = NULL; RenderTarget9 *renderTarget9 = NULL;
......
...@@ -34,7 +34,7 @@ Framebuffer9::~Framebuffer9() ...@@ -34,7 +34,7 @@ Framebuffer9::~Framebuffer9()
gl::Error Framebuffer9::clear(const gl::State &state, const ClearParameters &clearParams) gl::Error Framebuffer9::clear(const gl::State &state, const ClearParameters &clearParams)
{ {
const gl::FramebufferAttachment *colorAttachment = mData.mColorAttachments[0]; const gl::FramebufferAttachment *colorAttachment = mData.getColorAttachment(0);
const gl::FramebufferAttachment *depthStencilAttachment = mData.getDepthOrStencilAttachment(); const gl::FramebufferAttachment *depthStencilAttachment = mData.getDepthOrStencilAttachment();
gl::Error error = mRenderer->applyRenderTarget(colorAttachment, depthStencilAttachment); gl::Error error = mRenderer->applyRenderTarget(colorAttachment, depthStencilAttachment);
...@@ -56,7 +56,7 @@ gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLe ...@@ -56,7 +56,7 @@ gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLe
{ {
ASSERT(pack.pixelBuffer.get() == NULL); ASSERT(pack.pixelBuffer.get() == NULL);
const gl::FramebufferAttachment *colorbuffer = mData.mColorAttachments[0]; const gl::FramebufferAttachment *colorbuffer = mData.getColorAttachment(0);
ASSERT(colorbuffer); ASSERT(colorbuffer);
RenderTarget9 *renderTarget = NULL; RenderTarget9 *renderTarget = NULL;
...@@ -254,7 +254,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl ...@@ -254,7 +254,7 @@ gl::Error Framebuffer9::blit(const gl::Rectangle &sourceArea, const gl::Rectangl
} }
ASSERT(readRenderTarget); ASSERT(readRenderTarget);
const gl::FramebufferAttachment *drawBuffer = mData.mColorAttachments[0]; const gl::FramebufferAttachment *drawBuffer = mData.getColorAttachment(0);
ASSERT(drawBuffer); ASSERT(drawBuffer);
RenderTarget9 *drawRenderTarget = NULL; RenderTarget9 *drawRenderTarget = NULL;
......
...@@ -963,7 +963,7 @@ gl::Error Renderer9::setBlendState(const gl::Framebuffer *framebuffer, const gl: ...@@ -963,7 +963,7 @@ gl::Error Renderer9::setBlendState(const gl::Framebuffer *framebuffer, const gl:
FIXME("Sample alpha to coverage is unimplemented."); FIXME("Sample alpha to coverage is unimplemented.");
} }
gl::FramebufferAttachment *attachment = framebuffer->getFirstColorbuffer(); const gl::FramebufferAttachment *attachment = framebuffer->getFirstColorbuffer();
GLenum internalFormat = attachment ? attachment->getInternalFormat() : GL_NONE; GLenum internalFormat = attachment ? attachment->getInternalFormat() : GL_NONE;
// Set the color mask // Set the color mask
......
...@@ -415,7 +415,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum targ ...@@ -415,7 +415,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum targ
return true; return true;
} }
static bool IsPartialBlit(gl::Context *context, gl::FramebufferAttachment *readBuffer, gl::FramebufferAttachment *writeBuffer, static bool IsPartialBlit(gl::Context *context, const gl::FramebufferAttachment *readBuffer, const gl::FramebufferAttachment *writeBuffer,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1) GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1)
{ {
...@@ -529,8 +529,8 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -529,8 +529,8 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
if (mask & GL_COLOR_BUFFER_BIT) if (mask & GL_COLOR_BUFFER_BIT)
{ {
gl::FramebufferAttachment *readColorBuffer = readFramebuffer->getReadColorbuffer(); const gl::FramebufferAttachment *readColorBuffer = readFramebuffer->getReadColorbuffer();
gl::FramebufferAttachment *drawColorBuffer = drawFramebuffer->getFirstColorbuffer(); const gl::FramebufferAttachment *drawColorBuffer = drawFramebuffer->getFirstColorbuffer();
if (readColorBuffer && drawColorBuffer) if (readColorBuffer && drawColorBuffer)
{ {
...@@ -583,7 +583,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -583,7 +583,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
if (fromAngleExtension) if (fromAngleExtension)
{ {
FramebufferAttachment *readColorAttachment = readFramebuffer->getReadColorbuffer(); const FramebufferAttachment *readColorAttachment = readFramebuffer->getReadColorbuffer();
if (!readColorAttachment || if (!readColorAttachment ||
(!(readColorAttachment->type() == GL_TEXTURE && readColorAttachment->getTextureImageIndex().type == GL_TEXTURE_2D) && (!(readColorAttachment->type() == GL_TEXTURE && readColorAttachment->getTextureImageIndex().type == GL_TEXTURE_2D) &&
readColorAttachment->type() != GL_RENDERBUFFER && readColorAttachment->type() != GL_RENDERBUFFER &&
...@@ -1174,7 +1174,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, ...@@ -1174,7 +1174,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType,
return false; return false;
} }
FramebufferAttachment *attachment = framebuffer->getReadColorbuffer(); const FramebufferAttachment *attachment = framebuffer->getReadColorbuffer();
if (!attachment) if (!attachment)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
......
...@@ -822,7 +822,7 @@ bool ValidateES3CopyTexImageParameters(Context *context, GLenum target, GLint le ...@@ -822,7 +822,7 @@ bool ValidateES3CopyTexImageParameters(Context *context, GLenum target, GLint le
return false; return false;
} }
gl::FramebufferAttachment *source = framebuffer->getReadColorbuffer(); const gl::FramebufferAttachment *source = framebuffer->getReadColorbuffer();
GLenum colorbufferInternalFormat = source->getInternalFormat(); GLenum colorbufferInternalFormat = source->getInternalFormat();
if (isSubImage) if (isSubImage)
......
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