Commit 005a7016 by Geoff Lang Committed by Commit Bot

Adjust the FBO invalidate attachment enums for emulated default FBOs.

BUG=angleproject:1953 Change-Id: I7f325e3b7400e12077cdf9106a83a747a318a299 Reviewed-on: https://chromium-review.googlesource.com/461297Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 9e1bf10b
......@@ -135,16 +135,26 @@ Error FramebufferGL::discard(size_t count, const GLenum *attachments)
Error FramebufferGL::invalidate(size_t count, const GLenum *attachments)
{
const GLenum *finalAttachmentsPtr = attachments;
std::vector<GLenum> modifiedAttachments;
if (modifyInvalidateAttachmentsForEmulatedDefaultFBO(count, attachments, &modifiedAttachments))
{
finalAttachmentsPtr = modifiedAttachments.data();
}
// Since this function is just a hint, only call a native function if it exists.
if (mFunctions->invalidateFramebuffer)
{
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->invalidateFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count), attachments);
mFunctions->invalidateFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count),
finalAttachmentsPtr);
}
else if (mFunctions->discardFramebuffer)
{
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->discardFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count), attachments);
mFunctions->discardFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count),
finalAttachmentsPtr);
}
return gl::NoError();
......@@ -154,12 +164,22 @@ Error FramebufferGL::invalidateSub(size_t count,
const GLenum *attachments,
const gl::Rectangle &area)
{
const GLenum *finalAttachmentsPtr = attachments;
std::vector<GLenum> modifiedAttachments;
if (modifyInvalidateAttachmentsForEmulatedDefaultFBO(count, attachments, &modifiedAttachments))
{
finalAttachmentsPtr = modifiedAttachments.data();
}
// Since this function is just a hint and not available until OpenGL 4.3, only call it if it is available.
if (mFunctions->invalidateSubFramebuffer)
{
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->invalidateSubFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count),
attachments, area.x, area.y, area.width, area.height);
finalAttachmentsPtr, area.x, area.y, area.width,
area.height);
}
return NoError();
......@@ -520,6 +540,44 @@ void FramebufferGL::syncClearBufferState(ContextImpl *context, GLenum buffer, GL
}
}
}
bool FramebufferGL::modifyInvalidateAttachmentsForEmulatedDefaultFBO(
size_t count,
const GLenum *attachments,
std::vector<GLenum> *modifiedAttachments) const
{
bool needsModification = mIsDefault && mFramebufferID != 0;
if (!needsModification)
{
return false;
}
modifiedAttachments->resize(count);
for (size_t i = 0; i < count; i++)
{
switch (attachments[i])
{
case GL_COLOR:
(*modifiedAttachments)[i] = GL_COLOR_ATTACHMENT0;
break;
case GL_DEPTH:
(*modifiedAttachments)[i] = GL_DEPTH_ATTACHMENT;
break;
case GL_STENCIL:
(*modifiedAttachments)[i] = GL_STENCIL_ATTACHMENT;
break;
default:
UNREACHABLE();
break;
}
}
return true;
}
gl::Error FramebufferGL::readPixelsRowByRowWorkaround(const gl::Rectangle &area,
GLenum format,
GLenum type,
......
......@@ -89,6 +89,11 @@ class FramebufferGL : public FramebufferImpl
void syncClearState(ContextImpl *context, GLbitfield mask);
void syncClearBufferState(ContextImpl *context, GLenum buffer, GLint drawBuffer);
bool modifyInvalidateAttachmentsForEmulatedDefaultFBO(
size_t count,
const GLenum *attachments,
std::vector<GLenum> *modifiedAttachments) const;
gl::Error readPixelsRowByRowWorkaround(const gl::Rectangle &area,
GLenum format,
GLenum type,
......
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