Commit a0016b7f by Jamie Madill Committed by Commit Bot

Check depth-stencil attachment sample count.

Currently we would only check for the color attachment sample count, which could return incorrect results for depth or stencil-only Framebuffers. BUG=angleproject:2108 Change-Id: I378349c91c0139ee507d88fa6a36a86234fea0d4 Reviewed-on: https://chromium-review.googlesource.com/571064Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent b50ccd36
...@@ -1081,11 +1081,11 @@ int Framebuffer::getSamples(const Context *context) ...@@ -1081,11 +1081,11 @@ int Framebuffer::getSamples(const Context *context)
{ {
// For a complete framebuffer, all attachments must have the same sample count. // For a complete framebuffer, all attachments must have the same sample count.
// In this case return the first nonzero sample size. // In this case return the first nonzero sample size.
const auto *firstColorAttachment = mState.getFirstColorAttachment(); const auto *firstNonNullAttachment = mState.getFirstNonNullAttachment();
if (firstColorAttachment) if (firstNonNullAttachment)
{ {
ASSERT(firstColorAttachment->isAttached()); ASSERT(firstNonNullAttachment->isAttached());
return firstColorAttachment->getSamples(); return firstNonNullAttachment->getSamples();
} }
} }
......
...@@ -1822,19 +1822,19 @@ void State::getIntegerv(const Context *context, GLenum pname, GLint *params) ...@@ -1822,19 +1822,19 @@ void State::getIntegerv(const Context *context, GLenum pname, GLint *params)
{ {
switch (pname) switch (pname)
{ {
case GL_SAMPLE_BUFFERS: case GL_SAMPLE_BUFFERS:
if (framebuffer->getSamples(context) != 0) if (framebuffer->getSamples(context) != 0)
{ {
*params = 1; *params = 1;
} }
else else
{ {
*params = 0; *params = 0;
} }
break; break;
case GL_SAMPLES: case GL_SAMPLES:
*params = framebuffer->getSamples(context); *params = framebuffer->getSamples(context);
break; break;
} }
} }
else else
......
...@@ -498,6 +498,25 @@ TEST_P(FramebufferTest_ES3, ColorAttachmentIndexOutOfBounds) ...@@ -498,6 +498,25 @@ TEST_P(FramebufferTest_ES3, ColorAttachmentIndexOutOfBounds)
EXPECT_GL_ERROR(GL_INVALID_OPERATION); EXPECT_GL_ERROR(GL_INVALID_OPERATION);
} }
// Check that depth-only attachments report the correct number of samples.
TEST_P(FramebufferTest_ES3, MultisampleDepthOnly)
{
GLRenderbuffer renderbuffer;
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_DEPTH_COMPONENT24, 32, 32);
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
EXPECT_GL_NO_ERROR();
GLint samples = 0;
glGetIntegerv(GL_SAMPLES, &samples);
EXPECT_GL_NO_ERROR();
EXPECT_GE(samples, 2);
}
ANGLE_INSTANTIATE_TEST(FramebufferTest_ES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES()); ANGLE_INSTANTIATE_TEST(FramebufferTest_ES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
class FramebufferTest_ES31 : public ANGLETest class FramebufferTest_ES31 : public ANGLETest
......
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