[Mesa-dev] [alternate PATCH 1.2/6] mesa: Make ES3 glDrawBuffers() only accept BACK/NONE for the winsys fbo.

Kenneth Graunke kenneth at whitecape.org
Tue Dec 18 13:26:04 PST 2012


Nothing was explicitly checking this.
---
 src/mesa/main/buffers.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 244f4de..065ef2a 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -316,6 +316,16 @@ _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;
+   }
+
    /* complicated error checking... */
    for (output = 0; output < n; output++) {
       if (buffers[output] == GL_NONE) {
-- 
1.8.0.2



More information about the mesa-dev mailing list