Fix framebuffer attachment enum validation
In GLES 3.0, GL_COLOR_ATTACHMENTi enums run all the way up to i=31,
and don't stop at i=15 which the validation was previously checking
against. It's acceptable to use this new enum range also for
EXT_draw_buffers, since an error will still be generated if an enum
is outside the range of maximum supported attachments.
Also, generate INVALID_ENUM when dEQP tests expect it to be generated
for color attachment number that's outside the supported range. This
is not in line with the published 3.0 spec, but that's just an
oversight in the spec document.
Also fix incorrect INVALID_VALUE error in the validation of
renderbufferStorageMultisample to INVALID_OPERATION.
BUG=angleproject:1101
TEST=dEQP-GLES3.functional.negative_api.buffer.* (all pass)
Change-Id: Ib8cf92651d29ef8fe8da0ce4bfa456cbc4d48850
Reviewed-on: https://chromium-review.googlesource.com/332140
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 12c7612..ddc32c4 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -2265,7 +2265,7 @@
for (GLsizei i = 0; i < numAttachments; ++i)
{
- if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT15)
+ if (attachments[i] >= GL_COLOR_ATTACHMENT0 && attachments[i] <= GL_COLOR_ATTACHMENT31)
{
if (defaultFramebuffer)
{
@@ -2569,13 +2569,21 @@
const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != GL_BACK &&
- (bufs[colorAttachment] < GL_COLOR_ATTACHMENT0_EXT ||
- bufs[colorAttachment] >= maxColorAttachment))
+ (bufs[colorAttachment] < GL_COLOR_ATTACHMENT0 ||
+ bufs[colorAttachment] > GL_COLOR_ATTACHMENT31))
{
// Value in bufs is not NONE, BACK, or GL_COLOR_ATTACHMENTi
- // In the 3.0 specs, the error should return GL_INVALID_OPERATION.
- // When we move to 3.1 specs, we should change the error to be GL_INVALID_ENUM
- context->recordError(Error(GL_INVALID_OPERATION, "Invalid buffer value"));
+ // The 3.0.4 spec says to generate GL_INVALID_OPERATION here, but this
+ // was changed to GL_INVALID_ENUM in 3.1, which dEQP also expects.
+ // 3.1 is still a bit ambiguous about the error, but future specs are
+ // expected to clarify that GL_INVALID_ENUM is the correct error.
+ context->recordError(Error(GL_INVALID_ENUM, "Invalid buffer value"));
+ return false;
+ }
+ else if (bufs[colorAttachment] >= maxColorAttachment)
+ {
+ context->recordError(
+ Error(GL_INVALID_OPERATION, "Buffer value is greater than MAX_DRAW_BUFFERS"));
return false;
}
else if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment &&