mesa: Return INVALID_ENUM in glClearBufferiv() when buffer is not color or stencil
authorEduardo Lima Mitev <elima@igalia.com>
Tue, 10 Feb 2015 15:40:40 +0000 (16:40 +0100)
committerEduardo Lima Mitev <elima@igalia.com>
Wed, 29 Jul 2015 06:13:12 +0000 (08:13 +0200)
Page 497 of the PDF, section '17.4.3.1 Clearing Individual Buffers' of the
OpenGL 4.5 spec states:

    "An INVALID_ENUM error is generated by ClearBufferiv and
     ClearNamedFramebufferiv if buffer is not COLOR or STENCIL."

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

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/clear.c

index 8284dcab528e793b3082a053d1fe7b726f5173fb..3bfcc5c0e396aaba45edfe18c67b250770d9e026 100644 (file)
@@ -325,6 +325,18 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
       _mesa_update_state( ctx );
    }
 
+   /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
+    * of the OpenGL 4.5 spec states:
+    *
+    *    "An INVALID_ENUM error is generated by ClearBufferiv and
+    *     ClearNamedFramebufferiv if buffer is not COLOR or STENCIL."
+    */
+   if (buffer == GL_DEPTH || buffer == GL_DEPTH_STENCIL) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "glClearBufferiv(buffer=GL_DEPTH || GL_DEPTH_STENCIL)");
+      return;
+   }
+
    switch (buffer) {
    case GL_STENCIL:
       /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says: