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, ...@@ -1686,7 +1686,7 @@ void Context::getFramebufferAttachmentParameteriv(GLenum target,
GLint *params) GLint *params)
{ {
const Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); 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) void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
...@@ -2220,7 +2220,7 @@ EGLenum Context::getRenderBuffer() const ...@@ -2220,7 +2220,7 @@ EGLenum Context::getRenderBuffer() const
return EGL_NONE; return EGL_NONE;
} }
const FramebufferAttachment *backAttachment = framebuffer->getAttachment(GL_BACK); const FramebufferAttachment *backAttachment = framebuffer->getAttachment(this, GL_BACK);
ASSERT(backAttachment != nullptr); ASSERT(backAttachment != nullptr);
return backAttachment->getSurface()->getRenderBuffer(); return backAttachment->getSurface()->getRenderBuffer();
} }
......
...@@ -297,7 +297,8 @@ const std::string &FramebufferState::getLabel() ...@@ -297,7 +297,8 @@ const std::string &FramebufferState::getLabel()
return mLabel; 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) if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15)
{ {
...@@ -317,7 +318,17 @@ const FramebufferAttachment *FramebufferState::getAttachment(GLenum attachment) ...@@ -317,7 +318,17 @@ const FramebufferAttachment *FramebufferState::getAttachment(GLenum attachment)
return getStencilAttachment(); return getStencilAttachment();
case GL_DEPTH_STENCIL: case GL_DEPTH_STENCIL:
case GL_DEPTH_STENCIL_ATTACHMENT: 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: default:
UNREACHABLE(); UNREACHABLE();
return nullptr; return nullptr;
...@@ -402,6 +413,11 @@ const FramebufferAttachment *FramebufferState::getDepthAttachment() const ...@@ -402,6 +413,11 @@ const FramebufferAttachment *FramebufferState::getDepthAttachment() const
return mDepthAttachment.isAttached() ? &mDepthAttachment : nullptr; return mDepthAttachment.isAttached() ? &mDepthAttachment : nullptr;
} }
const FramebufferAttachment *FramebufferState::getWebGLDepthStencilAttachment() const
{
return mWebGLDepthStencilAttachment.isAttached() ? &mWebGLDepthStencilAttachment : nullptr;
}
const FramebufferAttachment *FramebufferState::getStencilAttachment() const const FramebufferAttachment *FramebufferState::getStencilAttachment() const
{ {
return mStencilAttachment.isAttached() ? &mStencilAttachment : nullptr; return mStencilAttachment.isAttached() ? &mStencilAttachment : nullptr;
...@@ -466,7 +482,15 @@ const gl::FramebufferAttachment *FramebufferState::getDrawBuffer(size_t drawBuff ...@@ -466,7 +482,15 @@ const gl::FramebufferAttachment *FramebufferState::getDrawBuffer(size_t drawBuff
// must be COLOR_ATTACHMENTi or NONE" // must be COLOR_ATTACHMENTi or NONE"
ASSERT(mDrawBufferStates[drawBufferIdx] == GL_COLOR_ATTACHMENT0 + drawBufferIdx || ASSERT(mDrawBufferStates[drawBufferIdx] == GL_COLOR_ATTACHMENT0 + drawBufferIdx ||
(drawBufferIdx == 0 && mDrawBufferStates[drawBufferIdx] == GL_BACK)); (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 else
{ {
...@@ -797,9 +821,10 @@ const FramebufferAttachment *Framebuffer::getFirstNonNullAttachment() const ...@@ -797,9 +821,10 @@ const FramebufferAttachment *Framebuffer::getFirstNonNullAttachment() const
return mState.getFirstNonNullAttachment(); 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 size_t Framebuffer::getDrawbufferStateCount() const
......
...@@ -60,7 +60,7 @@ class FramebufferState final : angle::NonCopyable ...@@ -60,7 +60,7 @@ class FramebufferState final : angle::NonCopyable
const std::string &getLabel(); const std::string &getLabel();
size_t getReadIndex() const; 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 *getReadAttachment() const;
const FramebufferAttachment *getFirstNonNullAttachment() const; const FramebufferAttachment *getFirstNonNullAttachment() const;
const FramebufferAttachment *getFirstColorAttachment() const; const FramebufferAttachment *getFirstColorAttachment() const;
...@@ -100,6 +100,8 @@ class FramebufferState final : angle::NonCopyable ...@@ -100,6 +100,8 @@ class FramebufferState final : angle::NonCopyable
GLint getBaseViewIndex() const; GLint getBaseViewIndex() const;
private: private:
const FramebufferAttachment *getWebGLDepthStencilAttachment() const;
friend class Framebuffer; friend class Framebuffer;
std::string mLabel; std::string mLabel;
...@@ -185,7 +187,7 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver ...@@ -185,7 +187,7 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
const FramebufferAttachment *getFirstColorbuffer() const; const FramebufferAttachment *getFirstColorbuffer() const;
const FramebufferAttachment *getFirstNonNullAttachment() const; const FramebufferAttachment *getFirstNonNullAttachment() const;
const FramebufferAttachment *getAttachment(GLenum attachment) const; const FramebufferAttachment *getAttachment(const Context *context, GLenum attachment) const;
GLenum getMultiviewLayout() const; GLenum getMultiviewLayout() const;
GLsizei getNumViews() const; GLsizei getNumViews() const;
GLint getBaseViewIndex() const; GLint getBaseViewIndex() const;
......
...@@ -778,14 +778,16 @@ void GetAtomicCounterBufferResourceProperty(const Program *program, ...@@ -778,14 +778,16 @@ void GetAtomicCounterBufferResourceProperty(const Program *program,
} // anonymous namespace } // anonymous namespace
void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer, void QueryFramebufferAttachmentParameteriv(const Context *context,
const Framebuffer *framebuffer,
GLenum attachment, GLenum attachment,
GLenum pname, GLenum pname,
GLint *params) GLint *params)
{ {
ASSERT(framebuffer); ASSERT(framebuffer);
const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment); const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(context, attachment);
if (attachmentObject == nullptr) if (attachmentObject == nullptr)
{ {
// ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
......
...@@ -32,7 +32,8 @@ struct VertexAttribute; ...@@ -32,7 +32,8 @@ struct VertexAttribute;
class VertexBinding; class VertexBinding;
struct VertexAttribCurrentValueData; struct VertexAttribCurrentValueData;
void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer, void QueryFramebufferAttachmentParameteriv(const Context *context,
const Framebuffer *framebuffer,
GLenum attachment, GLenum attachment,
GLenum pname, GLenum pname,
GLint *params); GLint *params);
......
...@@ -1189,7 +1189,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, ...@@ -1189,7 +1189,7 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context,
return true; return true;
} }
bool ValidateBlitFramebufferParameters(ValidationContext *context, bool ValidateBlitFramebufferParameters(Context *context,
GLint srcX0, GLint srcX0,
GLint srcY0, GLint srcY0,
GLint srcX1, GLint srcX1,
...@@ -1383,9 +1383,9 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context, ...@@ -1383,9 +1383,9 @@ bool ValidateBlitFramebufferParameters(ValidationContext *context,
if (mask & masks[i]) if (mask & masks[i])
{ {
const gl::FramebufferAttachment *readBuffer = const gl::FramebufferAttachment *readBuffer =
readFramebuffer->getAttachment(attachments[i]); readFramebuffer->getAttachment(context, attachments[i]);
const gl::FramebufferAttachment *drawBuffer = const gl::FramebufferAttachment *drawBuffer =
drawFramebuffer->getAttachment(attachments[i]); drawFramebuffer->getAttachment(context, attachments[i]);
if (readBuffer && drawBuffer) if (readBuffer && drawBuffer)
{ {
...@@ -3739,7 +3739,7 @@ bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsiz ...@@ -3739,7 +3739,7 @@ bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsiz
return true; return true;
} }
bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, bool ValidateGetFramebufferAttachmentParameterivBase(Context *context,
GLenum target, GLenum target,
GLenum attachment, GLenum attachment,
GLenum pname, GLenum pname,
...@@ -3889,7 +3889,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -3889,7 +3889,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
} }
} }
const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment); const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(context, attachment);
if (attachmentObject) if (attachmentObject)
{ {
ASSERT(attachmentObject->type() == GL_RENDERBUFFER || ASSERT(attachmentObject->type() == GL_RENDERBUFFER ||
...@@ -4001,7 +4001,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, ...@@ -4001,7 +4001,7 @@ bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context,
return true; return true;
} }
bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(ValidationContext *context, bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(Context *context,
GLenum target, GLenum target,
GLenum attachment, GLenum attachment,
GLenum pname, GLenum pname,
......
...@@ -104,7 +104,7 @@ bool ValidateFramebufferRenderbufferParameters(Context *context, ...@@ -104,7 +104,7 @@ bool ValidateFramebufferRenderbufferParameters(Context *context,
GLenum renderbuffertarget, GLenum renderbuffertarget,
GLuint renderbuffer); GLuint renderbuffer);
bool ValidateBlitFramebufferParameters(ValidationContext *context, bool ValidateBlitFramebufferParameters(Context *context,
GLint srcX0, GLint srcX0,
GLint srcY0, GLint srcY0,
GLint srcX1, GLint srcX1,
...@@ -382,12 +382,12 @@ bool ValidateGenOrDelete(Context *context, GLint n); ...@@ -382,12 +382,12 @@ bool ValidateGenOrDelete(Context *context, GLint n);
bool ValidateRobustEntryPoint(ValidationContext *context, GLsizei bufSize); bool ValidateRobustEntryPoint(ValidationContext *context, GLsizei bufSize);
bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsizei numParams); bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsizei numParams);
bool ValidateGetFramebufferAttachmentParameterivBase(ValidationContext *context, bool ValidateGetFramebufferAttachmentParameterivBase(Context *context,
GLenum target, GLenum target,
GLenum attachment, GLenum attachment,
GLenum pname, GLenum pname,
GLsizei *numParams); GLsizei *numParams);
bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(ValidationContext *context, bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(Context *context,
GLenum target, GLenum target,
GLenum attachment, GLenum attachment,
GLenum pname, GLenum pname,
......
...@@ -2502,9 +2502,9 @@ bool ValidateBlitFramebufferANGLE(Context *context, ...@@ -2502,9 +2502,9 @@ bool ValidateBlitFramebufferANGLE(Context *context,
if (mask & masks[i]) if (mask & masks[i])
{ {
const FramebufferAttachment *readBuffer = const FramebufferAttachment *readBuffer =
readFramebuffer->getAttachment(attachments[i]); readFramebuffer->getAttachment(context, attachments[i]);
const FramebufferAttachment *drawBuffer = const FramebufferAttachment *drawBuffer =
drawFramebuffer->getAttachment(attachments[i]); drawFramebuffer->getAttachment(context, attachments[i]);
if (readBuffer && drawBuffer) if (readBuffer && drawBuffer)
{ {
...@@ -5834,7 +5834,7 @@ bool ValidateDrawElements(ValidationContext *context, ...@@ -5834,7 +5834,7 @@ bool ValidateDrawElements(ValidationContext *context,
return ValidateDrawElementsCommon(context, mode, count, type, indices, 1); return ValidateDrawElementsCommon(context, mode, count, type, indices, 1);
} }
bool ValidateGetFramebufferAttachmentParameteriv(ValidationContext *context, bool ValidateGetFramebufferAttachmentParameteriv(Context *context,
GLenum target, GLenum target,
GLenum attachment, GLenum attachment,
GLenum pname, GLenum pname,
......
...@@ -597,7 +597,7 @@ bool ValidateDrawElements(ValidationContext *context, ...@@ -597,7 +597,7 @@ bool ValidateDrawElements(ValidationContext *context,
bool ValidateDrawArrays(ValidationContext *context, GLenum mode, GLint first, GLsizei count); bool ValidateDrawArrays(ValidationContext *context, GLenum mode, GLint first, GLsizei count);
bool ValidateGetFramebufferAttachmentParameteriv(ValidationContext *context, bool ValidateGetFramebufferAttachmentParameteriv(Context *context,
GLenum target, GLenum target,
GLenum attachment, GLenum attachment,
GLenum pname, GLenum pname,
......
...@@ -2091,7 +2091,7 @@ ANGLE_EXPORT void GL_APIENTRY GetFramebufferAttachmentParameterivRobustANGLE(GLe ...@@ -2091,7 +2091,7 @@ ANGLE_EXPORT void GL_APIENTRY GetFramebufferAttachmentParameterivRobustANGLE(GLe
} }
const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target); const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target);
QueryFramebufferAttachmentParameteriv(framebuffer, attachment, pname, params); QueryFramebufferAttachmentParameteriv(context, framebuffer, attachment, pname, params);
SetRobustLengthParam(length, numParams); SetRobustLengthParam(length, numParams);
} }
} }
......
...@@ -2935,10 +2935,9 @@ TEST_P(WebGLCompatibilityTest, DepthStencilAttachment) ...@@ -2935,10 +2935,9 @@ TEST_P(WebGLCompatibilityTest, DepthStencilAttachment)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texture, 0);
GLint attachmentType; GLint attachmentType = 0;
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &attachmentType);
/*param*/ &attachmentType);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(GL_TEXTURE, attachmentType); EXPECT_GLENUM_EQ(GL_TEXTURE, attachmentType);
...@@ -2947,11 +2946,42 @@ TEST_P(WebGLCompatibilityTest, DepthStencilAttachment) ...@@ -2947,11 +2946,42 @@ TEST_P(WebGLCompatibilityTest, DepthStencilAttachment)
glBindFramebuffer(GL_FRAMEBUFFER, fbo2); glBindFramebuffer(GL_FRAMEBUFFER, fbo2);
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &attachmentType);
/*param*/ &attachmentType);
EXPECT_GL_ERROR(GL_INVALID_ENUM); 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. // This tests that rendering feedback loops works as expected with WebGL 2.
// Based on WebGL test conformance2/rendering/rendering-sampling-feedback-loop.html // Based on WebGL test conformance2/rendering/rendering-sampling-feedback-loop.html
TEST_P(WebGL2CompatibilityTest, RenderingFeedbackLoopWithDrawBuffers) 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