--- src/mesa/main/bufferobj.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++ src/mesa/main/bufferobj.h | 9 ++- 2 files changed, 165 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index a3d8f24..bad8f90 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -2706,3 +2706,161 @@ _mesa_InvalidateBufferData(GLuint buffer) */ return; } + +void GLAPIENTRY +_mesa_BindBuffersBase(GLenum target, GLuint first, GLsizei count, + const GLuint *buffers) +{ + GET_CURRENT_CONTEXT(ctx); + int i = 0; + GLboolean exceedMaxBindings = GL_FALSE; + + switch(target) { + case GL_TRANSFORM_FEEDBACK_BUFFER: + first + count > ctx->Const.MaxTransformFeedbackBuffers ? + exceedMaxBindings = GL_TRUE : exceedMaxBindings = GL_FALSE; + break; + case GL_UNIFORM_BUFFER: + first + count > ctx->Const.MaxUniformBufferBindings ? + exceedMaxBindings = GL_TRUE : exceedMaxBindings = GL_FALSE; + break; + case GL_ATOMIC_COUNTER_BUFFER: + first + count > ctx->Const.MaxAtomicBufferBindings ? + exceedMaxBindings = GL_TRUE : exceedMaxBindings = GL_FALSE; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glBindBuffersBase(invalid target)"); + return; + } + + if(exceedMaxBindings) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBuffersBase(first+count)"); + return; + } + + for(i = 0 ; i < count ; i++) { + GLuint buffer; + struct gl_buffer_object *bufferObj; + + if(buffers == NULL) + buffer = 0; + else + buffer = buffers[i]; + + if(buffer != 0) { + bufferObj = _mesa_lookup_bufferobj(ctx, buffer); + if(bufferObj) { + _mesa_BindBufferBase(target, first+i, buffer); + } + else + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBufferBase(buffer[%i] is invalid)", i); + } + else + _mesa_BindBufferBase(target, first + i, 0); + } +} + +void GLAPIENTRY +_mesa_BindBuffersRange(GLenum target, GLuint first, GLsizei count, + const GLuint *buffers, const GLintptr *offsets, + const GLsizeiptr *sizes) +{ + GET_CURRENT_CONTEXT(ctx); + int i = 0; + GLboolean exceedMaxBindings = GL_FALSE; + + switch(target) { + case GL_TRANSFORM_FEEDBACK_BUFFER: + first + count > ctx->Const.MaxTransformFeedbackBuffers ? + exceedMaxBindings = GL_TRUE : exceedMaxBindings = GL_FALSE; + break; + case GL_UNIFORM_BUFFER: + first + count > ctx->Const.MaxUniformBufferBindings ? + exceedMaxBindings = GL_TRUE : exceedMaxBindings = GL_FALSE; + break; + case GL_ATOMIC_COUNTER_BUFFER: + first + count > ctx->Const.MaxAtomicBufferBindings ? + exceedMaxBindings = GL_TRUE : exceedMaxBindings = GL_FALSE; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glBindBuffersRange(invalid target)"); + return; + } + + if(exceedMaxBindings) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBuffersRange(first+count)"); + return; + } + + for(i = 0 ; i < count ; i++) { + GLuint buffer; + GLintptr offset; + GLsizeiptr size; + struct gl_buffer_object *bufferObj; + + if(buffers == NULL) + buffer = 0; + else { + buffer = buffers[i]; + offset = offsets[i]; + size = sizes[i]; + } + + if(buffer != 0) { + bufferObj = _mesa_lookup_bufferobj(ctx, buffer); + if(bufferObj) { + GLboolean validOffet, validSize; + + switch(target) { + case GL_TRANSFORM_FEEDBACK_BUFFER: + (offset >= 0) ? + validOffset = GL_TRUE : validOffet = GL_FALSE; + (size >= 0) ? + validSize = GL_TRUE : validSize = GL_FALSE; + /* TODO : add target specific checks */ + break; + case GL_UNIFORM_BUFFER: + (offset >= 0) ? + validOffset = GL_TRUE : validOffet = GL_FALSE; + (size >= 0) ? + validSize = GL_TRUE : validSize = GL_FALSE; + /* TODO : add target specific checks */ + break; + case GL_ATOMIC_COUNTER_BUFFER: + (offset >= 0) ? + validOffset = GL_TRUE : validOffet = GL_FALSE; + (size >= 0) ? + validSize = GL_TRUE : validSize = GL_FALSE; + /* TODO : add target specific checks */ + break; + default: + /* should not get there at this point */ + return; + } + + if(!validOffet || !validSize) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glBindBuffersRange(offsets and/or sizes invalid)"); + return; + } + + if(offset+size > bufferObj->Size) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glBindBuffersRange(offset+size > GL_BUFFER_SIZE)"); + return; + } + _mesa_BindBufferRange(target, first+i, buffer, offset, size); + } + else + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBuffersRange(buffers)"); + } + else + _mesa_BindBufferRange(target, first + i, 0, 0, 0); + } +} diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 71988b0..5bc3734 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -191,6 +191,11 @@ _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset, void GLAPIENTRY _mesa_InvalidateBufferData(GLuint buffer); - - +void GLAPIENTRY +_mesa_BindBuffersBase(GLenum target, GLuint first, GLsizei count, + const GLuint *buffers); +void GLAPIENTRY +_mesa_BindBuffersRange(GLenum target, GLuint first, GLsizei count, + const GLuint *buffers, const GLintptr *offsets, + const GLsizeiptr *sizes); #endif -- 1.8.5.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev