Commit d178aa46 by Martin Radev Committed by Commit Bot

Fix attachment validation bug

Passing COLOR_ATTACHMENTm, where m is greater or equal to MAX_COLOR_ATTACHMENTS, to a FramebufferTexture* function should generate an INVALID_OPERATION instead of an INVALID_VALUE error. BUG=angleproject:2106 TEST=angle_end2end_tests Change-Id: I99045defcbe5eb2afefac1b45062ee4245f50dd3 Reviewed-on: https://chromium-review.googlesource.com/569966Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 34bc315d
...@@ -1446,7 +1446,9 @@ bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment) ...@@ -1446,7 +1446,9 @@ bool ValidateAttachmentTarget(gl::Context *context, GLenum attachment)
if (colorAttachment >= context->getCaps().maxColorAttachments) if (colorAttachment >= context->getCaps().maxColorAttachments)
{ {
context->handleError(InvalidValue()); context->handleError(
InvalidOperation()
<< "attachment index cannot be greater or equal to MAX_COLOR_ATTACHMENTS.");
return false; return false;
} }
} }
......
...@@ -478,6 +478,26 @@ TEST_P(FramebufferTest_ES3, TextureAttachmentMipLevels) ...@@ -478,6 +478,26 @@ TEST_P(FramebufferTest_ES3, TextureAttachmentMipLevels)
ExpectFramebufferCompleteOrUnsupported(GL_FRAMEBUFFER); ExpectFramebufferCompleteOrUnsupported(GL_FRAMEBUFFER);
} }
// Test that passing an attachment COLOR_ATTACHMENTm where m is equal to MAX_COLOR_ATTACHMENTS
// generates an INVALID_OPERATION.
// OpenGL ES Version 3.0.5 (November 3, 2016), 4.4.2.4 Attaching Texture Images to a Framebuffer, p.
// 208
TEST_P(FramebufferTest_ES3, ColorAttachmentIndexOutOfBounds)
{
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
GLint maxColorAttachments = 0;
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
GLenum attachment = static_cast<GLenum>(maxColorAttachments + GL_COLOR_ATTACHMENT0);
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture.get());
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, 1, 1);
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, texture.get(), 0);
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
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