[Mesa-dev] [PATCH v2] mesa: Check first that draw buffers are valid for glDrawBuffers on GLES3
Eduardo Lima Mitev
elima at igalia.com
Mon Dec 15 02:47:06 PST 2014
Section 4.2 (Whole Framebuffer Operations) of the OpenGL 3.0 specification
says "Each buffer listed in bufs must be BACK, NONE, or one of the values from
table 4.3 (NONE, COLOR_ATTACHMENTi)".
This patch adds this check before previous other, more complex validation steps.
Fixes 1 dEQP test: dEQP-GLES3.functional.negative_api.buffer.draw_buffers
---
src/mesa/main/buffers.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 1ee2009..d7e97c7 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -323,14 +323,31 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
supportedMask = supported_buffer_bitmask(ctx, ctx->DrawBuffer);
usedBufferMask = 0x0;
- /* From the ES 3.0 specification, page 180:
- * "If the GL is bound to the default framebuffer, then n must be 1
- * and the constant must be BACK or NONE."
- */
- if (_mesa_is_gles3(ctx) && _mesa_is_winsys_fbo(ctx->DrawBuffer) &&
- (n != 1 || (buffers[0] != GL_NONE && buffers[0] != GL_BACK))) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffers(buffer)");
- return;
+ if (_mesa_is_gles3(ctx)) {
+ /* Section 4.2 (Whole Framebuffer Operations) of the OpenGL 3.0
+ * specification says:
+ *
+ * "Each buffer listed in bufs must be BACK, NONE, or one of the values
+ * from table 4.3 (NONE, COLOR_ATTACHMENTi)"
+ */
+ for (output = 0; output < n; output++) {
+ if (buffers[output] != GL_NONE && buffers[output] != GL_BACK &&
+ (buffers[output] < GL_COLOR_ATTACHMENT0 ||
+ buffers[output] >= GL_COLOR_ATTACHMENT0 + ctx->Const.MaxColorAttachments)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffers(buffer)");
+ return;
+ }
+ }
+
+ /* From the ES 3.0 specification, page 180:
+ * "If the GL is bound to the default framebuffer, then n must be 1
+ * and the constant must be BACK or NONE."
+ */
+ if (_mesa_is_winsys_fbo(ctx->DrawBuffer) &&
+ (n != 1 || (buffers[0] != GL_NONE && buffers[0] != GL_BACK))) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffers(buffer)");
+ return;
+ }
}
/* complicated error checking... */
--
2.1.3
More information about the mesa-dev
mailing list