Commit 57e6d50e by Corentin Wallez Committed by Commit Bot

FramebufferAttachment: make attach(nullptr) work like detach

Otherwise when trying to use a DEPTH texture for DEPTH_STENCIL, attach(nullptr) gets called but the FramebufferAttachment still returns true when isAttached is called. BUG=angleproject:1523 Change-Id: I30b78aff619eb6cd63e0befac886bddc177a2e58 Reviewed-on: https://chromium-review.googlesource.com/418403 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 4de340ac
......@@ -99,17 +99,21 @@ void FramebufferAttachment::attach(GLenum type,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource)
{
if (resource == nullptr)
{
detach();
return;
}
mType = type;
mTarget = Target(binding, textureIndex);
resource->onAttach();
if (resource)
{
resource->onAttach();
}
if (mResource != nullptr)
{
mResource->onDetach();
}
mResource = resource;
}
......
......@@ -336,10 +336,10 @@ ANGLE_INSTANTIATE_TEST(FramebufferFormatsTest,
ES2_OPENGLES(),
ES3_OPENGLES());
class FramebufferInvalidateTest : public ANGLETest
class FramebufferTest_ES3 : public ANGLETest
{
protected:
FramebufferInvalidateTest() : mFramebuffer(0), mRenderbuffer(0) {}
FramebufferTest_ES3() : mFramebuffer(0), mRenderbuffer(0) {}
void SetUp() override
{
......@@ -361,7 +361,7 @@ class FramebufferInvalidateTest : public ANGLETest
};
// Covers invalidating an incomplete framebuffer. This should be a no-op, but should not error.
TEST_P(FramebufferInvalidateTest, Incomplete)
TEST_P(FramebufferTest_ES3, InvalidateIncomplete)
{
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer);
......@@ -376,4 +376,17 @@ TEST_P(FramebufferInvalidateTest, Incomplete)
EXPECT_GL_NO_ERROR();
}
ANGLE_INSTANTIATE_TEST(FramebufferInvalidateTest, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
// Test that the framebuffer state tracking robustly handles a depth-only attachment being set
// as a depth-stencil attachment. It is equivalent to detaching the depth-stencil attachment.
TEST_P(FramebufferTest_ES3, DepthOnlyAsDepthStencil)
{
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 4, 4);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
mRenderbuffer);
EXPECT_GLENUM_NE(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
}
ANGLE_INSTANTIATE_TEST(FramebufferTest_ES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
......@@ -41,6 +41,10 @@
#define ASSERT_GLENUM_EQ(expected, actual) ASSERT_EQ(static_cast<GLenum>(expected), static_cast<GLenum>(actual))
#define EXPECT_GLENUM_EQ(expected, actual) EXPECT_EQ(static_cast<GLenum>(expected), static_cast<GLenum>(actual))
#define ASSERT_GLENUM_NE(expected, actual) \
ASSERT_NE(static_cast<GLenum>(expected), static_cast<GLenum>(actual))
#define EXPECT_GLENUM_NE(expected, actual) \
EXPECT_NE(static_cast<GLenum>(expected), static_cast<GLenum>(actual))
namespace angle
{
......
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