Lines Matching refs:ctx
63 * \param ctx the GL context
69 get_buffer_target(struct gl_context *ctx, GLenum target)
73 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)
79 return &ctx->Array.ArrayBufferObj;
81 return &ctx->Array.ArrayObj->ElementArrayBufferObj;
83 return &ctx->Pack.BufferObj;
85 return &ctx->Unpack.BufferObj;
87 return &ctx->CopyReadBuffer;
89 return &ctx->CopyWriteBuffer;
92 if (ctx->Extensions.EXT_transform_feedback) {
93 return &ctx->TransformFeedback.CurrentBuffer;
98 if (_mesa_is_desktop_gl(ctx)
99 && ctx->Extensions.ARB_texture_buffer_object) {
100 return &ctx->Texture.BufferObject;
104 if (ctx->Extensions.ARB_uniform_buffer_object) {
105 return &ctx->UniformBuffer;
117 * \param ctx the GL context
123 get_buffer(struct gl_context *ctx, const char *func, GLenum target)
125 struct gl_buffer_object **bufObj = get_buffer_target(ctx, target);
128 _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func);
133 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffer 0)", func);
142 default_access_mode(const struct gl_context *ctx)
160 return _mesa_is_gles(ctx)
187 * \param ctx GL context.
200 buffer_object_subdata_range_good( struct gl_context * ctx, GLenum target,
207 _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", caller);
212 _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset < 0)", caller);
216 bufObj = get_buffer(ctx, caller, target);
221 _mesa_error(ctx, GL_INVALID_VALUE,
230 _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
244 _mesa_new_buffer_object( struct gl_context *ctx, GLuint name, GLenum target )
248 (void) ctx;
251 _mesa_initialize_buffer_object(ctx, obj, name, target);
262 _mesa_delete_buffer_object(struct gl_context *ctx,
265 (void) ctx;
286 _mesa_reference_buffer_object_(struct gl_context *ctx,
310 ASSERT(ctx->Array.ArrayBufferObj != bufObj);
311 ASSERT(ctx->Array.ArrayObj->ElementArrayBufferObj != bufObj);
312 ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj);
315 ASSERT(ctx->Driver.DeleteBuffer);
316 ctx->Driver.DeleteBuffer(ctx, oldObj);
349 _mesa_initialize_buffer_object( struct gl_context *ctx,
360 obj->AccessFlags = default_access_mode(ctx);
384 _mesa_total_buffer_object_memory(struct gl_context *ctx)
388 _mesa_HashWalk(ctx->Shared->BufferObjects, count_buffer_size, &total);
402 * \param ctx GL context.
414 _mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
420 (void) ctx; (void) target;
448 * \param ctx GL context.
458 _mesa_buffer_subdata( struct gl_context *ctx, GLintptrARB offset,
462 (void) ctx;
481 * \param ctx GL context.
491 _mesa_buffer_get_subdata( struct gl_context *ctx, GLintptrARB offset,
495 (void) ctx;
508 _mesa_buffer_map_range( struct gl_context *ctx, GLintptr offset,
512 (void) ctx;
528 _mesa_buffer_flush_mapped_range( struct gl_context *ctx,
532 (void) ctx;
548 _mesa_buffer_unmap( struct gl_context *ctx, struct gl_buffer_object *bufObj )
550 (void) ctx;
565 _mesa_copy_buffer_subdata(struct gl_context *ctx,
578 srcPtr = dstPtr = ctx->Driver.MapBufferRange(ctx, 0, src->Size,
588 srcPtr = ctx->Driver.MapBufferRange(ctx, readOffset, size,
590 dstPtr = ctx->Driver.MapBufferRange(ctx, writeOffset, size,
601 ctx->Driver.UnmapBuffer(ctx, src);
603 ctx->Driver.UnmapBuffer(ctx, dst);
612 _mesa_init_buffer_objects( struct gl_context *ctx )
620 _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj,
621 ctx->Shared->NullBufferObj);
623 _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer,
624 ctx->Shared->NullBufferObj);
625 _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer,
626 ctx->Shared->NullBufferObj);
628 ctx->UniformBufferBindings = calloc(ctx->Const.MaxUniformBufferBindings,
629 sizeof(*ctx->UniformBufferBindings));
631 _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer,
632 ctx->Shared->NullBufferObj);
634 for (i = 0; i < ctx->Const.MaxUniformBufferBindings; i++) {
635 _mesa_reference_buffer_object(ctx,
636 &ctx->UniformBufferBindings[i].BufferObject,
637 ctx->Shared->NullBufferObj);
638 ctx->UniformBufferBindings[i].Offset = -1;
639 ctx->UniformBufferBindings[i].Size = -1;
645 _mesa_free_buffer_objects( struct gl_context *ctx )
649 _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL);
651 _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer, NULL);
652 _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer, NULL);
654 _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, NULL);
656 for (i = 0; i < ctx->Const.MaxUniformBufferBindings; i++) {
657 _mesa_reference_buffer_object(ctx,
658 &ctx->UniformBufferBindings[i].BufferObject,
662 free(ctx->UniformBufferBindings);
663 ctx->UniformBufferBindings = NULL;
667 handle_bind_buffer_gen(struct gl_context *ctx,
674 if (!buf && ctx->API == API_OPENGL_CORE) {
675 _mesa_error(ctx, GL_INVALID_OPERATION, "glBindBuffer(non-gen name)");
683 ASSERT(ctx->Driver.NewBufferObject);
684 buf = ctx->Driver.NewBufferObject(ctx, buffer, target);
686 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
689 _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, buf);
701 bind_buffer_object(struct gl_context *ctx, GLenum target, GLuint buffer)
707 bindTarget = get_buffer_target(ctx, target);
709 _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)", target);
725 newBufObj = ctx->Shared->NullBufferObj;
729 newBufObj = _mesa_lookup_bufferobj(ctx, buffer);
730 if (!handle_bind_buffer_gen(ctx, target, buffer, &newBufObj))
735 _mesa_reference_buffer_object(ctx, bindTarget, newBufObj);
738 if (ctx->Driver.BindBuffer)
739 ctx->Driver.BindBuffer( ctx, target, newBufObj );
749 _mesa_update_default_objects_buffer_objects(struct gl_context *ctx)
754 bind_buffer_object( ctx, GL_ARRAY_BUFFER_ARB, 0);
755 bind_buffer_object( ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
756 bind_buffer_object( ctx, GL_PIXEL_PACK_BUFFER_ARB, 0);
757 bind_buffer_object( ctx, GL_PIXEL_UNPACK_BUFFER_ARB, 0);
767 _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer)
773 _mesa_HashLookup(ctx->Shared->BufferObjects, buffer);
784 unbind(struct gl_context *ctx,
789 _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj);
827 GET_CURRENT_CONTEXT(ctx);
828 ASSERT_OUTSIDE_BEGIN_END(ctx);
831 _mesa_debug(ctx, "glBindBuffer(%s, %u)\n",
834 bind_buffer_object(ctx, target, buffer);
847 GET_CURRENT_CONTEXT(ctx);
849 ASSERT_OUTSIDE_BEGIN_END(ctx);
850 FLUSH_VERTICES(ctx, 0);
853 _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteBuffersARB(n)");
857 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
860 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, ids[i]);
862 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
869 ctx->Driver.UnmapBuffer(ctx, bufObj);
870 bufObj->AccessFlags = default_access_mode(ctx);
876 unbind(ctx, &arrayObj->VertexAttrib[j].BufferObj, bufObj);
879 if (ctx->Array.ArrayBufferObj == bufObj) {
887 if (ctx->CopyReadBuffer == bufObj) {
890 if (ctx->CopyWriteBuffer == bufObj) {
895 if (ctx->TransformFeedback.CurrentBuffer == bufObj) {
899 if (ctx->TransformFeedback.CurrentObject->Buffers[j] == bufObj) {
905 for (j = 0; j < ctx->Const.MaxUniformBufferBindings; j++) {
906 if (ctx->UniformBufferBindings[j].BufferObject == bufObj) {
911 if (ctx->UniformBuffer == bufObj) {
916 if (ctx->Pack.BufferObj == bufObj) {
919 if (ctx->Unpack.BufferObj == bufObj) {
923 if (ctx->Texture.BufferObject == bufObj) {
928 _mesa_HashRemove(ctx->Shared->BufferObjects, ids[i]);
940 _mesa_reference_buffer_object(ctx, &bufObj, NULL);
944 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
957 GET_CURRENT_CONTEXT(ctx);
960 ASSERT_OUTSIDE_BEGIN_END(ctx);
963 _mesa_debug(ctx, "glGenBuffers(%d)\n", n);
966 _mesa_error(ctx, GL_INVALID_VALUE, "glGenBuffersARB");
977 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
979 first = _mesa_HashFindFreeKeyBlock(ctx->Shared->BufferObjects, n);
983 _mesa_HashInsert(ctx->Shared->BufferObjects, first + i,
988 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
1003 GET_CURRENT_CONTEXT(ctx);
1004 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
1006 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
1007 bufObj = _mesa_lookup_bufferobj(ctx, id);
1008 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
1018 GET_CURRENT_CONTEXT(ctx);
1021 ASSERT_OUTSIDE_BEGIN_END(ctx);
1024 _mesa_debug(ctx, "glBufferData(%s, %ld, %p, %s)\n",
1030 _mesa_error(ctx, GL_INVALID_VALUE, "glBufferDataARB(size < 0)");
1036 valid_usage = (ctx->API != API_OPENGLES);
1050 valid_usage = _mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx);
1059 _mesa_error(ctx, GL_INVALID_ENUM, "glBufferData(usage)");
1063 bufObj = get_buffer(ctx, "glBufferDataARB", target);
1069 ctx->Driver.UnmapBuffer(ctx, bufObj);
1070 bufObj->AccessFlags = default_access_mode(ctx);
1074 FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
1087 ASSERT(ctx->Driver.BufferData);
1088 if (!ctx->Driver.BufferData( ctx, target, size, data, usage, bufObj )) {
1089 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB()");
1098 GET_CURRENT_CONTEXT(ctx);
1100 ASSERT_OUTSIDE_BEGIN_END(ctx);
1102 bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
1114 ASSERT(ctx->Driver.BufferSubData);
1115 ctx->Driver.BufferSubData( ctx, offset, size, data, bufObj );
1123 GET_CURRENT_CONTEXT(ctx);
1125 ASSERT_OUTSIDE_BEGIN_END(ctx);
1127 bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
1134 ASSERT(ctx->Driver.GetBufferSubData);
1135 ctx->Driver.GetBufferSubData( ctx, offset, size, data, bufObj );
1142 GET_CURRENT_CONTEXT(ctx);
1148 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
1153 valid_access = _mesa_is_desktop_gl(ctx);
1161 valid_access = _mesa_is_desktop_gl(ctx);
1169 _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)");
1173 bufObj = get_buffer(ctx, "glMapBufferARB", target);
1178 _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(already mapped)");
1183 _mesa_error(ctx, GL_OUT_OF_MEMORY,
1188 ASSERT(ctx->Driver.MapBufferRange);
1189 map = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size, accessFlags, bufObj);
1191 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)");
1237 GET_CURRENT_CONTEXT(ctx);
1240 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
1242 bufObj = get_buffer(ctx, "glUnmapBufferARB", target);
1247 _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB");
1259 _mesa_warning(ctx, "Out of bounds buffer object write detected"
1287 status = ctx->Driver.UnmapBuffer( ctx, bufObj );
1288 bufObj->AccessFlags = default_access_mode(ctx);
1300 GET_CURRENT_CONTEXT(ctx);
1302 ASSERT_OUTSIDE_BEGIN_END(ctx);
1304 bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target);
1322 if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_map_buffer_range)
1323 && !_mesa_is_gles3(ctx))
1328 if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_map_buffer_range)
1329 && !_mesa_is_gles3(ctx))
1334 if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_map_buffer_range)
1335 && !_mesa_is_gles3(ctx))
1344 _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname=%s)",
1357 GET_CURRENT_CONTEXT(ctx);
1359 ASSERT_OUTSIDE_BEGIN_END(ctx);
1361 bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target);
1376 if (!ctx->Extensions.ARB_map_buffer_range)
1384 if (!ctx->Extensions.ARB_map_buffer_range)
1389 if (!ctx->Extensions.ARB_map_buffer_range)
1398 _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname=%s)",
1406 GET_CURRENT_CONTEXT(ctx);
1408 ASSERT_OUTSIDE_BEGIN_END(ctx);
1411 _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)");
1415 bufObj = get_buffer(ctx, "glGetBufferPointervARB", target);
1428 GET_CURRENT_CONTEXT(ctx);
1430 ASSERT_OUTSIDE_BEGIN_END(ctx);
1432 src = get_buffer(ctx, "glCopyBufferSubData", readTarget);
1436 dst = get_buffer(ctx, "glCopyBufferSubData", writeTarget);
1441 _mesa_error(ctx, GL_INVALID_OPERATION,
1447 _mesa_error(ctx, GL_INVALID_OPERATION,
1453 _mesa_error(ctx, GL_INVALID_VALUE,
1459 _mesa_error(ctx, GL_INVALID_VALUE,
1465 _mesa_error(ctx, GL_INVALID_VALUE,
1471 _mesa_error(ctx, GL_INVALID_VALUE,
1478 _mesa_error(ctx, GL_INVALID_VALUE,
1493 _mesa_error(ctx, GL_INVALID_VALUE,
1499 ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset, size);
1510 GET_CURRENT_CONTEXT(ctx);
1514 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
1516 if (!ctx->Extensions.ARB_map_buffer_range) {
1517 _mesa_error(ctx, GL_INVALID_OPERATION,
1523 _mesa_error(ctx, GL_INVALID_VALUE,
1529 _mesa_error(ctx, GL_INVALID_VALUE,
1541 _mesa_error(ctx, GL_INVALID_VALUE, "glMapBufferRange(access)");
1546 _mesa_error(ctx, GL_INVALID_OPERATION,
1555 _mesa_error(ctx, GL_INVALID_OPERATION,
1562 _mesa_error(ctx, GL_INVALID_OPERATION,
1567 bufObj = get_buffer(ctx, "glMapBufferRange", target);
1572 _mesa_error(ctx, GL_INVALID_VALUE,
1578 _mesa_error(ctx, GL_INVALID_OPERATION,
1584 _mesa_error(ctx, GL_OUT_OF_MEMORY,
1599 ASSERT(ctx->Driver.MapBufferRange);
1600 map = ctx->Driver.MapBufferRange(ctx, offset, length, access, bufObj);
1602 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)");
1625 GET_CURRENT_CONTEXT(ctx);
1627 ASSERT_OUTSIDE_BEGIN_END(ctx);
1629 if (!ctx->Extensions.ARB_map_buffer_range) {
1630 _mesa_error(ctx, GL_INVALID_OPERATION,
1636 _mesa_error(ctx, GL_INVALID_VALUE,
1642 _mesa_error(ctx, GL_INVALID_VALUE,
1647 bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target);
1653 _mesa_error(ctx, GL_INVALID_OPERATION,
1659 _mesa_error(ctx, GL_INVALID_OPERATION,
1665 _mesa_error(ctx, GL_INVALID_VALUE,
1673 if (ctx->Driver.FlushMappedBufferRange)
1674 ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj);
1680 buffer_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option)
1685 bufObj = _mesa_lookup_bufferobj(ctx, name);
1687 _mesa_error(ctx, GL_INVALID_VALUE,
1692 _mesa_error(ctx, GL_INVALID_OPERATION, "glObjectPurgeable(buffer 0)" );
1697 _mesa_error(ctx, GL_INVALID_OPERATION,
1705 if (ctx->Driver.BufferObjectPurgeable)
1706 retval = ctx->Driver.BufferObjectPurgeable(ctx
1713 renderbuffer_purgeable(struct gl_context *ctx, GLuint name, GLenum option)
1718 bufObj = _mesa_lookup_renderbuffer(ctx, name);
1720 _mesa_error(ctx, GL_INVALID_VALUE,
1726 _mesa_error(ctx, GL_INVALID_OPERATION,
1734 if (ctx->Driver.RenderObjectPurgeable)
1735 retval = ctx->Driver.RenderObjectPurgeable(ctx, bufObj, option);
1742 texture_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option)
1747 bufObj = _mesa_lookup_texture(ctx, name);
1749 _mesa_error(ctx, GL_INVALID_VALUE,
1755 _mesa_error(ctx, GL_INVALID_OPERATION,
1763 if (ctx->Driver.TextureObjectPurgeable)
1764 retval = ctx->Driver.TextureObjectPurgeable(ctx, bufObj, option);
1775 GET_CURRENT_CONTEXT(ctx);
1776 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
1779 _mesa_error(ctx, GL_INVALID_VALUE,
1790 _mesa_error(ctx, GL_INVALID_ENUM,
1798 retval = texture_object_purgeable(ctx, name, option);
1801 retval = renderbuffer_purgeable(ctx, name, option);
1804 retval = buffer_object_purgeable(ctx, name, option);
1807 _mesa_error(ctx, GL_INVALID_ENUM,
1823 buffer_object_unpurgeable(struct gl_context *ctx, GLuint name, GLenum option)
1828 bufObj = _mesa_lookup_bufferobj(ctx, name);
1830 _mesa_error(ctx, GL_INVALID_VALUE,
1836 _mesa_error(ctx, GL_INVALID_OPERATION,
1845 if (ctx->Driver.BufferObjectUnpurgeable)
1846 retval = ctx->Driver.BufferObjectUnpurgeable(ctx, bufObj, option);
1853 renderbuffer_unpurgeable(struct gl_context *ctx, GLuint name, GLenum option)
1858 bufObj = _mesa_lookup_renderbuffer(ctx, name);
1860 _mesa_error(ctx, GL_INVALID_VALUE,
1866 _mesa_error(ctx, GL_INVALID_OPERATION,
1875 if (ctx->Driver.RenderObjectUnpurgeable)
1876 retval = ctx->Driver.RenderObjectUnpurgeable(ctx, bufObj, option);
1883 texture_object_unpurgeable(struct gl_context *ctx, GLuint name, GLenum option)
1888 bufObj = _mesa_lookup_texture(ctx, name);
1890 _mesa_error(ctx, GL_INVALID_VALUE,
1896 _mesa_error(ctx, GL_INVALID_OPERATION,
1905 if (ctx->Driver.TextureObjectUnpurgeable)
1906 retval = ctx->Driver.TextureObjectUnpurgeable(ctx, bufObj, option);
1915 GET_CURRENT_CONTEXT(ctx);
1916 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
1919 _mesa_error(ctx, GL_INVALID_VALUE,
1930 _mesa_error(ctx, GL_INVALID_ENUM,
1938 return buffer_object_unpurgeable(ctx, name, option);
1940 return texture_object_unpurgeable(ctx, name, option);
1942 return renderbuffer_unpurgeable(ctx, name, option);
1944 _mesa_error(ctx, GL_INVALID_ENUM,
1953 get_buffer_object_parameteriv(struct gl_context *ctx, GLuint name,
1956 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, name);
1958 _mesa_error(ctx, GL_INVALID_VALUE,
1968 _mesa_error(ctx, GL_INVALID_ENUM,
1977 get_renderbuffer_parameteriv(struct gl_context *ctx, GLuint name,
1980 struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, name);
1982 _mesa_error(ctx, GL_INVALID_VALUE,
1992 _mesa_error(ctx, GL_INVALID_ENUM,
2001 get_texture_object_parameteriv(struct gl_context *ctx, GLuint name,
2004 struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, name);
2006 _mesa_error(ctx, GL_INVALID_VALUE,
2016 _mesa_error(ctx, GL_INVALID_ENUM,
2028 GET_CURRENT_CONTEXT(ctx);
2031 _mesa_error(ctx, GL_INVALID_VALUE,
2038 get_texture_object_parameteriv(ctx, name, pname, params);
2041 get_buffer_object_parameteriv(ctx, name, pname, params);
2044 get_renderbuffer_parameteriv(ctx, name, pname, params);
2047 _mesa_error(ctx, GL_INVALID_ENUM,
2056 set_ubo_binding(struct gl_context *ctx,
2065 binding = &ctx->UniformBufferBindings[index];
2073 FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
2075 _mesa_reference_buffer_object(ctx, &binding->BufferObject, bufObj);
2089 bind_buffer_range_uniform_buffer(struct gl_context *ctx,
2095 if (index >= ctx->Const.MaxUniformBufferBindings) {
2096 _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d)", index);
2100 if (offset & (ctx->Const.UniformBufferOffsetAlignment - 1)) {
2101 _mesa_error(ctx, GL_INVALID_VALUE,
2103 ctx->Const.UniformBufferOffsetAlignment);
2107 if (bufObj == ctx->Shared->NullBufferObj) {
2112 _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj);
2113 set_ubo_binding(ctx, index, bufObj, offset, size, GL_FALSE);
2122 bind_buffer_base_uniform_buffer(struct gl_context *ctx,
2126 if (index >= ctx->Const.MaxUniformBufferBindings) {
2127 _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index);
2131 _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, bufObj);
2132 if (bufObj == ctx->Shared->NullBufferObj)
2133 set_ubo_binding(ctx, index, bufObj, -1, -1, GL_TRUE);
2135 set_ubo_binding(ctx, index, bufObj, 0, 0, GL_TRUE);
2142 GET_CURRENT_CONTEXT(ctx);
2146 bufObj = ctx->Shared->NullBufferObj;
2148 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2150 if (!handle_bind_buffer_gen(ctx, target, buffer, &bufObj))
2154 _mesa_error(ctx, GL_INVALID_OPERATION,
2160 _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)",
2166 _mesa_error(ctx, GL_INVALID_VALUE,
2174 _mesa_bind_buffer_range_transform_feedback(ctx, index, bufObj,
2178 bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size);
2181 _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)");
2189 GET_CURRENT_CONTEXT(ctx);
2193 bufObj = ctx->Shared->NullBufferObj;
2195 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2197 if (!handle_bind_buffer_gen(ctx, target, buffer, &bufObj))
2201 _mesa_error(ctx, GL_INVALID_OPERATION,
2234 _mesa_bind_buffer_base_transform_feedback(ctx, index, bufObj);
2237 bind_buffer_base_uniform_buffer(ctx, index, bufObj);
2240 _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferBase(target)");
2249 GET_CURRENT_CONTEXT(ctx);
2253 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2255 _mesa_error(ctx, GL_INVALID_VALUE,
2268 _mesa_error(ctx, GL_INVALID_VALUE,
2291 _mesa_error(ctx, GL_INVALID_OPERATION,
2307 GET_CURRENT_CONTEXT(ctx);
2310 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2312 _mesa_error(ctx, GL_INVALID_VALUE,
2325 _mesa_error(ctx, GL_INVALID_OPERATION,
2338 _mesa_init_bufferobj_dispatch(struct gl_context *ctx, struct _glapi_table *disp)
2347 if (ctx->API != API_OPENGLES2) {
2354 if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) {
2359 if (_mesa_is_desktop_gl(ctx)) {