Commit 748f74ef by Geoff Lang

Rename Framebuffer::completeness to checkStatus and add an Impl method.

BUG=angle:841 Change-Id: I04b4ffd086424569a15aa21447dd552e0a898928 Reviewed-on: https://chromium-review.googlesource.com/232394Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 9dd95808
...@@ -1375,7 +1375,7 @@ const Extensions &Context::getExtensions() const ...@@ -1375,7 +1375,7 @@ const Extensions &Context::getExtensions() const
void Context::getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type) void Context::getCurrentReadFormatType(GLenum *internalFormat, GLenum *format, GLenum *type)
{ {
Framebuffer *framebuffer = mState.getReadFramebuffer(); Framebuffer *framebuffer = mState.getReadFramebuffer();
ASSERT(framebuffer && framebuffer->completeness(getData()) == GL_FRAMEBUFFER_COMPLETE); ASSERT(framebuffer && framebuffer->checkStatus(getData()) == GL_FRAMEBUFFER_COMPLETE);
FramebufferAttachment *attachment = framebuffer->getReadColorbuffer(); FramebufferAttachment *attachment = framebuffer->getReadColorbuffer();
ASSERT(attachment); ASSERT(attachment);
......
...@@ -245,7 +245,7 @@ bool Framebuffer::usingExtendedDrawBuffers() const ...@@ -245,7 +245,7 @@ bool Framebuffer::usingExtendedDrawBuffers() const
return false; return false;
} }
GLenum Framebuffer::completeness(const gl::Data &data) const GLenum Framebuffer::checkStatus(const gl::Data &data) const
{ {
// The default framebuffer *must* always be complete, though it may not be // The default framebuffer *must* always be complete, though it may not be
// subject to the same rules as application FBOs. ie, it could have 0x0 size. // subject to the same rules as application FBOs. ie, it could have 0x0 size.
...@@ -318,19 +318,6 @@ GLenum Framebuffer::completeness(const gl::Data &data) const ...@@ -318,19 +318,6 @@ GLenum Framebuffer::completeness(const gl::Data &data) const
return GL_FRAMEBUFFER_UNSUPPORTED; return GL_FRAMEBUFFER_UNSUPPORTED;
} }
} }
// D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness
for (unsigned int previousColorAttachment = 0; previousColorAttachment < colorAttachment; previousColorAttachment++)
{
const FramebufferAttachment *previousAttachment = mColorbuffers[previousColorAttachment];
if (previousAttachment &&
(colorbuffer->id() == previousAttachment->id() &&
colorbuffer->type() == previousAttachment->type()))
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
}
} }
else else
{ {
...@@ -463,7 +450,7 @@ GLenum Framebuffer::completeness(const gl::Data &data) const ...@@ -463,7 +450,7 @@ GLenum Framebuffer::completeness(const gl::Data &data) const
return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
} }
return GL_FRAMEBUFFER_COMPLETE; return mImpl->checkStatus();
} }
Error Framebuffer::invalidate(size_t count, const GLenum *attachments) Error Framebuffer::invalidate(size_t count, const GLenum *attachments)
...@@ -478,7 +465,7 @@ Error Framebuffer::invalidateSub(size_t count, const GLenum *attachments, const ...@@ -478,7 +465,7 @@ Error Framebuffer::invalidateSub(size_t count, const GLenum *attachments, const
int Framebuffer::getSamples(const gl::Data &data) const int Framebuffer::getSamples(const gl::Data &data) const
{ {
if (completeness(data) == GL_FRAMEBUFFER_COMPLETE) if (checkStatus(data) == GL_FRAMEBUFFER_COMPLETE)
{ {
// 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
......
...@@ -81,7 +81,7 @@ class Framebuffer ...@@ -81,7 +81,7 @@ class Framebuffer
int getSamples(const gl::Data &data) const; int getSamples(const gl::Data &data) const;
bool usingExtendedDrawBuffers() const; bool usingExtendedDrawBuffers() const;
GLenum completeness(const gl::Data &data) const; GLenum checkStatus(const gl::Data &data) const;
bool hasValidDepthStencil() const; bool hasValidDepthStencil() const;
Error invalidate(size_t count, const GLenum *attachments); Error invalidate(size_t count, const GLenum *attachments);
......
...@@ -1251,7 +1251,7 @@ void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params) ...@@ -1251,7 +1251,7 @@ void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params)
case GL_SAMPLES: case GL_SAMPLES:
{ {
gl::Framebuffer *framebuffer = mDrawFramebuffer; gl::Framebuffer *framebuffer = mDrawFramebuffer;
if (framebuffer->completeness(data) == GL_FRAMEBUFFER_COMPLETE) if (framebuffer->checkStatus(data) == GL_FRAMEBUFFER_COMPLETE)
{ {
switch (pname) switch (pname)
{ {
......
...@@ -49,6 +49,8 @@ class FramebufferImpl ...@@ -49,6 +49,8 @@ class FramebufferImpl
virtual gl::Error invalidate(size_t count, const GLenum *attachments) = 0; virtual gl::Error invalidate(size_t count, const GLenum *attachments) = 0;
virtual gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) = 0; virtual gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) = 0;
virtual GLenum checkStatus() const = 0;
}; };
} }
......
...@@ -65,9 +65,12 @@ RenderTarget *DefaultAttachmentD3D::getRenderTarget() const ...@@ -65,9 +65,12 @@ RenderTarget *DefaultAttachmentD3D::getRenderTarget() const
FramebufferD3D::FramebufferD3D(RendererD3D *renderer) FramebufferD3D::FramebufferD3D(RendererD3D *renderer)
: mRenderer(renderer) : mRenderer(renderer),
mColorBuffers(renderer->getRendererCaps().maxColorAttachments)
{ {
ASSERT(mRenderer != nullptr); ASSERT(mRenderer != nullptr);
std::fill(mColorBuffers.begin(), mColorBuffers.end(), nullptr);
} }
FramebufferD3D::~FramebufferD3D() FramebufferD3D::~FramebufferD3D()
...@@ -76,6 +79,8 @@ FramebufferD3D::~FramebufferD3D() ...@@ -76,6 +79,8 @@ FramebufferD3D::~FramebufferD3D()
void FramebufferD3D::setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) void FramebufferD3D::setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment)
{ {
ASSERT(index < mColorBuffers.size());
mColorBuffers[index] = attachment;
} }
void FramebufferD3D::setDepthttachment(const gl::FramebufferAttachment *attachment) void FramebufferD3D::setDepthttachment(const gl::FramebufferAttachment *attachment)
...@@ -110,6 +115,30 @@ gl::Error FramebufferD3D::invalidateSub(size_t, const GLenum *, const gl::Rectan ...@@ -110,6 +115,30 @@ gl::Error FramebufferD3D::invalidateSub(size_t, const GLenum *, const gl::Rectan
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
GLenum FramebufferD3D::checkStatus() const
{
// D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness
for (size_t colorAttachment = 0; colorAttachment < mColorBuffers.size(); colorAttachment++)
{
const gl::FramebufferAttachment *attachment = mColorBuffers[colorAttachment];
if (attachment != nullptr)
{
for (size_t prevColorAttachment = 0; prevColorAttachment < colorAttachment; prevColorAttachment++)
{
const gl::FramebufferAttachment *prevAttachment = mColorBuffers[prevColorAttachment];
if (prevAttachment != nullptr &&
(attachment->id() == prevAttachment->id() &&
attachment->type() == prevAttachment->type()))
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
}
}
}
return GL_FRAMEBUFFER_COMPLETE;
}
gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTarget **outRT) gl::Error GetAttachmentRenderTarget(const gl::FramebufferAttachment *attachment, RenderTarget **outRT)
{ {
if (attachment->type() == GL_TEXTURE) if (attachment->type() == GL_TEXTURE)
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
#include <vector>
namespace gl namespace gl
{ {
class FramebufferAttachment; class FramebufferAttachment;
...@@ -58,6 +60,11 @@ class FramebufferD3D : public FramebufferImpl ...@@ -58,6 +60,11 @@ class FramebufferD3D : public FramebufferImpl
gl::Error invalidate(size_t count, const GLenum *attachments) override; gl::Error invalidate(size_t count, const GLenum *attachments) override;
gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override; gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override;
GLenum checkStatus() const override;
protected:
std::vector<const gl::FramebufferAttachment*> mColorBuffers;
private: private:
RendererD3D *const mRenderer; RendererD3D *const mRenderer;
}; };
......
...@@ -269,7 +269,7 @@ gl::Error RendererD3D::generateSwizzles(const gl::Data &data) ...@@ -269,7 +269,7 @@ gl::Error RendererD3D::generateSwizzles(const gl::Data &data)
gl::Error RendererD3D::applyRenderTarget(const gl::Data &data, GLenum drawMode, bool ignoreViewport) gl::Error RendererD3D::applyRenderTarget(const gl::Data &data, GLenum drawMode, bool ignoreViewport)
{ {
const gl::Framebuffer *framebufferObject = data.state->getDrawFramebuffer(); const gl::Framebuffer *framebufferObject = data.state->getDrawFramebuffer();
ASSERT(framebufferObject && framebufferObject->completeness(data) == GL_FRAMEBUFFER_COMPLETE); ASSERT(framebufferObject && framebufferObject->checkStatus(data) == GL_FRAMEBUFFER_COMPLETE);
gl::Error error = applyRenderTarget(framebufferObject); gl::Error error = applyRenderTarget(framebufferObject);
if (error.isError()) if (error.isError())
......
...@@ -497,13 +497,13 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -497,13 +497,13 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
return false; return false;
} }
if (!readFramebuffer->completeness(context->getData())) if (!readFramebuffer->checkStatus(context->getData()))
{ {
context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false; return false;
} }
if (!drawFramebuffer->completeness(context->getData())) if (!drawFramebuffer->checkStatus(context->getData()))
{ {
context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false; return false;
...@@ -926,7 +926,7 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize ...@@ -926,7 +926,7 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize
gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
ASSERT(framebuffer); ASSERT(framebuffer);
if (framebuffer->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE) if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
{ {
context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false; return false;
...@@ -1187,7 +1187,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, ...@@ -1187,7 +1187,7 @@ bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType,
{ {
Framebuffer *framebuffer = context->getState().getReadFramebuffer(); Framebuffer *framebuffer = context->getState().getReadFramebuffer();
ASSERT(framebuffer); ASSERT(framebuffer);
if (framebuffer->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE) if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
...@@ -1251,7 +1251,7 @@ bool ValidateCopyTexImageParametersBase(gl::Context* context, GLenum target, GLi ...@@ -1251,7 +1251,7 @@ bool ValidateCopyTexImageParametersBase(gl::Context* context, GLenum target, GLi
} }
gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
if (framebuffer->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE) if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
{ {
context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false; return false;
...@@ -1456,7 +1456,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz ...@@ -1456,7 +1456,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz
} }
const gl::Framebuffer *fbo = state.getDrawFramebuffer(); const gl::Framebuffer *fbo = state.getDrawFramebuffer();
if (!fbo || fbo->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE) if (!fbo || fbo->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
{ {
context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false; return false;
......
...@@ -875,7 +875,7 @@ bool ValidateES3CopyTexImageParameters(Context *context, GLenum target, GLint le ...@@ -875,7 +875,7 @@ bool ValidateES3CopyTexImageParameters(Context *context, GLenum target, GLint le
gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
if (framebuffer->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE) if (framebuffer->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
{ {
context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false; return false;
...@@ -1289,7 +1289,7 @@ bool ValidateClearBuffer(Context *context) ...@@ -1289,7 +1289,7 @@ bool ValidateClearBuffer(Context *context)
} }
const gl::Framebuffer *fbo = context->getState().getDrawFramebuffer(); const gl::Framebuffer *fbo = context->getState().getDrawFramebuffer();
if (!fbo || fbo->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE) if (!fbo || fbo->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
{ {
context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return false; return false;
......
...@@ -599,7 +599,7 @@ GLenum GL_APIENTRY CheckFramebufferStatus(GLenum target) ...@@ -599,7 +599,7 @@ GLenum GL_APIENTRY CheckFramebufferStatus(GLenum target)
Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
ASSERT(framebuffer); ASSERT(framebuffer);
return framebuffer->completeness(context->getData()); return framebuffer->checkStatus(context->getData());
} }
return 0; return 0;
...@@ -615,7 +615,7 @@ void GL_APIENTRY Clear(GLbitfield mask) ...@@ -615,7 +615,7 @@ void GL_APIENTRY Clear(GLbitfield mask)
Framebuffer *framebufferObject = context->getState().getDrawFramebuffer(); Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
ASSERT(framebufferObject); ASSERT(framebufferObject);
if (framebufferObject->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE) if (framebufferObject->checkStatus(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
{ {
context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION)); context->recordError(Error(GL_INVALID_FRAMEBUFFER_OPERATION));
return; return;
......
...@@ -3233,7 +3233,7 @@ void GL_APIENTRY InvalidateFramebuffer(GLenum target, GLsizei numAttachments, co ...@@ -3233,7 +3233,7 @@ void GL_APIENTRY InvalidateFramebuffer(GLenum target, GLsizei numAttachments, co
Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
ASSERT(framebuffer); ASSERT(framebuffer);
if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE) if (framebuffer->checkStatus(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
{ {
Error error = framebuffer->invalidate(numAttachments, attachments); Error error = framebuffer->invalidate(numAttachments, attachments);
if (error.isError()) if (error.isError())
...@@ -3268,7 +3268,7 @@ void GL_APIENTRY InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, ...@@ -3268,7 +3268,7 @@ void GL_APIENTRY InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
ASSERT(framebuffer); ASSERT(framebuffer);
if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE) if (framebuffer->checkStatus(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
{ {
Rectangle area(x, y, width, height); Rectangle area(x, y, width, height);
Error error = framebuffer->invalidateSub(numAttachments, attachments, area); Error error = framebuffer->invalidateSub(numAttachments, attachments, area);
......
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