diff options
author | Timothy Arceri <[email protected]> | 2017-07-25 23:34:06 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-07-26 10:16:20 +1000 |
commit | 003c8b116717c3bade740d299b3b2e6131a1ae0b (patch) | |
tree | f7592c1a29f1532d6d43cbf0af75c8a3d4fcdddf /src/mesa/main/bufferobj.c | |
parent | 4943353bff3192aabf652e61bb13830a9d576406 (diff) |
mesa: move static binding functions above _mesa_DeleteBuffers()
Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/mesa/main/bufferobj.c')
-rw-r--r-- | src/mesa/main/bufferobj.c | 412 |
1 files changed, 205 insertions, 207 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 12fe2d31436..324bbc6ea15 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1258,6 +1258,211 @@ _mesa_BindBuffer(GLenum target, GLuint buffer) bind_buffer_object(ctx, bindTarget, buffer); } +/** + * Binds a buffer object to an atomic buffer binding point. + * + * The caller is responsible for validating the offset, + * flushing the vertices and updating NewDriverState. + */ +static void +set_atomic_buffer_binding(struct gl_context *ctx, + struct gl_atomic_buffer_binding *binding, + struct gl_buffer_object *bufObj, + GLintptr offset, + GLsizeiptr size) +{ + _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj); + + if (bufObj == ctx->Shared->NullBufferObj) { + binding->Offset = 0; + binding->Size = 0; + } else { + binding->Offset = offset; + binding->Size = size; + bufObj->UsageHistory |= USAGE_ATOMIC_COUNTER_BUFFER; + } +} + +/** + * Binds a buffer object to a uniform buffer binding point. + * + * The caller is responsible for flushing vertices and updating + * NewDriverState. + */ +static void +set_ubo_binding(struct gl_context *ctx, + struct gl_uniform_buffer_binding *binding, + struct gl_buffer_object *bufObj, + GLintptr offset, + GLsizeiptr size, + GLboolean autoSize) +{ + _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj); + + binding->Offset = offset; + binding->Size = size; + binding->AutomaticSize = autoSize; + + /* If this is a real buffer object, mark it has having been used + * at some point as a UBO. + */ + if (size >= 0) + bufObj->UsageHistory |= USAGE_UNIFORM_BUFFER; +} + +/** + * Binds a buffer object to a shader storage buffer binding point. + * + * The caller is responsible for flushing vertices and updating + * NewDriverState. + */ +static void +set_ssbo_binding(struct gl_context *ctx, + struct gl_shader_storage_buffer_binding *binding, + struct gl_buffer_object *bufObj, + GLintptr offset, + GLsizeiptr size, + GLboolean autoSize) +{ + _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj); + + binding->Offset = offset; + binding->Size = size; + binding->AutomaticSize = autoSize; + + /* If this is a real buffer object, mark it has having been used + * at some point as a SSBO. + */ + if (size >= 0) + bufObj->UsageHistory |= USAGE_SHADER_STORAGE_BUFFER; +} + +/** + * Binds a buffer object to a uniform buffer binding point. + * + * Unlike set_ubo_binding(), this function also flushes vertices + * and updates NewDriverState. It also checks if the binding + * has actually changed before updating it. + */ +static void +bind_uniform_buffer(struct gl_context *ctx, + GLuint index, + struct gl_buffer_object *bufObj, + GLintptr offset, + GLsizeiptr size, + GLboolean autoSize) +{ + struct gl_uniform_buffer_binding *binding = + &ctx->UniformBufferBindings[index]; + + if (binding->BufferObject == bufObj && + binding->Offset == offset && + binding->Size == size && + binding->AutomaticSize == autoSize) { + return; + } + + FLUSH_VERTICES(ctx, 0); + ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer; + + set_ubo_binding(ctx, binding, bufObj, offset, size, autoSize); +} + +/** + * Binds a buffer object to a shader storage buffer binding point. + * + * Unlike set_ssbo_binding(), this function also flushes vertices + * and updates NewDriverState. It also checks if the binding + * has actually changed before updating it. + */ +static void +bind_shader_storage_buffer(struct gl_context *ctx, + GLuint index, + struct gl_buffer_object *bufObj, + GLintptr offset, + GLsizeiptr size, + GLboolean autoSize) +{ + struct gl_shader_storage_buffer_binding *binding = + &ctx->ShaderStorageBufferBindings[index]; + + if (binding->BufferObject == bufObj && + binding->Offset == offset && + binding->Size == size && + binding->AutomaticSize == autoSize) { + return; + } + + FLUSH_VERTICES(ctx, 0); + ctx->NewDriverState |= ctx->DriverFlags.NewShaderStorageBuffer; + + set_ssbo_binding(ctx, binding, bufObj, offset, size, autoSize); +} + +/** + * Bind a buffer object to a uniform block binding point. + * As above, but offset = 0. + */ +static void +bind_buffer_base_uniform_buffer(struct gl_context *ctx, + GLuint index, + struct gl_buffer_object *bufObj) +{ + if (index >= ctx->Const.MaxUniformBufferBindings) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index); + return; + } + + _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj); + + if (bufObj == ctx->Shared->NullBufferObj) + bind_uniform_buffer(ctx, index, bufObj, -1, -1, GL_TRUE); + else + bind_uniform_buffer(ctx, index, bufObj, 0, 0, GL_TRUE); +} + +/** + * Bind a buffer object to a shader storage block binding point. + * As above, but offset = 0. + */ +static void +bind_buffer_base_shader_storage_buffer(struct gl_context *ctx, + GLuint index, + struct gl_buffer_object *bufObj) +{ + if (index >= ctx->Const.MaxShaderStorageBufferBindings) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index); + return; + } + + _mesa_reference_buffer_object(ctx, &ctx->ShaderStorageBuffer, bufObj); + + if (bufObj == ctx->Shared->NullBufferObj) + bind_shader_storage_buffer(ctx, index, bufObj, -1, -1, GL_TRUE); + else + bind_shader_storage_buffer(ctx, index, bufObj, 0, 0, GL_TRUE); +} + +static void +bind_atomic_buffer(struct gl_context *ctx, unsigned index, + struct gl_buffer_object *bufObj, GLintptr offset, + GLsizeiptr size) +{ + _mesa_reference_buffer_object(ctx, &ctx->AtomicBuffer, bufObj); + + struct gl_atomic_buffer_binding *binding = + &ctx->AtomicBufferBindings[index]; + if (binding->BufferObject == bufObj && + binding->Offset == offset && + binding->Size == size) { + return; + } + + FLUSH_VERTICES(ctx, 0); + ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer; + + set_atomic_buffer_binding(ctx, binding, bufObj, offset, size); +} /** * Delete a set of buffer objects. @@ -3035,123 +3240,6 @@ _mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset, "glFlushMappedNamedBufferRange"); } - -/** - * Binds a buffer object to a uniform buffer binding point. - * - * The caller is responsible for flushing vertices and updating - * NewDriverState. - */ -static void -set_ubo_binding(struct gl_context *ctx, - struct gl_uniform_buffer_binding *binding, - struct gl_buffer_object *bufObj, - GLintptr offset, - GLsizeiptr size, - GLboolean autoSize) -{ - _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj); - - binding->Offset = offset; - binding->Size = size; - binding->AutomaticSize = autoSize; - - /* If this is a real buffer object, mark it has having been used - * at some point as a UBO. - */ - if (size >= 0) - bufObj->UsageHistory |= USAGE_UNIFORM_BUFFER; -} - -/** - * Binds a buffer object to a shader storage buffer binding point. - * - * The caller is responsible for flushing vertices and updating - * NewDriverState. - */ -static void -set_ssbo_binding(struct gl_context *ctx, - struct gl_shader_storage_buffer_binding *binding, - struct gl_buffer_object *bufObj, - GLintptr offset, - GLsizeiptr size, - GLboolean autoSize) -{ - _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj); - - binding->Offset = offset; - binding->Size = size; - binding->AutomaticSize = autoSize; - - /* If this is a real buffer object, mark it has having been used - * at some point as a SSBO. - */ - if (size >= 0) - bufObj->UsageHistory |= USAGE_SHADER_STORAGE_BUFFER; -} - -/** - * Binds a buffer object to a uniform buffer binding point. - * - * Unlike set_ubo_binding(), this function also flushes vertices - * and updates NewDriverState. It also checks if the binding - * has actually changed before updating it. - */ -static void -bind_uniform_buffer(struct gl_context *ctx, - GLuint index, - struct gl_buffer_object *bufObj, - GLintptr offset, - GLsizeiptr size, - GLboolean autoSize) -{ - struct gl_uniform_buffer_binding *binding = - &ctx->UniformBufferBindings[index]; - - if (binding->BufferObject == bufObj && - binding->Offset == offset && - binding->Size == size && - binding->AutomaticSize == autoSize) { - return; - } - - FLUSH_VERTICES(ctx, 0); - ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer; - - set_ubo_binding(ctx, binding, bufObj, offset, size, autoSize); -} - -/** - * Binds a buffer object to a shader storage buffer binding point. - * - * Unlike set_ssbo_binding(), this function also flushes vertices - * and updates NewDriverState. It also checks if the binding - * has actually changed before updating it. - */ -static void -bind_shader_storage_buffer(struct gl_context *ctx, - GLuint index, - struct gl_buffer_object *bufObj, - GLintptr offset, - GLsizeiptr size, - GLboolean autoSize) -{ - struct gl_shader_storage_buffer_binding *binding = - &ctx->ShaderStorageBufferBindings[index]; - - if (binding->BufferObject == bufObj && - binding->Offset == offset && - binding->Size == size && - binding->AutomaticSize == autoSize) { - return; - } - - FLUSH_VERTICES(ctx, 0); - ctx->NewDriverState |= ctx->DriverFlags.NewShaderStorageBuffer; - - set_ssbo_binding(ctx, binding, bufObj, offset, size, autoSize); -} - static void bind_buffer_range_uniform_buffer(struct gl_context *ctx, GLuint index, struct gl_buffer_object *bufObj, @@ -3238,96 +3326,6 @@ bind_buffer_range_shader_storage_buffer_err(struct gl_context *ctx, } /** - * Bind a buffer object to a uniform block binding point. - * As above, but offset = 0. - */ -static void -bind_buffer_base_uniform_buffer(struct gl_context *ctx, - GLuint index, - struct gl_buffer_object *bufObj) -{ - if (index >= ctx->Const.MaxUniformBufferBindings) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index); - return; - } - - _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj); - - if (bufObj == ctx->Shared->NullBufferObj) - bind_uniform_buffer(ctx, index, bufObj, -1, -1, GL_TRUE); - else - bind_uniform_buffer(ctx, index, bufObj, 0, 0, GL_TRUE); -} - -/** - * Bind a buffer object to a shader storage block binding point. - * As above, but offset = 0. - */ -static void -bind_buffer_base_shader_storage_buffer(struct gl_context *ctx, - GLuint index, - struct gl_buffer_object *bufObj) -{ - if (index >= ctx->Const.MaxShaderStorageBufferBindings) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index); - return; - } - - _mesa_reference_buffer_object(ctx, &ctx->ShaderStorageBuffer, bufObj); - - if (bufObj == ctx->Shared->NullBufferObj) - bind_shader_storage_buffer(ctx, index, bufObj, -1, -1, GL_TRUE); - else - bind_shader_storage_buffer(ctx, index, bufObj, 0, 0, GL_TRUE); -} - -/** - * Binds a buffer object to an atomic buffer binding point. - * - * The caller is responsible for validating the offset, - * flushing the vertices and updating NewDriverState. - */ -static void -set_atomic_buffer_binding(struct gl_context *ctx, - struct gl_atomic_buffer_binding *binding, - struct gl_buffer_object *bufObj, - GLintptr offset, - GLsizeiptr size) -{ - _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj); - - if (bufObj == ctx->Shared->NullBufferObj) { - binding->Offset = 0; - binding->Size = 0; - } else { - binding->Offset = offset; - binding->Size = size; - bufObj->UsageHistory |= USAGE_ATOMIC_COUNTER_BUFFER; - } -} - -static void -bind_atomic_buffer(struct gl_context *ctx, unsigned index, - struct gl_buffer_object *bufObj, GLintptr offset, - GLsizeiptr size) -{ - _mesa_reference_buffer_object(ctx, &ctx->AtomicBuffer, bufObj); - - struct gl_atomic_buffer_binding *binding = - &ctx->AtomicBufferBindings[index]; - if (binding->BufferObject == bufObj && - binding->Offset == offset && - binding->Size == size) { - return; - } - - FLUSH_VERTICES(ctx, 0); - ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer; - - set_atomic_buffer_binding(ctx, binding, bufObj, offset, size); -} - -/** * Binds a buffer object to an atomic buffer binding point. * * Unlike set_atomic_buffer_binding(), this function also validates the |