From: Ian Romanick <ian.d.roman...@intel.com>

The spec says "Only ClearBufferiv should be used to clear
stencil buffers." and "Only ClearBufferfv should be used to clear
depth buffers."  However, on the following page it also says:

    "The result of ClearBuffer is undefined if no conversion between
    the type of the specified value and the type of the buffer being
    cleared is defined (for example, if ClearBufferiv is called for a
    fixed- or floating-point buffer, or if ClearBufferfv is called
    for a signed or unsigned integer buffer). *This is not an error.*"

Emphasis mine.

Fixes problems with piglit's clearbuffer-invalid-drawbuffer test.

Signed-off-by: Ian Romanick <ian.d.roman...@intel.com>
---
 src/mesa/main/clear.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index c35675f..c4e87e1 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -373,6 +373,23 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
          }
       }
       break;
+   case GL_DEPTH:
+      /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
+       *
+       *     "The result of ClearBuffer is undefined if no conversion between
+       *     the type of the specified value and the type of the buffer being
+       *     cleared is defined (for example, if ClearBufferiv is called for a
+       *     fixed- or floating-point buffer, or if ClearBufferfv is called
+       *     for a signed or unsigned integer buffer). This is not an error."
+       *
+       * In this case we take "undefined" and "not an error" to mean "ignore."
+       */
+      if (drawbuffer != 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)",
+                     drawbuffer);
+         return;
+      }
+      return;
    default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferiv(buffer=%s)",
                   _mesa_lookup_enum_by_nr(buffer));
@@ -424,6 +441,28 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, 
const GLuint *value)
          }
       }
       break;
+   case GL_DEPTH:
+   case GL_STENCIL:
+      /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
+       *
+       *     "The result of ClearBuffer is undefined if no conversion between
+       *     the type of the specified value and the type of the buffer being
+       *     cleared is defined (for example, if ClearBufferiv is called for a
+       *     fixed- or floating-point buffer, or if ClearBufferfv is called
+       *     for a signed or unsigned integer buffer). This is not an error."
+       *
+       * In this case we take "undefined" and "not an error" to mean "ignore."
+       * Even though we could do something sensible for GL_STENCIL, page 263
+       * (page 279 of the PDF) says:
+       *
+       *     "Only ClearBufferiv should be used to clear stencil buffers."
+       */
+      if (drawbuffer != 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferuiv(drawbuffer=%d)",
+                     drawbuffer);
+         return;
+      }
+      return;
    default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferuiv(buffer=%s)",
                   _mesa_lookup_enum_by_nr(buffer));
@@ -498,6 +537,23 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
          }
       }
       break;
+   case GL_STENCIL:
+      /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
+       *
+       *     "The result of ClearBuffer is undefined if no conversion between
+       *     the type of the specified value and the type of the buffer being
+       *     cleared is defined (for example, if ClearBufferiv is called for a
+       *     fixed- or floating-point buffer, or if ClearBufferfv is called
+       *     for a signed or unsigned integer buffer). This is not an error."
+       *
+       * In this case we take "undefined" and "not an error" to mean "ignore."
+       */
+      if (drawbuffer != 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)",
+                     drawbuffer);
+         return;
+      }
+      return;
    default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfv(buffer=%s)",
                   _mesa_lookup_enum_by_nr(buffer));
-- 
1.7.6.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to