[Mesa-dev] [PATCH] mesa: Fix error generation for glClearBuffer{i ui}v with GL_DEPTH or GL_STENCIL
Eric Anholt
eric at anholt.net
Thu Nov 3 23:25:59 PDT 2011
On Thu, 3 Nov 2011 15:29:29 -0700, "Ian Romanick" <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at 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.romanick at 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;
Quoting spec about not generating an error for some condition right
above code for generating an error for an unrelated condition is rather
confusing.
I think quoting the bits about the required value for drawbuffer as well
would clear that up to me.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20111103/5246a4e5/attachment-0001.pgp>
More information about the mesa-dev
mailing list