Commit 2eeb1b34 by Bryan Bernhart (Intel Americas Inc) Committed by Commit Bot

WebGLCompat: Fix depthstencil query results.

getFramebufferAttachmentParameter returns incorrect result for framebuffers in an inconsistent state. BUG=angleproject:2259 Change-Id: I76fa99f1b8847c30469d344bd93dedd9cf6657bf Reviewed-on: https://chromium-review.googlesource.com/798318Reviewed-by: 's avatarBryan Bernhart <bryan.bernhart@intel.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent fdb400d7
......@@ -1686,7 +1686,7 @@ void Context::getFramebufferAttachmentParameteriv(GLenum target,
GLint *params)
{
const Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target);
QueryFramebufferAttachmentParameteriv(framebuffer, attachment, pname, params);
QueryFramebufferAttachmentParameteriv(this, framebuffer, attachment, pname, params);
}
void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
......@@ -2220,7 +2220,7 @@ EGLenum Context::getRenderBuffer() const
return EGL_NONE;
}
const FramebufferAttachment *backAttachment = framebuffer->getAttachment(GL_BACK);
const FramebufferAttachment *backAttachment = framebuffer->getAttachment(this, GL_BACK);
ASSERT(backAttachment != nullptr);
return backAttachment->getSurface()->getRenderBuffer();
}
......
......@@ -297,7 +297,8 @@ const std::string &FramebufferState::getLabel()
return mLabel;
}
const FramebufferAttachment *FramebufferState::getAttachment(GLenum attachment) const
const FramebufferAttachment *FramebufferState::getAttachment(const Context *context,
GLenum attachment) const
{
if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15)
{
......@@ -317,7 +318,17 @@ const FramebufferAttachment *FramebufferState::getAttachment(GLenum attachment)
return getStencilAttachment();
case GL_DEPTH_STENCIL:
case GL_DEPTH_STENCIL_ATTACHMENT:
return getDepthStencilAttachment();
// 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();
}
else
{
return getDepthStencilAttachment();
}
default:
UNREACHABLE();
return nullptr;
......@@ -402,6 +413,11 @@ const FramebufferAttachment *FramebufferState::getDepthAttachment() const
return mDepthAttachment.isAttached() ? &mDepthAttachment : nullptr;
}
const FramebufferAttachment *FramebufferState::getWebGLDepthStencilAttachment() const
{
return mWebGLDepthStencilAttachment.isAttached() ? &mWebGLDepthStencilAttachment : nullptr;
}
const FramebufferAttachment *FramebufferState::getStencilAttachment() const
{
return mStencilAttachment.isAttached() ? &mStencilAttachment : nullptr;
......@@ -466,7 +482,15 @@ const gl::FramebufferAttachment *FramebufferState::getDrawBuffer(size_t drawBuff
// must be COLOR_ATTACHMENTi or NONE"
ASSERT(mDrawBufferStates[drawBufferIdx] == GL_COLOR_ATTACHMENT0 + drawBufferIdx ||
(drawBufferIdx == 0 && mDrawBufferStates[drawBufferIdx] == GL_BACK));
return getAttachment(mDrawBufferStates[drawBufferIdx]);
if (mDrawBufferStates[drawBufferIdx] == GL_BACK)
{
return getColorAttachment(0);
}
else
{
return getColorAttachment(mDrawBufferStates[drawBufferIdx] - GL_COLOR_ATTACHMENT0);
}
}
else
{
......@@ -797,9 +821,10 @@ const FramebufferAttachment *Framebuffer::getFirstNonNullAttachment() const
return mState.getFirstNonNullAttachment();
}
const FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
const FramebufferAttachment *Framebuffer::getAttachment(const Context *context,
GLenum attachment) const
{
return mState.getAttachment(attachment);
return mState.getAttachment(context, attachment);
}
size_t Framebuffer::getDrawbufferStateCount() const
......
......@@ -60,7 +60,7 @@ class FramebufferState final : angle::NonCopyable
const std::string &getLabel();
size_t getReadIndex() const;
const FramebufferAttachment *getAttachment(GLenum attachment) const;
const FramebufferAttachment *getAttachment(const Context *context, GLenum attachment) const;
const FramebufferAttachment *getReadAttachment() const;
const FramebufferAttachment *getFirstNonNullAttachment() const;
const FramebufferAttachment *getFirstColorAttachment() const;
......@@ -100,6 +100,8 @@ class FramebufferState final : angle::NonCopyable
GLint getBaseViewIndex() const;
private:
const FramebufferAttachment *getWebGLDepthStencilAttachment() const;
friend class Framebuffer;
std::string mLabel;
......@@ -185,7 +187,7 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
const FramebufferAttachment *getFirstColorbuffer() const;
const FramebufferAttachment *getFirstNonNullAttachment() const;
const FramebufferAttachment *getAttachment(GLenum attachment) const;
const FramebufferAttachment *getAttachment(const Context *context, GLenum attachment) const;
GLenum getMultiviewLayout() const;
GLsizei getNumViews() const;
GLint getBaseViewIndex() const;
......
......@@ -778,14 +778,16 @@ void GetAtomicCounterBufferResourceProperty(const Program *program,
} // anonymous namespace
void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer,
void QueryFramebufferAttachmentParameteriv(const Context *context,
const Framebuffer *framebuffer,
GLenum attachment,
GLenum pname,
GLint *params)
{
ASSERT(framebuffer);
const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(context, attachment);
if (attachmentObject == nullptr)
{
// ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
......
......@@ -32,7 +32,8 @@ struct VertexAttribute;
class VertexBinding;
struct VertexAttribCurrentValueData;
void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer,
void QueryFramebufferAttachmentParameteriv(const Context *context,
const Framebuffer *framebuffer,
GLenum attachment,
GLenum pname,
GLint *params);
......
......@@ -1189,7 +1189,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context,
return true;
}
bool ValidateBlitFramebufferParameters(ValidationContext *context,
bool ValidateBlitFramebufferParameters(Context *context,
GLint srcX0,
GLint srcY0,
GLint srcX1,
......@@ -1383,9 +1383,9 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context,
if (mask & masks[i])
{
const gl::FramebufferAttachment *readBuffer =
readFramebuffer->getAttachment(attachments[i]);
readFramebuffer->getAttachment(context, attachments[i]);
const gl::FramebufferAttachment *drawBuffer =
drawFramebuffer->getAttachment(attachments[i]);
drawFramebuffer->getAttachment(context, attachments[i]);
if (readBuffer && drawBuffer)
{
......@@ -3739,7 +3739,7 @@ bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsiz
return true;
}
bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
bool ValidateGetFramebufferAttachmentParameterivBase(Context *context,
GLenum target,
GLenum attachment,
GLenum pname,
......@@ -3889,7 +3889,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
}
}
const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(context, attachment);
if (attachmentObject)
{
ASSERT(attachmentObject->type() == GL_RENDERBUFFER ||
......@@ -4001,7 +4001,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
return true;
}
bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(ValidationContext *context,
bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(Context *context,
GLenum target,
GLenum attachment,
GLenum pname,
......
......@@ -104,7 +104,7 @@ bool ValidateFramebufferRenderbufferParameters(Context *context,
GLenum renderbuffertarget,
GLuint renderbuffer);
bool ValidateBlitFramebufferParameters(ValidationContext *context,
bool ValidateBlitFramebufferParameters(Context *context,
GLint srcX0,
GLint srcY0,
GLint srcX1,
......@@ -382,12 +382,12 @@ bool ValidateGenOrDelete(Context *context, GLint n);
bool ValidateRobustEntryPoint(ValidationContext *context, GLsizei bufSize);
bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsizei numParams);
bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
bool ValidateGetFramebufferAttachmentParameterivBase(Context *context,
GLenum target,
GLenum attachment,
GLenum pname,
GLsizei *numParams);
bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(ValidationContext *context,
bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(Context *context,
GLenum target,
GLenum attachment,
GLenum pname,
......
......@@ -2502,9 +2502,9 @@ bool ValidateBlitFramebufferANGLE(Context *context,
if (mask & masks[i])
{
const FramebufferAttachment *readBuffer =
readFramebuffer->getAttachment(attachments[i]);
readFramebuffer->getAttachment(context, attachments[i]);
const FramebufferAttachment *drawBuffer =
drawFramebuffer->getAttachment(attachments[i]);
drawFramebuffer->getAttachment(context, attachments[i]);
if (readBuffer && drawBuffer)
{
......@@ -5834,7 +5834,7 @@ bool ValidateDrawElements(ValidationContext *context,
return ValidateDrawElementsCommon(context, mode, count, type, indices, 1);
}
bool ValidateGetFramebufferAttachmentParameteriv(ValidationContext *context,
bool ValidateGetFramebufferAttachmentParameteriv(Context *context,
GLenum target,
GLenum attachment,
GLenum pname,
......
......@@ -597,7 +597,7 @@ bool ValidateDrawElements(ValidationContext *context,
bool ValidateDrawArrays(ValidationContext *context, GLenum mode, GLint first, GLsizei count);
bool ValidateGetFramebufferAttachmentParameteriv(ValidationContext *context,
bool ValidateGetFramebufferAttachmentParameteriv(Context *context,
GLenum target,
GLenum attachment,
GLenum pname,
......
......@@ -2091,7 +2091,7 @@ ANGLE_EXPORT void GL_APIENTRY GetFramebufferAttachmentParameterivRobustANGLE(GLe
}
const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target);
QueryFramebufferAttachmentParameteriv(framebuffer, attachment, pname, params);
QueryFramebufferAttachmentParameteriv(context, framebuffer, attachment, pname, params);
SetRobustLengthParam(length, numParams);
}
}
......
......@@ -2935,10 +2935,9 @@ TEST_P(WebGLCompatibilityTest, DepthStencilAttachment)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texture, 0);
GLint attachmentType;
GLint attachmentType = 0;
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
/*param*/ &attachmentType);
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &attachmentType);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(GL_TEXTURE, attachmentType);
......@@ -2947,11 +2946,42 @@ TEST_P(WebGLCompatibilityTest, DepthStencilAttachment)
glBindFramebuffer(GL_FRAMEBUFFER, fbo2);
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
/*param*/ &attachmentType);
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &attachmentType);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
}
// Verify framebuffer attachments return expected types when in an inconsistant state.
TEST_P(WebGLCompatibilityTest, FramebufferAttachmentConsistancy)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() > 2);
GLFramebuffer fbo;
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
GLRenderbuffer rb1;
glBindRenderbuffer(GL_RENDERBUFFER, rb1);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb1);
GLint attachmentType = 0;
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &attachmentType);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(GL_RENDERBUFFER, attachmentType);
GLRenderbuffer rb2;
glBindRenderbuffer(GL_RENDERBUFFER, rb2);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb2);
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_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.
// Based on WebGL test conformance2/rendering/rendering-sampling-feedback-loop.html
TEST_P(WebGL2CompatibilityTest, RenderingFeedbackLoopWithDrawBuffers)
......
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