Commit 461d9a30 by JiangYizhou Committed by Commit Bot

ES31:Check framebuffer status for multisample and default params

This patch implements FRAMEBUFFER_INCOMPLETE_MULTISAMPLE checking for checkFramebufferStatus, and also modify conditions of FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENTS when setting default parameters to fbo. BUG=angleproject:1594 TEST=angle_end2end_tests --gtest_filter=FramebufferTest_ES31* TEST=dEQP-GLES31.functional.texture.multisample.negative.fbo_attach_different_fixed_state_tex* Change-Id: I86954056d3a5d89dca517b267bd16e17b70e5652 Reviewed-on: https://chromium-review.googlesource.com/437991 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 185e32b8
......@@ -594,8 +594,9 @@ GLenum Framebuffer::checkStatusImpl(const ContextState &state)
unsigned int colorbufferSize = 0;
int samples = -1;
bool missingAttachment = true;
Optional<GLboolean> fixedSampleLocations;
bool hasRenderbuffer = false;
// TODO(yizhou): Check status for default framebuffer parameters.
for (const FramebufferAttachment &colorAttachment : mState.mColorAttachments)
{
if (colorAttachment.isAttached())
......@@ -636,9 +637,23 @@ GLenum Framebuffer::checkStatusImpl(const ContextState &state)
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
// ES3.1 (section 9.4) requires that the value of TEXTURE_FIXED_SAMPLE_LOCATIONS
// should be the same for all attached textures.
GLboolean fixedSampleloc = colorAttachment.getTexture()->getFixedSampleLocations(
colorAttachment.getTextureImageIndex().type, 0);
if (fixedSampleLocations.valid() && fixedSampleloc != fixedSampleLocations.value())
{
return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
}
else
{
fixedSampleLocations = fixedSampleloc;
}
}
else if (colorAttachment.type() == GL_RENDERBUFFER)
{
hasRenderbuffer = true;
if (!formatCaps.renderable || format.info->depthBits > 0 ||
format.info->stencilBits > 0)
{
......@@ -667,7 +682,7 @@ GLenum Framebuffer::checkStatusImpl(const ContextState &state)
}
else
{
samples = colorAttachment.getSamples();
samples = colorAttachment.getSamples();
colorbufferSize = format.info->pixelBytes;
missingAttachment = false;
}
......@@ -811,8 +826,14 @@ GLenum Framebuffer::checkStatusImpl(const ContextState &state)
}
}
// we need to have at least one attachment to be complete
if (missingAttachment)
// ES3.1(section 9.4) requires that if no image is attached to the
// framebuffer, and either the value of the framebuffer's FRAMEBUFFER_DEFAULT_WIDTH
// or FRAMEBUFFER_DEFAULT_HEIGHT parameters is zero, the framebuffer is
// considered incomplete.
GLint defaultWidth = mState.getDefaultWidth();
GLint defaultHeight = mState.getDefaultHeight();
if (missingAttachment && (defaultWidth == 0 || defaultHeight == 0))
{
return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
}
......@@ -824,6 +845,14 @@ GLenum Framebuffer::checkStatusImpl(const ContextState &state)
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
}
// ES3.1(section 9.4) requires that if the attached images are a mix of renderbuffers
// and textures, the value of TEXTURE_FIXED_SAMPLE_LOCATIONS must be TRUE for all
// attached textures.
if (fixedSampleLocations.valid() && hasRenderbuffer && !fixedSampleLocations.value())
{
return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
}
syncState();
if (!mImpl->checkStatus())
{
......
......@@ -82,8 +82,6 @@
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_16.sample_mask_and_sample_coverage = FAIL
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_16.sample_mask_and_sample_coverage_and_alpha_to_coverage = FAIL
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_16.sample_mask_non_effective_bits = FAIL
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.negative.fbo_attach_different_fixed_state_tex_tex = FAIL
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.negative.fbo_attach_different_fixed_state_tex_rbo = FAIL
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.negative.texture_min_filter = FAIL
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.negative.texture_mag_filter = FAIL
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.negative.texture_wrap_s = FAIL
......
......@@ -8,6 +8,7 @@
//
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
using namespace angle;
......@@ -390,3 +391,127 @@ TEST_P(FramebufferTest_ES3, DepthOnlyAsDepthStencil)
}
ANGLE_INSTANTIATE_TEST(FramebufferTest_ES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
class FramebufferTest_ES31 : public ANGLETest
{
};
// Test that without attachment, if either the value of FRAMEBUFFER_DEFAULT_WIDTH or
// FRAMEBUFFER_DEFAULT_HEIGHT parameters is zero, the framebuffer is incomplete.
TEST_P(FramebufferTest_ES31, IncompleteMissingAttachmentDefaultParam)
{
GLFramebuffer mFramebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get());
glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, 1);
glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, 1);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, 0);
glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, 0);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT,
glCheckFramebufferStatus(GL_FRAMEBUFFER));
glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, 1);
glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, 0);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT,
glCheckFramebufferStatus(GL_FRAMEBUFFER));
glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, 0);
glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, 1);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT,
glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_NO_ERROR();
}
// Test that the sample count of a mix of texture and renderbuffer should be same.
TEST_P(FramebufferTest_ES31, IncompleteMultisampleSampleCountMix)
{
GLFramebuffer mFramebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get());
GLTexture mTexture;
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTexture.get());
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, true);
GLRenderbuffer mRenderbuffer;
glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_RGBA8, 1, 1);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
mTexture.get(), 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER,
mRenderbuffer.get());
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_NO_ERROR();
}
// Test that the sample count of texture attachments should be same.
TEST_P(FramebufferTest_ES31, IncompleteMultisampleSampleCountTex)
{
GLFramebuffer mFramebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get());
GLTexture mTextures[2];
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[0].get());
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, true);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[1].get());
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 2, GL_RGBA8, 1, 1, true);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
mTextures[0].get(), 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE,
mTextures[1].get(), 0);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_NO_ERROR();
}
// Test that if the attached images are a mix of renderbuffers and textures, the value of
// TEXTURE_FIXED_SAMPLE_LOCATIONS must be TRUE for all attached textures.
TEST_P(FramebufferTest_ES31, IncompleteMultisampleFixedSampleLocationsMix)
{
GLFramebuffer mFramebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get());
GLTexture mTexture;
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTexture.get());
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, false);
GLRenderbuffer mRenderbuffer;
glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 1, GL_RGBA8, 1, 1);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
mTexture.get(), 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER,
mRenderbuffer.get());
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_NO_ERROR();
}
// Test that the value of TEXTURE_FIXED_SAMPLE_LOCATIONS is the same for all attached textures.
TEST_P(FramebufferTest_ES31, IncompleteMultisampleFixedSampleLocationsTex)
{
GLFramebuffer mFramebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get());
GLTexture mTextures[2];
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[0].get());
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, false);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
mTextures[0].get(), 0);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[1].get());
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGB8, 1, 1, true);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE,
mTextures[1].get(), 0);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_NO_ERROR();
}
ANGLE_INSTANTIATE_TEST(FramebufferTest_ES31, ES31_OPENGL(), ES31_OPENGLES());
......@@ -107,15 +107,8 @@ TEST_P(TextureMultisampleTestES31, ValidateTextureStorageMultisampleParameters)
{
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTexture);
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, GL_FALSE);
if (getClientMajorVersion() < 3 || getClientMinorVersion() < 1)
{
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
return;
}
else
{
ASSERT_GL_NO_ERROR();
}
ASSERT_GL_NO_ERROR();
GLint params = 0;
glGetTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_IMMUTABLE_FORMAT, &params);
EXPECT_EQ(1, params);
......
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