From: Nicolai Hähnle Date: Sat, 9 Jan 2016 22:51:39 +0000 (-0500) Subject: mesa: fix the checks in _mesa_InvalidateBuffer(Sub)Data X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=53c77494aa7362d390b09351f831713519064ccc;p=mesa.git mesa: fix the checks in _mesa_InvalidateBuffer(Sub)Data Change the check to be in line with what the quoted spec fragment says. I have sent out a piglit test for this as well. Reviewed-by: Ian Romanick --- diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 14ee8c8fc73..aa2498bf5f5 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -3898,8 +3898,14 @@ _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset, struct gl_buffer_object *bufObj; const GLintptr end = offset + length; + /* Section 6.5 (Invalidating Buffer Data) of the OpenGL 4.5 (Compatibility + * Profile) spec says: + * + * "An INVALID_VALUE error is generated if buffer is zero or is not the + * name of an existing buffer object." + */ bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!bufObj) { + if (!bufObj || bufObj == &DummyBufferObject) { _mesa_error(ctx, GL_INVALID_VALUE, "glInvalidateBufferSubData(name = 0x%x) invalid object", buffer); @@ -3912,7 +3918,7 @@ _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset, * negative, or if + is greater than the value of * BUFFER_SIZE." */ - if (end < 0 || end > bufObj->Size) { + if (offset < 0 || length < 0 || end > bufObj->Size) { _mesa_error(ctx, GL_INVALID_VALUE, "glInvalidateBufferSubData(invalid offset or length)"); return; @@ -3945,8 +3951,14 @@ _mesa_InvalidateBufferData(GLuint buffer) GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + /* Section 6.5 (Invalidating Buffer Data) of the OpenGL 4.5 (Compatibility + * Profile) spec says: + * + * "An INVALID_VALUE error is generated if buffer is zero or is not the + * name of an existing buffer object." + */ bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!bufObj) { + if (!bufObj || bufObj == &DummyBufferObject) { _mesa_error(ctx, GL_INVALID_VALUE, "glInvalidateBufferData(name = 0x%x) invalid object", buffer);