Commit 32d6006b by Geoff Lang Committed by Commit Bot

Don't block setting the DEPTH_STENCIL attachment based on the resource format.

By blocking the attachment at this point, it doesn't allow for the resource to have a depth stencil format later. BUG=997702 Change-Id: Iec5243012cb9a9527c5b1467d44c393b0dc6bddc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1780898 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 90a58622
...@@ -1788,27 +1788,13 @@ void Framebuffer::setAttachmentImpl(const Context *context, ...@@ -1788,27 +1788,13 @@ void Framebuffer::setAttachmentImpl(const Context *context,
{ {
case GL_DEPTH_STENCIL: case GL_DEPTH_STENCIL:
case GL_DEPTH_STENCIL_ATTACHMENT: case GL_DEPTH_STENCIL_ATTACHMENT:
{
// ensure this is a legitimate depth+stencil format
FramebufferAttachmentObject *attachmentObj = resource;
if (resource)
{
const Format &format = resource->getAttachmentFormat(binding, textureIndex);
if (format.info->depthBits == 0 || format.info->stencilBits == 0)
{
// Attaching nullptr detaches the current attachment.
attachmentObj = nullptr;
}
}
updateAttachment(context, &mState.mDepthAttachment, DIRTY_BIT_DEPTH_ATTACHMENT, updateAttachment(context, &mState.mDepthAttachment, DIRTY_BIT_DEPTH_ATTACHMENT,
&mDirtyDepthAttachmentBinding, type, binding, textureIndex, &mDirtyDepthAttachmentBinding, type, binding, textureIndex, resource,
attachmentObj, numViews, baseViewIndex, isMultiview, samples); numViews, baseViewIndex, isMultiview, samples);
updateAttachment(context, &mState.mStencilAttachment, DIRTY_BIT_STENCIL_ATTACHMENT, updateAttachment(context, &mState.mStencilAttachment, DIRTY_BIT_STENCIL_ATTACHMENT,
&mDirtyStencilAttachmentBinding, type, binding, textureIndex, &mDirtyStencilAttachmentBinding, type, binding, textureIndex, resource,
attachmentObj, numViews, baseViewIndex, isMultiview, samples); numViews, baseViewIndex, isMultiview, samples);
break; break;
}
case GL_DEPTH: case GL_DEPTH:
case GL_DEPTH_ATTACHMENT: case GL_DEPTH_ATTACHMENT:
......
...@@ -842,6 +842,64 @@ TEST_P(WebGLFramebufferTest, TextureAttachmentCommitBug) ...@@ -842,6 +842,64 @@ TEST_P(WebGLFramebufferTest, TextureAttachmentCommitBug)
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
} }
// Test combinations of ordering in setting the resource format and attaching it to the depth
// stencil attacchment. Covers http://crbug.com/997702
TEST_P(WebGLFramebufferTest, DepthStencilAttachmentOrdering)
{
constexpr GLsizei kFramebufferSize = 16;
GLTexture color;
glBindTexture(GL_TEXTURE_2D, color);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kFramebufferSize, kFramebufferSize, 0, GL_RGBA,
GL_UNSIGNED_BYTE, nullptr);
GLRenderbuffer depthStencil;
glBindRenderbuffer(GL_RENDERBUFFER, depthStencil);
// Attach the renderbuffer to the framebuffer when it has no format
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
depthStencil);
// Framebuffer is incomplete because the depth stencil attachment doesn't a format/size
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER),
GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
// Set depth stencil attachment to a color format
if (EnsureGLExtensionEnabled("GL_OES_rgb8_rgba8"))
{
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, kFramebufferSize, kFramebufferSize);
// Non-depth stencil format on the depth stencil attachment
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER),
GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
}
{
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, kFramebufferSize,
kFramebufferSize);
// Depth-stencil attachment only has a depth format, not complete
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER),
GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
}
if (EnsureGLExtensionEnabled("GL_OES_packed_depth_stencil"))
{
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, kFramebufferSize,
kFramebufferSize);
// Framebuffer should be complete now with a depth-stencil format
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GL_FRAMEBUFFER_COMPLETE);
}
}
// Only run against WebGL 1 validation, since much was changed in 2. // Only run against WebGL 1 validation, since much was changed in 2.
ANGLE_INSTANTIATE_TEST(WebGLFramebufferTest, ANGLE_INSTANTIATE_TEST(WebGLFramebufferTest,
ES2_D3D9(), ES2_D3D9(),
......
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