Commit 5f19810d by Bryan Bernhart (Intel Americas Inc) Committed by Commit Bot

WebGLCompat: Fix depth & stencil query results.

getFramebufferAttachmentParameter returns incorrect result for framebuffers in an inconsistent state. BUG=angleproject:2281 Change-Id: Ifb83ecaf16c95bf1237b2c4f2684de6aa2d55c46 Reviewed-on: https://chromium-review.googlesource.com/823224 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 8225e73b
......@@ -305,6 +305,9 @@ const FramebufferAttachment *FramebufferState::getAttachment(const Context *cont
return getColorAttachment(attachment - GL_COLOR_ATTACHMENT0);
}
// WebGL1 allows a developer to query for attachment parameters even when "inconsistant" (i.e.
// multiple conflicting attachment points) and requires us to return the framebuffer attachment
// associated with WebGL.
switch (attachment)
{
case GL_COLOR:
......@@ -312,15 +315,26 @@ const FramebufferAttachment *FramebufferState::getAttachment(const Context *cont
return getColorAttachment(0);
case GL_DEPTH:
case GL_DEPTH_ATTACHMENT:
return getDepthAttachment();
if (context->isWebGL1())
{
return getWebGLDepthAttachment();
}
else
{
return getDepthAttachment();
}
case GL_STENCIL:
case GL_STENCIL_ATTACHMENT:
return getStencilAttachment();
if (context->isWebGL1())
{
return getWebGLStencilAttachment();
}
else
{
return getStencilAttachment();
}
case GL_DEPTH_STENCIL:
case GL_DEPTH_STENCIL_ATTACHMENT:
// In WebG1, DEPTH_STENCIL_ATTACHMENT is an alternative attachment point and even when
// inconsistant (i.e. multiple conflicting attachment points), it is still permitted to
// query the attachment parameters.
if (context->isWebGL1())
{
return getWebGLDepthStencilAttachment();
......@@ -413,6 +427,11 @@ const FramebufferAttachment *FramebufferState::getDepthAttachment() const
return mDepthAttachment.isAttached() ? &mDepthAttachment : nullptr;
}
const FramebufferAttachment *FramebufferState::getWebGLDepthAttachment() const
{
return mWebGLDepthAttachment.isAttached() ? &mWebGLDepthAttachment : nullptr;
}
const FramebufferAttachment *FramebufferState::getWebGLDepthStencilAttachment() const
{
return mWebGLDepthStencilAttachment.isAttached() ? &mWebGLDepthStencilAttachment : nullptr;
......@@ -423,6 +442,11 @@ const FramebufferAttachment *FramebufferState::getStencilAttachment() const
return mStencilAttachment.isAttached() ? &mStencilAttachment : nullptr;
}
const FramebufferAttachment *FramebufferState::getWebGLStencilAttachment() const
{
return mWebGLStencilAttachment.isAttached() ? &mWebGLStencilAttachment : nullptr;
}
const FramebufferAttachment *FramebufferState::getDepthStencilAttachment() const
{
// A valid depth-stencil attachment has the same resource bound to both the
......
......@@ -101,6 +101,8 @@ class FramebufferState final : angle::NonCopyable
private:
const FramebufferAttachment *getWebGLDepthStencilAttachment() const;
const FramebufferAttachment *getWebGLDepthAttachment() const;
const FramebufferAttachment *getWebGLStencilAttachment() const;
friend class Framebuffer;
......
......@@ -2980,6 +2980,22 @@ TEST_P(WebGLCompatibilityTest, FramebufferAttachmentConsistancy)
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(GL_RENDERBUFFER, attachmentType);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rb2);
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &attachmentType);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(GL_RENDERBUFFER, attachmentType);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb2);
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &attachmentType);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(GL_RENDERBUFFER, attachmentType);
}
// This tests that rendering feedback loops works as expected with WebGL 2.
......
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