From 2c2ea573e556d6a866ad397e44356b7e0894056b Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Mon, 22 May 2017 15:47:02 +1000 Subject: [PATCH] mesa: add KHR_no_error support for glBindBufferRange() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Iago Toral Quiroga Tested-by: Dieter Nützel --- src/mapi/glapi/gen/GL3x.xml | 2 +- src/mesa/main/bufferobj.c | 103 +++++++++++++++++++++++------------- src/mesa/main/bufferobj.h | 3 ++ 3 files changed, 70 insertions(+), 38 deletions(-) diff --git a/src/mapi/glapi/gen/GL3x.xml b/src/mapi/glapi/gen/GL3x.xml index 10c157e5f85..f488ba36aec 100644 --- a/src/mapi/glapi/gen/GL3x.xml +++ b/src/mapi/glapi/gen/GL3x.xml @@ -213,7 +213,7 @@ - + diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 5aae579eaf4..9e656a4c989 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -3993,7 +3993,7 @@ bind_atomic_buffers(struct gl_context *ctx, static ALWAYS_INLINE void bind_buffer_range(GLenum target, GLuint index, GLuint buffer, GLintptr offset, - GLsizeiptr size) + GLsizeiptr size, bool no_error) { GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; @@ -4013,53 +4013,82 @@ bind_buffer_range(GLenum target, GLuint index, GLuint buffer, GLintptr offset, &bufObj, "glBindBufferRange")) return; - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindBufferRange(invalid buffer=%u)", buffer); - return; - } - - if (buffer != 0) { - if (size <= 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)", - (int) size); + if (no_error) { + switch (target) { + case GL_TRANSFORM_FEEDBACK_BUFFER: + _mesa_bind_buffer_range_xfb(ctx, ctx->TransformFeedback.CurrentObject, + index, bufObj, offset, size); return; + case GL_UNIFORM_BUFFER: + bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size); + return; + case GL_SHADER_STORAGE_BUFFER: + bind_buffer_range_shader_storage_buffer(ctx, index, bufObj, offset, + size); + return; + case GL_ATOMIC_COUNTER_BUFFER: + bind_atomic_buffer(ctx, index, bufObj, offset, size); + return; + default: + unreachable("invalid BindBufferRange target with KHR_no_error"); } - } - - switch (target) { - case GL_TRANSFORM_FEEDBACK_BUFFER: - if (!_mesa_validate_buffer_range_xfb(ctx, - ctx->TransformFeedback.CurrentObject, - index, bufObj, offset, size, - false)) + } else { + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBufferRange(invalid buffer=%u)", buffer); return; + } - _mesa_bind_buffer_range_xfb(ctx, ctx->TransformFeedback.CurrentObject, - index, bufObj, offset, size); - return; - case GL_UNIFORM_BUFFER: - bind_buffer_range_uniform_buffer_err(ctx, index, bufObj, offset, size); - return; - case GL_SHADER_STORAGE_BUFFER: - bind_buffer_range_shader_storage_buffer_err(ctx, index, bufObj, offset, - size); - return; - case GL_ATOMIC_COUNTER_BUFFER: - bind_atomic_buffer_err(ctx, index, bufObj, offset, size, - "glBindBufferRange"); - return; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)"); - return; + if (buffer != 0) { + if (size <= 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)", + (int) size); + return; + } + } + + switch (target) { + case GL_TRANSFORM_FEEDBACK_BUFFER: + if (!_mesa_validate_buffer_range_xfb(ctx, + ctx->TransformFeedback.CurrentObject, + index, bufObj, offset, size, + false)) + return; + + _mesa_bind_buffer_range_xfb(ctx, ctx->TransformFeedback.CurrentObject, + index, bufObj, offset, size); + return; + case GL_UNIFORM_BUFFER: + bind_buffer_range_uniform_buffer_err(ctx, index, bufObj, offset, + size); + return; + case GL_SHADER_STORAGE_BUFFER: + bind_buffer_range_shader_storage_buffer_err(ctx, index, bufObj, + offset, size); + return; + case GL_ATOMIC_COUNTER_BUFFER: + bind_atomic_buffer_err(ctx, index, bufObj, offset, size, + "glBindBufferRange"); + return; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)"); + return; + } } } +void GLAPIENTRY +_mesa_BindBufferRange_no_error(GLenum target, GLuint index, GLuint buffer, + GLintptr offset, GLsizeiptr size) +{ + bind_buffer_range(target, index, buffer, offset, size, true); +} + void GLAPIENTRY _mesa_BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) { - bind_buffer_range(target, index, buffer, offset, size); + bind_buffer_range(target, index, buffer, offset, size, false); } void GLAPIENTRY diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index f652ec30d05..ff44fed0b85 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -322,6 +322,9 @@ _mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length); void GLAPIENTRY +_mesa_BindBufferRange_no_error(GLenum target, GLuint index, GLuint buffer, + GLintptr offset, GLsizeiptr size); +void GLAPIENTRY _mesa_BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -- 2.30.2