diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2016-01-09 17:51:39 -0500 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2016-01-12 12:19:38 -0500 |
commit | 130d8ee31823612fcd1f85088ef23555cf8a73ea (patch) | |
tree | 240fd764f2517edc6f878bb9d9488cfab32ea79a | |
parent | 77987bb01af901c574d18493f66dff724df3bfa2 (diff) |
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.
-rw-r--r-- | src/mesa/main/bufferobj.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 3aab83946d..63d563e5e5 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -3939,8 +3939,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); @@ -3953,7 +3959,7 @@ _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset, * negative, or if <offset> + <length> 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; @@ -3986,8 +3992,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); |