Mesa (master): mesa: Check that draw buffers are valid for glDrawBuffers on GLES3

Samuel Iglesias Gonsálvez samuelig at kemper.freedesktop.org
Fri Feb 20 08:36:30 UTC 2015


Module: Mesa
Branch: master
Commit: 097b933b55eea6181678b34ede94bbc588dc94ff
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=097b933b55eea6181678b34ede94bbc588dc94ff

Author: Eduardo Lima Mitev <elima at igalia.com>
Date:   Fri Feb 20 09:32:42 2015 +0100

mesa: Check that draw buffers are valid for glDrawBuffers on GLES3

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)".

Fixes 1 dEQP test:
* dEQP-GLES3.functional.negative_api.buffer.draw_buffers

Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/mesa/main/buffers.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index a2d02d5..e5076e9 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -336,6 +336,20 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
 
    /* complicated error checking... */
    for (output = 0; output < n; output++) {
+      /* 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)"
+       */
+      if (_mesa_is_gles3(ctx) && 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;
+      }
+
       if (buffers[output] == GL_NONE) {
          destMask[output] = 0x0;
       }




More information about the mesa-commit mailing list