[Mesa-dev,03/11] mesa: Return INVALID_ENUM in glClearBufferiv() when buffer is not color or stencil

Submitted by Eduardo Lima Mitev on Feb. 10, 2015, 3:40 p.m.

Details

Message ID 1423582848-18526-4-git-send-email-elima@igalia.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Eduardo Lima Mitev Feb. 10, 2015, 3:40 p.m.
Section 4.2.3 Clearing the Buffers, page 190 of the OpenGL ES 3.0.4 spec says:
"ClearBufferiv generates an INVALID_ENUM error if buffer is not COLOR or STENCIL."

Fixes 1 dEQP test:
* dEQP-GLES3.functional.negative_api.buffer.clear_bufferiv
---
 src/mesa/main/clear.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 3c4ced8..46de80b 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -323,6 +323,19 @@  _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
       _mesa_update_state( ctx );
    }
 
+   /* Section 4.2.3 Clearing the Buffers, page 190 of the OpenGL ES 3.0.4
+    * spec says:
+    *
+    *    "ClearBufferiv generates an INVALID_ENUM error if buffer is not COLOR or
+    *     STENCIL."
+    */
+   if (_mesa_is_gles3(ctx) &&
+       (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:

Comments

On 02/10/2015 07:40 AM, Eduardo Lima Mitev wrote:
> Section 4.2.3 Clearing the Buffers, page 190 of the OpenGL ES 3.0.4 spec says:
> "ClearBufferiv generates an INVALID_ENUM error if buffer is not COLOR or STENCIL."
> 
> Fixes 1 dEQP test:
> * dEQP-GLES3.functional.negative_api.buffer.clear_bufferiv
> ---
>  src/mesa/main/clear.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
> index 3c4ced8..46de80b 100644
> --- a/src/mesa/main/clear.c
> +++ b/src/mesa/main/clear.c
> @@ -323,6 +323,19 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
>        _mesa_update_state( ctx );
>     }
>  
> +   /* Section 4.2.3 Clearing the Buffers, page 190 of the OpenGL ES 3.0.4
> +    * spec says:

Desktop OpenGL 4.5 (and possibly earlier) has the same error.  See the
bottom of page 488 (page 520 of the PDF).  I believe this is a
clarification of previous specs, so we should always generate the error.

With that changed, this patch is

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>

> +    *
> +    *    "ClearBufferiv generates an INVALID_ENUM error if buffer is not COLOR or
> +    *     STENCIL."
> +    */
> +   if (_mesa_is_gles3(ctx) &&
> +       (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:
>