2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * \brief Functions for the GL_ARB_vertex/pixel_buffer_object extensions.
30 * \author Brian Paul, Ian Romanick
40 #include "bufferobj.h"
42 #include "mfeatures.h"
45 #include "transformfeedback.h"
51 /*#define BOUNDS_CHECK*/
55 * Used as a placeholder for buffer objects between glGenBuffers() and
56 * glBindBuffer() so that glIsBuffer() can work correctly.
58 static struct gl_buffer_object DummyBufferObject
;
62 * Return pointer to address of a buffer object target.
63 * \param ctx the GL context
64 * \param target the buffer object target to be retrieved.
65 * \return pointer to pointer to the buffer object bound to \c target in the
66 * specified context or \c NULL if \c target is invalid.
68 static inline struct gl_buffer_object
**
69 get_buffer_target(struct gl_context
*ctx
, GLenum target
)
71 /* Other targets are only supported in desktop OpenGL and OpenGL ES 3.0.
73 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
)
74 && target
!= GL_ARRAY_BUFFER
&& target
!= GL_ELEMENT_ARRAY_BUFFER
)
78 case GL_ARRAY_BUFFER_ARB
:
79 return &ctx
->Array
.ArrayBufferObj
;
80 case GL_ELEMENT_ARRAY_BUFFER_ARB
:
81 return &ctx
->Array
.ArrayObj
->ElementArrayBufferObj
;
82 case GL_PIXEL_PACK_BUFFER_EXT
:
83 return &ctx
->Pack
.BufferObj
;
84 case GL_PIXEL_UNPACK_BUFFER_EXT
:
85 return &ctx
->Unpack
.BufferObj
;
86 case GL_COPY_READ_BUFFER
:
87 return &ctx
->CopyReadBuffer
;
88 case GL_COPY_WRITE_BUFFER
:
89 return &ctx
->CopyWriteBuffer
;
90 case GL_TRANSFORM_FEEDBACK_BUFFER
:
91 if (ctx
->Extensions
.EXT_transform_feedback
) {
92 return &ctx
->TransformFeedback
.CurrentBuffer
;
95 case GL_TEXTURE_BUFFER
:
96 if (ctx
->API
== API_OPENGL_CORE
&&
97 ctx
->Extensions
.ARB_texture_buffer_object
) {
98 return &ctx
->Texture
.BufferObject
;
101 case GL_UNIFORM_BUFFER
:
102 if (ctx
->Extensions
.ARB_uniform_buffer_object
) {
103 return &ctx
->UniformBuffer
;
114 * Get the buffer object bound to the specified target in a GL context.
115 * \param ctx the GL context
116 * \param target the buffer object target to be retrieved.
117 * \return pointer to the buffer object bound to \c target in the
118 * specified context or \c NULL if \c target is invalid.
120 static inline struct gl_buffer_object
*
121 get_buffer(struct gl_context
*ctx
, const char *func
, GLenum target
)
123 struct gl_buffer_object
**bufObj
= get_buffer_target(ctx
, target
);
126 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(target)", func
);
130 if (!_mesa_is_bufferobj(*bufObj
)) {
131 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(buffer 0)", func
);
140 * Convert a GLbitfield describing the mapped buffer access flags
141 * into one of GL_READ_WRITE, GL_READ_ONLY, or GL_WRITE_ONLY.
144 simplified_access_mode(struct gl_context
*ctx
, GLbitfield access
)
146 const GLbitfield rwFlags
= GL_MAP_READ_BIT
| GL_MAP_WRITE_BIT
;
147 if ((access
& rwFlags
) == rwFlags
)
148 return GL_READ_WRITE
;
149 if ((access
& GL_MAP_READ_BIT
) == GL_MAP_READ_BIT
)
151 if ((access
& GL_MAP_WRITE_BIT
) == GL_MAP_WRITE_BIT
)
152 return GL_WRITE_ONLY
;
154 /* Otherwise, AccessFlags is zero (the default state).
156 * Table 2.6 on page 31 (page 44 of the PDF) of the OpenGL 1.5 spec says:
158 * Name Type Initial Value Legal Values
160 * BUFFER_ACCESS enum READ_WRITE READ_ONLY, WRITE_ONLY
163 * However, table 6.8 in the GL_OES_mapbuffer extension says:
165 * Get Value Type Get Command Value Description
166 * --------- ---- ----------- ----- -----------
167 * BUFFER_ACCESS_OES Z1 GetBufferParameteriv WRITE_ONLY_OES buffer map flag
169 * The difference is because GL_OES_mapbuffer only supports mapping buffers
174 return _mesa_is_gles(ctx
) ? GL_WRITE_ONLY
: GL_READ_WRITE
;
179 * Tests the subdata range parameters and sets the GL error code for
180 * \c glBufferSubDataARB and \c glGetBufferSubDataARB.
182 * \param ctx GL context.
183 * \param target Buffer object target on which to operate.
184 * \param offset Offset of the first byte of the subdata range.
185 * \param size Size, in bytes, of the subdata range.
186 * \param caller Name of calling function for recording errors.
187 * \return A pointer to the buffer object bound to \c target in the
188 * specified context or \c NULL if any of the parameter or state
189 * conditions for \c glBufferSubDataARB or \c glGetBufferSubDataARB
192 * \sa glBufferSubDataARB, glGetBufferSubDataARB
194 static struct gl_buffer_object
*
195 buffer_object_subdata_range_good( struct gl_context
* ctx
, GLenum target
,
196 GLintptrARB offset
, GLsizeiptrARB size
,
199 struct gl_buffer_object
*bufObj
;
202 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(size < 0)", caller
);
207 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(offset < 0)", caller
);
211 bufObj
= get_buffer(ctx
, caller
, target
);
215 if (offset
+ size
> bufObj
->Size
) {
216 _mesa_error(ctx
, GL_INVALID_VALUE
,
217 "%s(offset %lu + size %lu > buffer size %lu)", caller
,
218 (unsigned long) offset
,
219 (unsigned long) size
,
220 (unsigned long) bufObj
->Size
);
223 if (_mesa_bufferobj_mapped(bufObj
)) {
224 /* Buffer is currently mapped */
225 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s", caller
);
234 * Allocate and initialize a new buffer object.
236 * Default callback for the \c dd_function_table::NewBufferObject() hook.
238 static struct gl_buffer_object
*
239 _mesa_new_buffer_object( struct gl_context
*ctx
, GLuint name
, GLenum target
)
241 struct gl_buffer_object
*obj
;
245 obj
= MALLOC_STRUCT(gl_buffer_object
);
246 _mesa_initialize_buffer_object(ctx
, obj
, name
, target
);
252 * Delete a buffer object.
254 * Default callback for the \c dd_function_table::DeleteBuffer() hook.
257 _mesa_delete_buffer_object(struct gl_context
*ctx
,
258 struct gl_buffer_object
*bufObj
)
264 /* assign strange values here to help w/ debugging */
265 bufObj
->RefCount
= -1000;
268 _glthread_DESTROY_MUTEX(bufObj
->Mutex
);
275 * Set ptr to bufObj w/ reference counting.
276 * This is normally only called from the _mesa_reference_buffer_object() macro
277 * when there's a real pointer change.
280 _mesa_reference_buffer_object_(struct gl_context
*ctx
,
281 struct gl_buffer_object
**ptr
,
282 struct gl_buffer_object
*bufObj
)
285 /* Unreference the old buffer */
286 GLboolean deleteFlag
= GL_FALSE
;
287 struct gl_buffer_object
*oldObj
= *ptr
;
289 _glthread_LOCK_MUTEX(oldObj
->Mutex
);
290 ASSERT(oldObj
->RefCount
> 0);
293 printf("BufferObj %p %d DECR to %d\n",
294 (void *) oldObj
, oldObj
->Name
, oldObj
->RefCount
);
296 deleteFlag
= (oldObj
->RefCount
== 0);
297 _glthread_UNLOCK_MUTEX(oldObj
->Mutex
);
301 /* some sanity checking: don't delete a buffer still in use */
303 /* unfortunately, these tests are invalid during context tear-down */
304 ASSERT(ctx
->Array
.ArrayBufferObj
!= bufObj
);
305 ASSERT(ctx
->Array
.ArrayObj
->ElementArrayBufferObj
!= bufObj
);
306 ASSERT(ctx
->Array
.ArrayObj
->Vertex
.BufferObj
!= bufObj
);
309 ASSERT(ctx
->Driver
.DeleteBuffer
);
310 ctx
->Driver
.DeleteBuffer(ctx
, oldObj
);
318 /* reference new buffer */
319 _glthread_LOCK_MUTEX(bufObj
->Mutex
);
320 if (bufObj
->RefCount
== 0) {
321 /* this buffer's being deleted (look just above) */
322 /* Not sure this can every really happen. Warn if it does. */
323 _mesa_problem(NULL
, "referencing deleted buffer object");
329 printf("BufferObj %p %d INCR to %d\n",
330 (void *) bufObj
, bufObj
->Name
, bufObj
->RefCount
);
334 _glthread_UNLOCK_MUTEX(bufObj
->Mutex
);
340 * Initialize a buffer object to default values.
343 _mesa_initialize_buffer_object( struct gl_context
*ctx
,
344 struct gl_buffer_object
*obj
,
345 GLuint name
, GLenum target
)
349 memset(obj
, 0, sizeof(struct gl_buffer_object
));
350 _glthread_INIT_MUTEX(obj
->Mutex
);
353 obj
->Usage
= GL_STATIC_DRAW_ARB
;
354 obj
->AccessFlags
= 0;
360 * Callback called from _mesa_HashWalk()
363 count_buffer_size(GLuint key
, void *data
, void *userData
)
365 const struct gl_buffer_object
*bufObj
=
366 (const struct gl_buffer_object
*) data
;
367 GLuint
*total
= (GLuint
*) userData
;
369 *total
= *total
+ bufObj
->Size
;
374 * Compute total size (in bytes) of all buffer objects for the given context.
375 * For debugging purposes.
378 _mesa_total_buffer_object_memory(struct gl_context
*ctx
)
382 _mesa_HashWalk(ctx
->Shared
->BufferObjects
, count_buffer_size
, &total
);
389 * Allocate space for and store data in a buffer object. Any data that was
390 * previously stored in the buffer object is lost. If \c data is \c NULL,
391 * memory will be allocated, but no copy will occur.
393 * This is the default callback for \c dd_function_table::BufferData()
394 * Note that all GL error checking will have been done already.
396 * \param ctx GL context.
397 * \param target Buffer object target on which to operate.
398 * \param size Size, in bytes, of the new data store.
399 * \param data Pointer to the data to store in the buffer object. This
400 * pointer may be \c NULL.
401 * \param usage Hints about how the data will be used.
402 * \param bufObj Object to be used.
404 * \return GL_TRUE for success, GL_FALSE for failure
405 * \sa glBufferDataARB, dd_function_table::BufferData.
408 _mesa_buffer_data( struct gl_context
*ctx
, GLenum target
, GLsizeiptrARB size
,
409 const GLvoid
* data
, GLenum usage
,
410 struct gl_buffer_object
* bufObj
)
414 (void) ctx
; (void) target
;
416 new_data
= _mesa_realloc( bufObj
->Data
, bufObj
->Size
, size
);
418 bufObj
->Data
= (GLubyte
*) new_data
;
420 bufObj
->Usage
= usage
;
423 memcpy( bufObj
->Data
, data
, size
);
435 * Replace data in a subrange of buffer object. If the data range
436 * specified by \c size + \c offset extends beyond the end of the buffer or
437 * if \c data is \c NULL, no copy is performed.
439 * This is the default callback for \c dd_function_table::BufferSubData()
440 * Note that all GL error checking will have been done already.
442 * \param ctx GL context.
443 * \param target Buffer object target on which to operate.
444 * \param offset Offset of the first byte to be modified.
445 * \param size Size, in bytes, of the data range.
446 * \param data Pointer to the data to store in the buffer object.
447 * \param bufObj Object to be used.
449 * \sa glBufferSubDataARB, dd_function_table::BufferSubData.
452 _mesa_buffer_subdata( struct gl_context
*ctx
, GLintptrARB offset
,
453 GLsizeiptrARB size
, const GLvoid
* data
,
454 struct gl_buffer_object
* bufObj
)
458 /* this should have been caught in _mesa_BufferSubData() */
459 ASSERT(size
+ offset
<= bufObj
->Size
);
462 memcpy( (GLubyte
*) bufObj
->Data
+ offset
, data
, size
);
468 * Retrieve data from a subrange of buffer object. If the data range
469 * specified by \c size + \c offset extends beyond the end of the buffer or
470 * if \c data is \c NULL, no copy is performed.
472 * This is the default callback for \c dd_function_table::GetBufferSubData()
473 * Note that all GL error checking will have been done already.
475 * \param ctx GL context.
476 * \param target Buffer object target on which to operate.
477 * \param offset Offset of the first byte to be fetched.
478 * \param size Size, in bytes, of the data range.
479 * \param data Destination for data
480 * \param bufObj Object to be used.
482 * \sa glBufferGetSubDataARB, dd_function_table::GetBufferSubData.
485 _mesa_buffer_get_subdata( struct gl_context
*ctx
, GLintptrARB offset
,
486 GLsizeiptrARB size
, GLvoid
* data
,
487 struct gl_buffer_object
* bufObj
)
491 if (bufObj
->Data
&& ((GLsizeiptrARB
) (size
+ offset
) <= bufObj
->Size
)) {
492 memcpy( data
, (GLubyte
*) bufObj
->Data
+ offset
, size
);
498 * Default fallback for \c dd_function_table::MapBufferRange().
499 * Called via glMapBufferRange().
502 _mesa_buffer_map_range( struct gl_context
*ctx
, GLintptr offset
,
503 GLsizeiptr length
, GLbitfield access
,
504 struct gl_buffer_object
*bufObj
)
507 assert(!_mesa_bufferobj_mapped(bufObj
));
508 /* Just return a direct pointer to the data */
509 bufObj
->Pointer
= bufObj
->Data
+ offset
;
510 bufObj
->Length
= length
;
511 bufObj
->Offset
= offset
;
512 bufObj
->AccessFlags
= access
;
513 return bufObj
->Pointer
;
518 * Default fallback for \c dd_function_table::FlushMappedBufferRange().
519 * Called via glFlushMappedBufferRange().
522 _mesa_buffer_flush_mapped_range( struct gl_context
*ctx
,
523 GLintptr offset
, GLsizeiptr length
,
524 struct gl_buffer_object
*obj
)
535 * Default callback for \c dd_function_table::MapBuffer().
537 * The input parameters will have been already tested for errors.
539 * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer
542 _mesa_buffer_unmap( struct gl_context
*ctx
, struct gl_buffer_object
*bufObj
)
545 /* XXX we might assert here that bufObj->Pointer is non-null */
546 bufObj
->Pointer
= NULL
;
549 bufObj
->AccessFlags
= 0x0;
555 * Default fallback for \c dd_function_table::CopyBufferSubData().
556 * Called via glCopyBufferSubData().
559 _mesa_copy_buffer_subdata(struct gl_context
*ctx
,
560 struct gl_buffer_object
*src
,
561 struct gl_buffer_object
*dst
,
562 GLintptr readOffset
, GLintptr writeOffset
,
565 GLubyte
*srcPtr
, *dstPtr
;
567 /* the buffers should not be mapped */
568 assert(!_mesa_bufferobj_mapped(src
));
569 assert(!_mesa_bufferobj_mapped(dst
));
572 srcPtr
= dstPtr
= ctx
->Driver
.MapBufferRange(ctx
, 0, src
->Size
,
574 GL_MAP_WRITE_BIT
, src
);
579 srcPtr
+= readOffset
;
580 dstPtr
+= writeOffset
;
582 srcPtr
= ctx
->Driver
.MapBufferRange(ctx
, readOffset
, size
,
583 GL_MAP_READ_BIT
, src
);
584 dstPtr
= ctx
->Driver
.MapBufferRange(ctx
, writeOffset
, size
,
586 GL_MAP_INVALIDATE_RANGE_BIT
), dst
);
589 /* Note: the src and dst regions will never overlap. Trying to do so
590 * would generate GL_INVALID_VALUE earlier.
592 if (srcPtr
&& dstPtr
)
593 memcpy(dstPtr
, srcPtr
, size
);
595 ctx
->Driver
.UnmapBuffer(ctx
, src
);
597 ctx
->Driver
.UnmapBuffer(ctx
, dst
);
603 * Initialize the state associated with buffer objects
606 _mesa_init_buffer_objects( struct gl_context
*ctx
)
610 memset(&DummyBufferObject
, 0, sizeof(DummyBufferObject
));
611 _glthread_INIT_MUTEX(DummyBufferObject
.Mutex
);
612 DummyBufferObject
.RefCount
= 1000*1000*1000; /* never delete */
614 _mesa_reference_buffer_object(ctx
, &ctx
->Array
.ArrayBufferObj
,
615 ctx
->Shared
->NullBufferObj
);
617 _mesa_reference_buffer_object(ctx
, &ctx
->CopyReadBuffer
,
618 ctx
->Shared
->NullBufferObj
);
619 _mesa_reference_buffer_object(ctx
, &ctx
->CopyWriteBuffer
,
620 ctx
->Shared
->NullBufferObj
);
622 ctx
->UniformBufferBindings
= calloc(ctx
->Const
.MaxUniformBufferBindings
,
623 sizeof(*ctx
->UniformBufferBindings
));
625 _mesa_reference_buffer_object(ctx
, &ctx
->UniformBuffer
,
626 ctx
->Shared
->NullBufferObj
);
628 for (i
= 0; i
< ctx
->Const
.MaxUniformBufferBindings
; i
++) {
629 _mesa_reference_buffer_object(ctx
,
630 &ctx
->UniformBufferBindings
[i
].BufferObject
,
631 ctx
->Shared
->NullBufferObj
);
632 ctx
->UniformBufferBindings
[i
].Offset
= -1;
633 ctx
->UniformBufferBindings
[i
].Size
= -1;
639 _mesa_free_buffer_objects( struct gl_context
*ctx
)
643 _mesa_reference_buffer_object(ctx
, &ctx
->Array
.ArrayBufferObj
, NULL
);
645 _mesa_reference_buffer_object(ctx
, &ctx
->CopyReadBuffer
, NULL
);
646 _mesa_reference_buffer_object(ctx
, &ctx
->CopyWriteBuffer
, NULL
);
648 _mesa_reference_buffer_object(ctx
, &ctx
->UniformBuffer
, NULL
);
650 for (i
= 0; i
< ctx
->Const
.MaxUniformBufferBindings
; i
++) {
651 _mesa_reference_buffer_object(ctx
,
652 &ctx
->UniformBufferBindings
[i
].BufferObject
,
656 free(ctx
->UniformBufferBindings
);
657 ctx
->UniformBufferBindings
= NULL
;
661 handle_bind_buffer_gen(struct gl_context
*ctx
,
664 struct gl_buffer_object
**buf_handle
)
666 struct gl_buffer_object
*buf
= *buf_handle
;
668 if (!buf
&& ctx
->API
== API_OPENGL_CORE
) {
669 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindBuffer(non-gen name)");
673 if (!buf
|| buf
== &DummyBufferObject
) {
674 /* If this is a new buffer object id, or one which was generated but
675 * never used before, allocate a buffer object now.
677 ASSERT(ctx
->Driver
.NewBufferObject
);
678 buf
= ctx
->Driver
.NewBufferObject(ctx
, buffer
, target
);
680 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glBindBufferARB");
683 _mesa_HashInsert(ctx
->Shared
->BufferObjects
, buffer
, buf
);
691 * Bind the specified target to buffer for the specified context.
692 * Called by glBindBuffer() and other functions.
695 bind_buffer_object(struct gl_context
*ctx
, GLenum target
, GLuint buffer
)
697 struct gl_buffer_object
*oldBufObj
;
698 struct gl_buffer_object
*newBufObj
= NULL
;
699 struct gl_buffer_object
**bindTarget
= NULL
;
701 bindTarget
= get_buffer_target(ctx
, target
);
703 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindBufferARB(target 0x%x)", target
);
707 /* Get pointer to old buffer object (to be unbound) */
708 oldBufObj
= *bindTarget
;
709 if (oldBufObj
&& oldBufObj
->Name
== buffer
&& !oldBufObj
->DeletePending
)
710 return; /* rebinding the same buffer object- no change */
713 * Get pointer to new buffer object (newBufObj)
716 /* The spec says there's not a buffer object named 0, but we use
717 * one internally because it simplifies things.
719 newBufObj
= ctx
->Shared
->NullBufferObj
;
722 /* non-default buffer object */
723 newBufObj
= _mesa_lookup_bufferobj(ctx
, buffer
);
724 if (!handle_bind_buffer_gen(ctx
, target
, buffer
, &newBufObj
))
728 /* bind new buffer */
729 _mesa_reference_buffer_object(ctx
, bindTarget
, newBufObj
);
731 /* Pass BindBuffer call to device driver */
732 if (ctx
->Driver
.BindBuffer
)
733 ctx
->Driver
.BindBuffer( ctx
, target
, newBufObj
);
738 * Update the default buffer objects in the given context to reference those
739 * specified in the shared state and release those referencing the old
743 _mesa_update_default_objects_buffer_objects(struct gl_context
*ctx
)
745 /* Bind the NullBufferObj to remove references to those
746 * in the shared context hash table.
748 bind_buffer_object( ctx
, GL_ARRAY_BUFFER_ARB
, 0);
749 bind_buffer_object( ctx
, GL_ELEMENT_ARRAY_BUFFER_ARB
, 0);
750 bind_buffer_object( ctx
, GL_PIXEL_PACK_BUFFER_ARB
, 0);
751 bind_buffer_object( ctx
, GL_PIXEL_UNPACK_BUFFER_ARB
, 0);
757 * Return the gl_buffer_object for the given ID.
758 * Always return NULL for ID 0.
760 struct gl_buffer_object
*
761 _mesa_lookup_bufferobj(struct gl_context
*ctx
, GLuint buffer
)
766 return (struct gl_buffer_object
*)
767 _mesa_HashLookup(ctx
->Shared
->BufferObjects
, buffer
);
772 * If *ptr points to obj, set ptr = the Null/default buffer object.
773 * This is a helper for buffer object deletion.
774 * The GL spec says that deleting a buffer object causes it to get
775 * unbound from all arrays in the current context.
778 unbind(struct gl_context
*ctx
,
779 struct gl_buffer_object
**ptr
,
780 struct gl_buffer_object
*obj
)
783 _mesa_reference_buffer_object(ctx
, ptr
, ctx
->Shared
->NullBufferObj
);
789 * Plug default/fallback buffer object functions into the device
793 _mesa_init_buffer_object_functions(struct dd_function_table
*driver
)
795 /* GL_ARB_vertex/pixel_buffer_object */
796 driver
->NewBufferObject
= _mesa_new_buffer_object
;
797 driver
->DeleteBuffer
= _mesa_delete_buffer_object
;
798 driver
->BindBuffer
= NULL
;
799 driver
->BufferData
= _mesa_buffer_data
;
800 driver
->BufferSubData
= _mesa_buffer_subdata
;
801 driver
->GetBufferSubData
= _mesa_buffer_get_subdata
;
802 driver
->UnmapBuffer
= _mesa_buffer_unmap
;
804 /* GL_ARB_map_buffer_range */
805 driver
->MapBufferRange
= _mesa_buffer_map_range
;
806 driver
->FlushMappedBufferRange
= _mesa_buffer_flush_mapped_range
;
808 /* GL_ARB_copy_buffer */
809 driver
->CopyBufferSubData
= _mesa_copy_buffer_subdata
;
814 /**********************************************************************/
816 /**********************************************************************/
819 _mesa_BindBuffer(GLenum target
, GLuint buffer
)
821 GET_CURRENT_CONTEXT(ctx
);
823 if (MESA_VERBOSE
& VERBOSE_API
)
824 _mesa_debug(ctx
, "glBindBuffer(%s, %u)\n",
825 _mesa_lookup_enum_by_nr(target
), buffer
);
827 bind_buffer_object(ctx
, target
, buffer
);
832 * Delete a set of buffer objects.
834 * \param n Number of buffer objects to delete.
835 * \param ids Array of \c n buffer object IDs.
838 _mesa_DeleteBuffers(GLsizei n
, const GLuint
*ids
)
840 GET_CURRENT_CONTEXT(ctx
);
842 FLUSH_VERTICES(ctx
, 0);
845 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteBuffersARB(n)");
849 _glthread_LOCK_MUTEX(ctx
->Shared
->Mutex
);
851 for (i
= 0; i
< n
; i
++) {
852 struct gl_buffer_object
*bufObj
= _mesa_lookup_bufferobj(ctx
, ids
[i
]);
854 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
857 ASSERT(bufObj
->Name
== ids
[i
] || bufObj
== &DummyBufferObject
);
859 if (_mesa_bufferobj_mapped(bufObj
)) {
860 /* if mapped, unmap it now */
861 ctx
->Driver
.UnmapBuffer(ctx
, bufObj
);
862 bufObj
->AccessFlags
= 0;
863 bufObj
->Pointer
= NULL
;
866 /* unbind any vertex pointers bound to this buffer */
867 for (j
= 0; j
< Elements(arrayObj
->VertexAttrib
); j
++) {
868 unbind(ctx
, &arrayObj
->VertexAttrib
[j
].BufferObj
, bufObj
);
871 if (ctx
->Array
.ArrayBufferObj
== bufObj
) {
872 _mesa_BindBuffer( GL_ARRAY_BUFFER_ARB
, 0 );
874 if (arrayObj
->ElementArrayBufferObj
== bufObj
) {
875 _mesa_BindBuffer( GL_ELEMENT_ARRAY_BUFFER_ARB
, 0 );
878 /* unbind ARB_copy_buffer binding points */
879 if (ctx
->CopyReadBuffer
== bufObj
) {
880 _mesa_BindBuffer( GL_COPY_READ_BUFFER
, 0 );
882 if (ctx
->CopyWriteBuffer
== bufObj
) {
883 _mesa_BindBuffer( GL_COPY_WRITE_BUFFER
, 0 );
886 /* unbind transform feedback binding points */
887 if (ctx
->TransformFeedback
.CurrentBuffer
== bufObj
) {
888 _mesa_BindBuffer( GL_TRANSFORM_FEEDBACK_BUFFER
, 0 );
890 for (j
= 0; j
< MAX_FEEDBACK_BUFFERS
; j
++) {
891 if (ctx
->TransformFeedback
.CurrentObject
->Buffers
[j
] == bufObj
) {
892 _mesa_BindBufferBase( GL_TRANSFORM_FEEDBACK_BUFFER
, j
, 0 );
896 /* unbind UBO binding points */
897 for (j
= 0; j
< ctx
->Const
.MaxUniformBufferBindings
; j
++) {
898 if (ctx
->UniformBufferBindings
[j
].BufferObject
== bufObj
) {
899 _mesa_BindBufferBase( GL_UNIFORM_BUFFER
, j
, 0 );
903 if (ctx
->UniformBuffer
== bufObj
) {
904 _mesa_BindBuffer( GL_UNIFORM_BUFFER
, 0 );
907 /* unbind any pixel pack/unpack pointers bound to this buffer */
908 if (ctx
->Pack
.BufferObj
== bufObj
) {
909 _mesa_BindBuffer( GL_PIXEL_PACK_BUFFER_EXT
, 0 );
911 if (ctx
->Unpack
.BufferObj
== bufObj
) {
912 _mesa_BindBuffer( GL_PIXEL_UNPACK_BUFFER_EXT
, 0 );
915 if (ctx
->Texture
.BufferObject
== bufObj
) {
916 _mesa_BindBuffer( GL_TEXTURE_BUFFER
, 0 );
919 /* The ID is immediately freed for re-use */
920 _mesa_HashRemove(ctx
->Shared
->BufferObjects
, ids
[i
]);
921 /* Make sure we do not run into the classic ABA problem on bind.
922 * We don't want to allow re-binding a buffer object that's been
923 * "deleted" by glDeleteBuffers().
925 * The explicit rebinding to the default object in the current context
926 * prevents the above in the current context, but another context
927 * sharing the same objects might suffer from this problem.
928 * The alternative would be to do the hash lookup in any case on bind
929 * which would introduce more runtime overhead than this.
931 bufObj
->DeletePending
= GL_TRUE
;
932 _mesa_reference_buffer_object(ctx
, &bufObj
, NULL
);
936 _glthread_UNLOCK_MUTEX(ctx
->Shared
->Mutex
);
941 * Generate a set of unique buffer object IDs and store them in \c buffer.
943 * \param n Number of IDs to generate.
944 * \param buffer Array of \c n locations to store the IDs.
947 _mesa_GenBuffers(GLsizei n
, GLuint
*buffer
)
949 GET_CURRENT_CONTEXT(ctx
);
953 if (MESA_VERBOSE
& VERBOSE_API
)
954 _mesa_debug(ctx
, "glGenBuffers(%d)\n", n
);
957 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGenBuffersARB");
966 * This must be atomic (generation and allocation of buffer object IDs)
968 _glthread_LOCK_MUTEX(ctx
->Shared
->Mutex
);
970 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->BufferObjects
, n
);
972 /* Insert the ID and pointer to dummy buffer object into hash table */
973 for (i
= 0; i
< n
; i
++) {
974 _mesa_HashInsert(ctx
->Shared
->BufferObjects
, first
+ i
,
976 buffer
[i
] = first
+ i
;
979 _glthread_UNLOCK_MUTEX(ctx
->Shared
->Mutex
);
984 * Determine if ID is the name of a buffer object.
986 * \param id ID of the potential buffer object.
987 * \return \c GL_TRUE if \c id is the name of a buffer object,
988 * \c GL_FALSE otherwise.
991 _mesa_IsBuffer(GLuint id
)
993 struct gl_buffer_object
*bufObj
;
994 GET_CURRENT_CONTEXT(ctx
);
995 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
997 _glthread_LOCK_MUTEX(ctx
->Shared
->Mutex
);
998 bufObj
= _mesa_lookup_bufferobj(ctx
, id
);
999 _glthread_UNLOCK_MUTEX(ctx
->Shared
->Mutex
);
1001 return bufObj
&& bufObj
!= &DummyBufferObject
;
1006 _mesa_BufferData(GLenum target
, GLsizeiptrARB size
,
1007 const GLvoid
* data
, GLenum usage
)
1009 GET_CURRENT_CONTEXT(ctx
);
1010 struct gl_buffer_object
*bufObj
;
1013 if (MESA_VERBOSE
& VERBOSE_API
)
1014 _mesa_debug(ctx
, "glBufferData(%s, %ld, %p, %s)\n",
1015 _mesa_lookup_enum_by_nr(target
),
1016 (long int) size
, data
,
1017 _mesa_lookup_enum_by_nr(usage
));
1020 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBufferDataARB(size < 0)");
1025 case GL_STREAM_DRAW_ARB
:
1026 valid_usage
= (ctx
->API
!= API_OPENGLES
);
1029 case GL_STATIC_DRAW_ARB
:
1030 case GL_DYNAMIC_DRAW_ARB
:
1034 case GL_STREAM_READ_ARB
:
1035 case GL_STREAM_COPY_ARB
:
1036 case GL_STATIC_READ_ARB
:
1037 case GL_STATIC_COPY_ARB
:
1038 case GL_DYNAMIC_READ_ARB
:
1039 case GL_DYNAMIC_COPY_ARB
:
1040 valid_usage
= _mesa_is_desktop_gl(ctx
) || _mesa_is_gles3(ctx
);
1044 valid_usage
= false;
1049 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBufferData(usage)");
1053 bufObj
= get_buffer(ctx
, "glBufferDataARB", target
);
1057 if (_mesa_bufferobj_mapped(bufObj
)) {
1058 /* Unmap the existing buffer. We'll replace it now. Not an error. */
1059 ctx
->Driver
.UnmapBuffer(ctx
, bufObj
);
1060 bufObj
->AccessFlags
= 0;
1061 ASSERT(bufObj
->Pointer
== NULL
);
1064 FLUSH_VERTICES(ctx
, _NEW_BUFFER_OBJECT
);
1066 bufObj
->Written
= GL_TRUE
;
1069 printf("glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n",
1070 bufObj
->Name
, size
, data
, usage
);
1077 ASSERT(ctx
->Driver
.BufferData
);
1078 if (!ctx
->Driver
.BufferData( ctx
, target
, size
, data
, usage
, bufObj
)) {
1079 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glBufferDataARB()");
1085 _mesa_BufferSubData(GLenum target
, GLintptrARB offset
,
1086 GLsizeiptrARB size
, const GLvoid
* data
)
1088 GET_CURRENT_CONTEXT(ctx
);
1089 struct gl_buffer_object
*bufObj
;
1091 bufObj
= buffer_object_subdata_range_good( ctx
, target
, offset
, size
,
1092 "glBufferSubDataARB" );
1094 /* error already recorded */
1101 bufObj
->Written
= GL_TRUE
;
1103 ASSERT(ctx
->Driver
.BufferSubData
);
1104 ctx
->Driver
.BufferSubData( ctx
, offset
, size
, data
, bufObj
);
1109 _mesa_GetBufferSubData(GLenum target
, GLintptrARB offset
,
1110 GLsizeiptrARB size
, void * data
)
1112 GET_CURRENT_CONTEXT(ctx
);
1113 struct gl_buffer_object
*bufObj
;
1115 bufObj
= buffer_object_subdata_range_good( ctx
, target
, offset
, size
,
1116 "glGetBufferSubDataARB" );
1118 /* error already recorded */
1122 ASSERT(ctx
->Driver
.GetBufferSubData
);
1123 ctx
->Driver
.GetBufferSubData( ctx
, offset
, size
, data
, bufObj
);
1128 _mesa_MapBuffer(GLenum target
, GLenum access
)
1130 GET_CURRENT_CONTEXT(ctx
);
1131 struct gl_buffer_object
* bufObj
;
1132 GLbitfield accessFlags
;
1136 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, NULL
);
1139 case GL_READ_ONLY_ARB
:
1140 accessFlags
= GL_MAP_READ_BIT
;
1141 valid_access
= _mesa_is_desktop_gl(ctx
);
1143 case GL_WRITE_ONLY_ARB
:
1144 accessFlags
= GL_MAP_WRITE_BIT
;
1145 valid_access
= true;
1147 case GL_READ_WRITE_ARB
:
1148 accessFlags
= GL_MAP_READ_BIT
| GL_MAP_WRITE_BIT
;
1149 valid_access
= _mesa_is_desktop_gl(ctx
);
1152 valid_access
= false;
1156 if (!valid_access
) {
1157 _mesa_error(ctx
, GL_INVALID_ENUM
, "glMapBufferARB(access)");
1161 bufObj
= get_buffer(ctx
, "glMapBufferARB", target
);
1165 if (_mesa_bufferobj_mapped(bufObj
)) {
1166 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glMapBufferARB(already mapped)");
1170 if (!bufObj
->Size
) {
1171 _mesa_error(ctx
, GL_OUT_OF_MEMORY
,
1172 "glMapBuffer(buffer size = 0)");
1176 ASSERT(ctx
->Driver
.MapBufferRange
);
1177 map
= ctx
->Driver
.MapBufferRange(ctx
, 0, bufObj
->Size
, accessFlags
, bufObj
);
1179 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glMapBufferARB(map failed)");
1183 /* The driver callback should have set these fields.
1184 * This is important because other modules (like VBO) might call
1185 * the driver function directly.
1187 ASSERT(bufObj
->Pointer
== map
);
1188 ASSERT(bufObj
->Length
== bufObj
->Size
);
1189 ASSERT(bufObj
->Offset
== 0);
1190 bufObj
->AccessFlags
= accessFlags
;
1193 if (access
== GL_WRITE_ONLY_ARB
|| access
== GL_READ_WRITE_ARB
)
1194 bufObj
->Written
= GL_TRUE
;
1197 printf("glMapBufferARB(%u, sz %ld, access 0x%x)\n",
1198 bufObj
->Name
, bufObj
->Size
, access
);
1199 if (access
== GL_WRITE_ONLY_ARB
) {
1201 GLubyte
*b
= (GLubyte
*) bufObj
->Pointer
;
1202 for (i
= 0; i
< bufObj
->Size
; i
++)
1209 GLubyte
*buf
= (GLubyte
*) bufObj
->Pointer
;
1211 /* buffer is 100 bytes larger than requested, fill with magic value */
1212 for (i
= 0; i
< 100; i
++) {
1213 buf
[bufObj
->Size
- i
- 1] = 123;
1218 return bufObj
->Pointer
;
1222 GLboolean GLAPIENTRY
1223 _mesa_UnmapBuffer(GLenum target
)
1225 GET_CURRENT_CONTEXT(ctx
);
1226 struct gl_buffer_object
*bufObj
;
1227 GLboolean status
= GL_TRUE
;
1228 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
1230 bufObj
= get_buffer(ctx
, "glUnmapBufferARB", target
);
1234 if (!_mesa_bufferobj_mapped(bufObj
)) {
1235 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glUnmapBufferARB");
1240 if (bufObj
->Access
!= GL_READ_ONLY_ARB
) {
1241 GLubyte
*buf
= (GLubyte
*) bufObj
->Pointer
;
1243 /* check that last 100 bytes are still = magic value */
1244 for (i
= 0; i
< 100; i
++) {
1245 GLuint pos
= bufObj
->Size
- i
- 1;
1246 if (buf
[pos
] != 123) {
1247 _mesa_warning(ctx
, "Out of bounds buffer object write detected"
1248 " at position %d (value = %u)\n",
1256 if (bufObj
->AccessFlags
& GL_MAP_WRITE_BIT
) {
1257 GLuint i
, unchanged
= 0;
1258 GLubyte
*b
= (GLubyte
*) bufObj
->Pointer
;
1260 /* check which bytes changed */
1261 for (i
= 0; i
< bufObj
->Size
- 1; i
++) {
1262 if (b
[i
] == (i
& 0xff) && b
[i
+1] == ((i
+1) & 0xff)) {
1269 printf("glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n",
1270 bufObj
->Name
, unchanged
, bufObj
->Size
, pos
);
1275 status
= ctx
->Driver
.UnmapBuffer( ctx
, bufObj
);
1276 bufObj
->AccessFlags
= 0;
1277 ASSERT(bufObj
->Pointer
== NULL
);
1278 ASSERT(bufObj
->Offset
== 0);
1279 ASSERT(bufObj
->Length
== 0);
1286 _mesa_GetBufferParameteriv(GLenum target
, GLenum pname
, GLint
*params
)
1288 GET_CURRENT_CONTEXT(ctx
);
1289 struct gl_buffer_object
*bufObj
;
1291 bufObj
= get_buffer(ctx
, "glGetBufferParameterivARB", target
);
1296 case GL_BUFFER_SIZE_ARB
:
1297 *params
= (GLint
) bufObj
->Size
;
1299 case GL_BUFFER_USAGE_ARB
:
1300 *params
= bufObj
->Usage
;
1302 case GL_BUFFER_ACCESS_ARB
:
1303 *params
= simplified_access_mode(ctx
, bufObj
->AccessFlags
);
1305 case GL_BUFFER_MAPPED_ARB
:
1306 *params
= _mesa_bufferobj_mapped(bufObj
);
1308 case GL_BUFFER_ACCESS_FLAGS
:
1309 if (!ctx
->Extensions
.ARB_map_buffer_range
)
1311 *params
= bufObj
->AccessFlags
;
1313 case GL_BUFFER_MAP_OFFSET
:
1314 if (!ctx
->Extensions
.ARB_map_buffer_range
)
1316 *params
= (GLint
) bufObj
->Offset
;
1318 case GL_BUFFER_MAP_LENGTH
:
1319 if (!ctx
->Extensions
.ARB_map_buffer_range
)
1321 *params
= (GLint
) bufObj
->Length
;
1324 ; /* fall-through */
1328 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetBufferParameterivARB(pname=%s)",
1329 _mesa_lookup_enum_by_nr(pname
));
1335 * This is pretty much a duplicate of GetBufferParameteriv() but the
1336 * GL_BUFFER_SIZE_ARB attribute will be 64-bits on a 64-bit system.
1339 _mesa_GetBufferParameteri64v(GLenum target
, GLenum pname
, GLint64
*params
)
1341 GET_CURRENT_CONTEXT(ctx
);
1342 struct gl_buffer_object
*bufObj
;
1344 bufObj
= get_buffer(ctx
, "glGetBufferParameteri64v", target
);
1349 case GL_BUFFER_SIZE_ARB
:
1350 *params
= bufObj
->Size
;
1352 case GL_BUFFER_USAGE_ARB
:
1353 *params
= bufObj
->Usage
;
1355 case GL_BUFFER_ACCESS_ARB
:
1356 *params
= simplified_access_mode(ctx
, bufObj
->AccessFlags
);
1358 case GL_BUFFER_ACCESS_FLAGS
:
1359 if (!ctx
->Extensions
.ARB_map_buffer_range
)
1361 *params
= bufObj
->AccessFlags
;
1363 case GL_BUFFER_MAPPED_ARB
:
1364 *params
= _mesa_bufferobj_mapped(bufObj
);
1366 case GL_BUFFER_MAP_OFFSET
:
1367 if (!ctx
->Extensions
.ARB_map_buffer_range
)
1369 *params
= bufObj
->Offset
;
1371 case GL_BUFFER_MAP_LENGTH
:
1372 if (!ctx
->Extensions
.ARB_map_buffer_range
)
1374 *params
= bufObj
->Length
;
1377 ; /* fall-through */
1381 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetBufferParameteri64v(pname=%s)",
1382 _mesa_lookup_enum_by_nr(pname
));
1387 _mesa_GetBufferPointerv(GLenum target
, GLenum pname
, GLvoid
**params
)
1389 GET_CURRENT_CONTEXT(ctx
);
1390 struct gl_buffer_object
* bufObj
;
1392 if (pname
!= GL_BUFFER_MAP_POINTER_ARB
) {
1393 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetBufferPointervARB(pname)");
1397 bufObj
= get_buffer(ctx
, "glGetBufferPointervARB", target
);
1401 *params
= bufObj
->Pointer
;
1406 _mesa_CopyBufferSubData(GLenum readTarget
, GLenum writeTarget
,
1407 GLintptr readOffset
, GLintptr writeOffset
,
1410 GET_CURRENT_CONTEXT(ctx
);
1411 struct gl_buffer_object
*src
, *dst
;
1413 src
= get_buffer(ctx
, "glCopyBufferSubData", readTarget
);
1417 dst
= get_buffer(ctx
, "glCopyBufferSubData", writeTarget
);
1421 if (_mesa_bufferobj_mapped(src
)) {
1422 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1423 "glCopyBufferSubData(readBuffer is mapped)");
1427 if (_mesa_bufferobj_mapped(dst
)) {
1428 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1429 "glCopyBufferSubData(writeBuffer is mapped)");
1433 if (readOffset
< 0) {
1434 _mesa_error(ctx
, GL_INVALID_VALUE
,
1435 "glCopyBufferSubData(readOffset = %d)", (int) readOffset
);
1439 if (writeOffset
< 0) {
1440 _mesa_error(ctx
, GL_INVALID_VALUE
,
1441 "glCopyBufferSubData(writeOffset = %d)", (int) writeOffset
);
1446 _mesa_error(ctx
, GL_INVALID_VALUE
,
1447 "glCopyBufferSubData(writeOffset = %d)", (int) size
);
1451 if (readOffset
+ size
> src
->Size
) {
1452 _mesa_error(ctx
, GL_INVALID_VALUE
,
1453 "glCopyBufferSubData(readOffset + size = %d)",
1454 (int) (readOffset
+ size
));
1458 if (writeOffset
+ size
> dst
->Size
) {
1459 _mesa_error(ctx
, GL_INVALID_VALUE
,
1460 "glCopyBufferSubData(writeOffset + size = %d)",
1461 (int) (writeOffset
+ size
));
1466 if (readOffset
+ size
<= writeOffset
) {
1469 else if (writeOffset
+ size
<= readOffset
) {
1473 /* overlapping src/dst is illegal */
1474 _mesa_error(ctx
, GL_INVALID_VALUE
,
1475 "glCopyBufferSubData(overlapping src/dst)");
1480 ctx
->Driver
.CopyBufferSubData(ctx
, src
, dst
, readOffset
, writeOffset
, size
);
1485 * See GL_ARB_map_buffer_range spec
1488 _mesa_MapBufferRange(GLenum target
, GLintptr offset
, GLsizeiptr length
,
1491 GET_CURRENT_CONTEXT(ctx
);
1492 struct gl_buffer_object
*bufObj
;
1495 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, NULL
);
1497 if (!ctx
->Extensions
.ARB_map_buffer_range
) {
1498 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1499 "glMapBufferRange(extension not supported)");
1504 _mesa_error(ctx
, GL_INVALID_VALUE
,
1505 "glMapBufferRange(offset = %ld)", (long)offset
);
1510 _mesa_error(ctx
, GL_INVALID_VALUE
,
1511 "glMapBufferRange(length = %ld)", (long)length
);
1515 /* Page 38 of the PDF of the OpenGL ES 3.0 spec says:
1517 * "An INVALID_OPERATION error is generated for any of the following
1520 * * <length> is zero."
1522 if (_mesa_is_gles(ctx
) && length
== 0) {
1523 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1524 "glMapBufferRange(length = 0)");
1528 if (access
& ~(GL_MAP_READ_BIT
|
1530 GL_MAP_INVALIDATE_RANGE_BIT
|
1531 GL_MAP_INVALIDATE_BUFFER_BIT
|
1532 GL_MAP_FLUSH_EXPLICIT_BIT
|
1533 GL_MAP_UNSYNCHRONIZED_BIT
)) {
1534 /* generate an error if any undefind bit is set */
1535 _mesa_error(ctx
, GL_INVALID_VALUE
, "glMapBufferRange(access)");
1539 if ((access
& (GL_MAP_READ_BIT
| GL_MAP_WRITE_BIT
)) == 0) {
1540 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1541 "glMapBufferRange(access indicates neither read or write)");
1545 if ((access
& GL_MAP_READ_BIT
) &&
1546 (access
& (GL_MAP_INVALIDATE_RANGE_BIT
|
1547 GL_MAP_INVALIDATE_BUFFER_BIT
|
1548 GL_MAP_UNSYNCHRONIZED_BIT
))) {
1549 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1550 "glMapBufferRange(invalid access flags)");
1554 if ((access
& GL_MAP_FLUSH_EXPLICIT_BIT
) &&
1555 ((access
& GL_MAP_WRITE_BIT
) == 0)) {
1556 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1557 "glMapBufferRange(invalid access flags)");
1561 bufObj
= get_buffer(ctx
, "glMapBufferRange", target
);
1565 if (offset
+ length
> bufObj
->Size
) {
1566 _mesa_error(ctx
, GL_INVALID_VALUE
,
1567 "glMapBufferRange(offset + length > size)");
1571 if (_mesa_bufferobj_mapped(bufObj
)) {
1572 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1573 "glMapBufferRange(buffer already mapped)");
1577 if (!bufObj
->Size
) {
1578 _mesa_error(ctx
, GL_OUT_OF_MEMORY
,
1579 "glMapBufferRange(buffer size = 0)");
1583 /* Mapping zero bytes should return a non-null pointer. */
1585 static long dummy
= 0;
1586 bufObj
->Pointer
= &dummy
;
1587 bufObj
->Length
= length
;
1588 bufObj
->Offset
= offset
;
1589 bufObj
->AccessFlags
= access
;
1590 return bufObj
->Pointer
;
1593 ASSERT(ctx
->Driver
.MapBufferRange
);
1594 map
= ctx
->Driver
.MapBufferRange(ctx
, offset
, length
, access
, bufObj
);
1596 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glMapBufferARB(map failed)");
1599 /* The driver callback should have set all these fields.
1600 * This is important because other modules (like VBO) might call
1601 * the driver function directly.
1603 ASSERT(bufObj
->Pointer
== map
);
1604 ASSERT(bufObj
->Length
== length
);
1605 ASSERT(bufObj
->Offset
== offset
);
1606 ASSERT(bufObj
->AccessFlags
== access
);
1614 * See GL_ARB_map_buffer_range spec
1617 _mesa_FlushMappedBufferRange(GLenum target
, GLintptr offset
, GLsizeiptr length
)
1619 GET_CURRENT_CONTEXT(ctx
);
1620 struct gl_buffer_object
*bufObj
;
1622 if (!ctx
->Extensions
.ARB_map_buffer_range
) {
1623 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1624 "glFlushMappedBufferRange(extension not supported)");
1629 _mesa_error(ctx
, GL_INVALID_VALUE
,
1630 "glFlushMappedBufferRange(offset = %ld)", (long)offset
);
1635 _mesa_error(ctx
, GL_INVALID_VALUE
,
1636 "glFlushMappedBufferRange(length = %ld)", (long)length
);
1640 bufObj
= get_buffer(ctx
, "glFlushMappedBufferRange", target
);
1644 if (!_mesa_bufferobj_mapped(bufObj
)) {
1645 /* buffer is not mapped */
1646 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1647 "glFlushMappedBufferRange(buffer is not mapped)");
1651 if ((bufObj
->AccessFlags
& GL_MAP_FLUSH_EXPLICIT_BIT
) == 0) {
1652 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1653 "glFlushMappedBufferRange(GL_MAP_FLUSH_EXPLICIT_BIT not set)");
1657 if (offset
+ length
> bufObj
->Length
) {
1658 _mesa_error(ctx
, GL_INVALID_VALUE
,
1659 "glFlushMappedBufferRange(offset %ld + length %ld > mapped length %ld)",
1660 (long)offset
, (long)length
, (long)bufObj
->Length
);
1664 ASSERT(bufObj
->AccessFlags
& GL_MAP_WRITE_BIT
);
1666 if (ctx
->Driver
.FlushMappedBufferRange
)
1667 ctx
->Driver
.FlushMappedBufferRange(ctx
, offset
, length
, bufObj
);
1672 buffer_object_purgeable(struct gl_context
*ctx
, GLuint name
, GLenum option
)
1674 struct gl_buffer_object
*bufObj
;
1677 bufObj
= _mesa_lookup_bufferobj(ctx
, name
);
1679 _mesa_error(ctx
, GL_INVALID_VALUE
,
1680 "glObjectPurgeable(name = 0x%x)", name
);
1683 if (!_mesa_is_bufferobj(bufObj
)) {
1684 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glObjectPurgeable(buffer 0)" );
1688 if (bufObj
->Purgeable
) {
1689 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1690 "glObjectPurgeable(name = 0x%x) is already purgeable", name
);
1691 return GL_VOLATILE_APPLE
;
1694 bufObj
->Purgeable
= GL_TRUE
;
1696 retval
= GL_VOLATILE_APPLE
;
1697 if (ctx
->Driver
.BufferObjectPurgeable
)
1698 retval
= ctx
->Driver
.BufferObjectPurgeable(ctx
, bufObj
, option
);
1705 renderbuffer_purgeable(struct gl_context
*ctx
, GLuint name
, GLenum option
)
1707 struct gl_renderbuffer
*bufObj
;
1710 bufObj
= _mesa_lookup_renderbuffer(ctx
, name
);
1712 _mesa_error(ctx
, GL_INVALID_VALUE
,
1713 "glObjectUnpurgeable(name = 0x%x)", name
);
1717 if (bufObj
->Purgeable
) {
1718 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1719 "glObjectPurgeable(name = 0x%x) is already purgeable", name
);
1720 return GL_VOLATILE_APPLE
;
1723 bufObj
->Purgeable
= GL_TRUE
;
1725 retval
= GL_VOLATILE_APPLE
;
1726 if (ctx
->Driver
.RenderObjectPurgeable
)
1727 retval
= ctx
->Driver
.RenderObjectPurgeable(ctx
, bufObj
, option
);
1734 texture_object_purgeable(struct gl_context
*ctx
, GLuint name
, GLenum option
)
1736 struct gl_texture_object
*bufObj
;
1739 bufObj
= _mesa_lookup_texture(ctx
, name
);
1741 _mesa_error(ctx
, GL_INVALID_VALUE
,
1742 "glObjectPurgeable(name = 0x%x)", name
);
1746 if (bufObj
->Purgeable
) {
1747 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1748 "glObjectPurgeable(name = 0x%x) is already purgeable", name
);
1749 return GL_VOLATILE_APPLE
;
1752 bufObj
->Purgeable
= GL_TRUE
;
1754 retval
= GL_VOLATILE_APPLE
;
1755 if (ctx
->Driver
.TextureObjectPurgeable
)
1756 retval
= ctx
->Driver
.TextureObjectPurgeable(ctx
, bufObj
, option
);
1763 _mesa_ObjectPurgeableAPPLE(GLenum objectType
, GLuint name
, GLenum option
)
1767 GET_CURRENT_CONTEXT(ctx
);
1768 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1771 _mesa_error(ctx
, GL_INVALID_VALUE
,
1772 "glObjectPurgeable(name = 0x%x)", name
);
1777 case GL_VOLATILE_APPLE
:
1778 case GL_RELEASED_APPLE
:
1782 _mesa_error(ctx
, GL_INVALID_ENUM
,
1783 "glObjectPurgeable(name = 0x%x) invalid option: %d",
1788 switch (objectType
) {
1790 retval
= texture_object_purgeable(ctx
, name
, option
);
1792 case GL_RENDERBUFFER_EXT
:
1793 retval
= renderbuffer_purgeable(ctx
, name
, option
);
1795 case GL_BUFFER_OBJECT_APPLE
:
1796 retval
= buffer_object_purgeable(ctx
, name
, option
);
1799 _mesa_error(ctx
, GL_INVALID_ENUM
,
1800 "glObjectPurgeable(name = 0x%x) invalid type: %d",
1805 /* In strict conformance to the spec, we must only return VOLATILE when
1806 * when passed the VOLATILE option. Madness.
1808 * XXX First fix the spec, then fix me.
1810 return option
== GL_VOLATILE_APPLE
? GL_VOLATILE_APPLE
: retval
;
1815 buffer_object_unpurgeable(struct gl_context
*ctx
, GLuint name
, GLenum option
)
1817 struct gl_buffer_object
*bufObj
;
1820 bufObj
= _mesa_lookup_bufferobj(ctx
, name
);
1822 _mesa_error(ctx
, GL_INVALID_VALUE
,
1823 "glObjectUnpurgeable(name = 0x%x)", name
);
1827 if (! bufObj
->Purgeable
) {
1828 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1829 "glObjectUnpurgeable(name = 0x%x) object is "
1830 " already \"unpurged\"", name
);
1834 bufObj
->Purgeable
= GL_FALSE
;
1837 if (ctx
->Driver
.BufferObjectUnpurgeable
)
1838 retval
= ctx
->Driver
.BufferObjectUnpurgeable(ctx
, bufObj
, option
);
1845 renderbuffer_unpurgeable(struct gl_context
*ctx
, GLuint name
, GLenum option
)
1847 struct gl_renderbuffer
*bufObj
;
1850 bufObj
= _mesa_lookup_renderbuffer(ctx
, name
);
1852 _mesa_error(ctx
, GL_INVALID_VALUE
,
1853 "glObjectUnpurgeable(name = 0x%x)", name
);
1857 if (! bufObj
->Purgeable
) {
1858 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1859 "glObjectUnpurgeable(name = 0x%x) object is "
1860 " already \"unpurged\"", name
);
1864 bufObj
->Purgeable
= GL_FALSE
;
1867 if (ctx
->Driver
.RenderObjectUnpurgeable
)
1868 retval
= ctx
->Driver
.RenderObjectUnpurgeable(ctx
, bufObj
, option
);
1875 texture_object_unpurgeable(struct gl_context
*ctx
, GLuint name
, GLenum option
)
1877 struct gl_texture_object
*bufObj
;
1880 bufObj
= _mesa_lookup_texture(ctx
, name
);
1882 _mesa_error(ctx
, GL_INVALID_VALUE
,
1883 "glObjectUnpurgeable(name = 0x%x)", name
);
1887 if (! bufObj
->Purgeable
) {
1888 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1889 "glObjectUnpurgeable(name = 0x%x) object is"
1890 " already \"unpurged\"", name
);
1894 bufObj
->Purgeable
= GL_FALSE
;
1897 if (ctx
->Driver
.TextureObjectUnpurgeable
)
1898 retval
= ctx
->Driver
.TextureObjectUnpurgeable(ctx
, bufObj
, option
);
1905 _mesa_ObjectUnpurgeableAPPLE(GLenum objectType
, GLuint name
, GLenum option
)
1907 GET_CURRENT_CONTEXT(ctx
);
1908 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1911 _mesa_error(ctx
, GL_INVALID_VALUE
,
1912 "glObjectUnpurgeable(name = 0x%x)", name
);
1917 case GL_RETAINED_APPLE
:
1918 case GL_UNDEFINED_APPLE
:
1922 _mesa_error(ctx
, GL_INVALID_ENUM
,
1923 "glObjectUnpurgeable(name = 0x%x) invalid option: %d",
1928 switch (objectType
) {
1929 case GL_BUFFER_OBJECT_APPLE
:
1930 return buffer_object_unpurgeable(ctx
, name
, option
);
1932 return texture_object_unpurgeable(ctx
, name
, option
);
1933 case GL_RENDERBUFFER_EXT
:
1934 return renderbuffer_unpurgeable(ctx
, name
, option
);
1936 _mesa_error(ctx
, GL_INVALID_ENUM
,
1937 "glObjectUnpurgeable(name = 0x%x) invalid type: %d",
1945 get_buffer_object_parameteriv(struct gl_context
*ctx
, GLuint name
,
1946 GLenum pname
, GLint
*params
)
1948 struct gl_buffer_object
*bufObj
= _mesa_lookup_bufferobj(ctx
, name
);
1950 _mesa_error(ctx
, GL_INVALID_VALUE
,
1951 "glGetObjectParameteriv(name = 0x%x) invalid object", name
);
1956 case GL_PURGEABLE_APPLE
:
1957 *params
= bufObj
->Purgeable
;
1960 _mesa_error(ctx
, GL_INVALID_ENUM
,
1961 "glGetObjectParameteriv(name = 0x%x) invalid enum: %d",
1969 get_renderbuffer_parameteriv(struct gl_context
*ctx
, GLuint name
,
1970 GLenum pname
, GLint
*params
)
1972 struct gl_renderbuffer
*rb
= _mesa_lookup_renderbuffer(ctx
, name
);
1974 _mesa_error(ctx
, GL_INVALID_VALUE
,
1975 "glObjectUnpurgeable(name = 0x%x)", name
);
1980 case GL_PURGEABLE_APPLE
:
1981 *params
= rb
->Purgeable
;
1984 _mesa_error(ctx
, GL_INVALID_ENUM
,
1985 "glGetObjectParameteriv(name = 0x%x) invalid enum: %d",
1993 get_texture_object_parameteriv(struct gl_context
*ctx
, GLuint name
,
1994 GLenum pname
, GLint
*params
)
1996 struct gl_texture_object
*texObj
= _mesa_lookup_texture(ctx
, name
);
1998 _mesa_error(ctx
, GL_INVALID_VALUE
,
1999 "glObjectUnpurgeable(name = 0x%x)", name
);
2004 case GL_PURGEABLE_APPLE
:
2005 *params
= texObj
->Purgeable
;
2008 _mesa_error(ctx
, GL_INVALID_ENUM
,
2009 "glGetObjectParameteriv(name = 0x%x) invalid enum: %d",
2017 _mesa_GetObjectParameterivAPPLE(GLenum objectType
, GLuint name
, GLenum pname
,
2020 GET_CURRENT_CONTEXT(ctx
);
2023 _mesa_error(ctx
, GL_INVALID_VALUE
,
2024 "glGetObjectParameteriv(name = 0x%x)", name
);
2028 switch (objectType
) {
2030 get_texture_object_parameteriv(ctx
, name
, pname
, params
);
2032 case GL_BUFFER_OBJECT_APPLE
:
2033 get_buffer_object_parameteriv(ctx
, name
, pname
, params
);
2035 case GL_RENDERBUFFER_EXT
:
2036 get_renderbuffer_parameteriv(ctx
, name
, pname
, params
);
2039 _mesa_error(ctx
, GL_INVALID_ENUM
,
2040 "glGetObjectParameteriv(name = 0x%x) invalid type: %d",
2046 set_ubo_binding(struct gl_context
*ctx
,
2048 struct gl_buffer_object
*bufObj
,
2053 struct gl_uniform_buffer_binding
*binding
;
2055 binding
= &ctx
->UniformBufferBindings
[index
];
2056 if (binding
->BufferObject
== bufObj
&&
2057 binding
->Offset
== offset
&&
2058 binding
->Size
== size
&&
2059 binding
->AutomaticSize
== autoSize
) {
2063 FLUSH_VERTICES(ctx
, _NEW_BUFFER_OBJECT
);
2065 _mesa_reference_buffer_object(ctx
, &binding
->BufferObject
, bufObj
);
2066 binding
->Offset
= offset
;
2067 binding
->Size
= size
;
2068 binding
->AutomaticSize
= autoSize
;
2072 * Bind a region of a buffer object to a uniform block binding point.
2073 * \param index the uniform buffer binding point index
2074 * \param bufObj the buffer object
2075 * \param offset offset to the start of buffer object region
2076 * \param size size of the buffer object region
2079 bind_buffer_range_uniform_buffer(struct gl_context
*ctx
,
2081 struct gl_buffer_object
*bufObj
,
2085 if (index
>= ctx
->Const
.MaxUniformBufferBindings
) {
2086 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindBufferRange(index=%d)", index
);
2090 if (offset
& (ctx
->Const
.UniformBufferOffsetAlignment
- 1)) {
2091 _mesa_error(ctx
, GL_INVALID_VALUE
,
2092 "glBindBufferRange(offset misalgned %d/%d)", (int) offset
,
2093 ctx
->Const
.UniformBufferOffsetAlignment
);
2097 if (bufObj
== ctx
->Shared
->NullBufferObj
) {
2102 _mesa_reference_buffer_object(ctx
, &ctx
->UniformBuffer
, bufObj
);
2103 set_ubo_binding(ctx
, index
, bufObj
, offset
, size
, GL_FALSE
);
2108 * Bind a buffer object to a uniform block binding point.
2109 * As above, but offset = 0.
2112 bind_buffer_base_uniform_buffer(struct gl_context
*ctx
,
2114 struct gl_buffer_object
*bufObj
)
2116 if (index
>= ctx
->Const
.MaxUniformBufferBindings
) {
2117 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindBufferBase(index=%d)", index
);
2121 _mesa_reference_buffer_object(ctx
, &ctx
->UniformBuffer
, bufObj
);
2122 if (bufObj
== ctx
->Shared
->NullBufferObj
)
2123 set_ubo_binding(ctx
, index
, bufObj
, -1, -1, GL_TRUE
);
2125 set_ubo_binding(ctx
, index
, bufObj
, 0, 0, GL_TRUE
);
2129 _mesa_BindBufferRange(GLenum target
, GLuint index
,
2130 GLuint buffer
, GLintptr offset
, GLsizeiptr size
)
2132 GET_CURRENT_CONTEXT(ctx
);
2133 struct gl_buffer_object
*bufObj
;
2136 bufObj
= ctx
->Shared
->NullBufferObj
;
2138 bufObj
= _mesa_lookup_bufferobj(ctx
, buffer
);
2140 if (!handle_bind_buffer_gen(ctx
, target
, buffer
, &bufObj
))
2144 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2145 "glBindBufferRange(invalid buffer=%u)", buffer
);
2151 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindBufferRange(size=%d)",
2156 if (offset
+ size
> bufObj
->Size
) {
2157 _mesa_error(ctx
, GL_INVALID_VALUE
,
2158 "glBindBufferRange(offset + size %d > buffer size %d)",
2159 (int) (offset
+ size
), (int) (bufObj
->Size
));
2165 case GL_TRANSFORM_FEEDBACK_BUFFER
:
2166 _mesa_bind_buffer_range_transform_feedback(ctx
, index
, bufObj
,
2169 case GL_UNIFORM_BUFFER
:
2170 bind_buffer_range_uniform_buffer(ctx
, index
, bufObj
, offset
, size
);
2173 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindBufferRange(target)");
2179 _mesa_BindBufferBase(GLenum target
, GLuint index
, GLuint buffer
)
2181 GET_CURRENT_CONTEXT(ctx
);
2182 struct gl_buffer_object
*bufObj
;
2185 bufObj
= ctx
->Shared
->NullBufferObj
;
2187 bufObj
= _mesa_lookup_bufferobj(ctx
, buffer
);
2189 if (!handle_bind_buffer_gen(ctx
, target
, buffer
, &bufObj
))
2193 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2194 "glBindBufferBase(invalid buffer=%u)", buffer
);
2198 /* Note that there's some oddness in the GL 3.1-GL 3.3 specifications with
2199 * regards to BindBufferBase. It says (GL 3.1 core spec, page 63):
2201 * "BindBufferBase is equivalent to calling BindBufferRange with offset
2202 * zero and size equal to the size of buffer."
2204 * but it says for glGetIntegeri_v (GL 3.1 core spec, page 230):
2206 * "If the parameter (starting offset or size) was not specified when the
2207 * buffer object was bound, zero is returned."
2209 * What happens if the size of the buffer changes? Does the size of the
2210 * buffer at the moment glBindBufferBase was called still play a role, like
2211 * the first quote would imply, or is the size meaningless in the
2212 * glBindBufferBase case like the second quote would suggest? The GL 4.1
2213 * core spec page 45 says:
2215 * "It is equivalent to calling BindBufferRange with offset zero, while
2216 * size is determined by the size of the bound buffer at the time the
2219 * My interpretation is that the GL 4.1 spec was a clarification of the
2220 * behavior, not a change. In particular, this choice will only make
2221 * rendering work in cases where it would have had undefined results.
2225 case GL_TRANSFORM_FEEDBACK_BUFFER
:
2226 _mesa_bind_buffer_base_transform_feedback(ctx
, index
, bufObj
);
2228 case GL_UNIFORM_BUFFER
:
2229 bind_buffer_base_uniform_buffer(ctx
, index
, bufObj
);
2232 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindBufferBase(target)");
2238 _mesa_InvalidateBufferSubData(GLuint buffer
, GLintptr offset
,
2241 GET_CURRENT_CONTEXT(ctx
);
2242 struct gl_buffer_object
*bufObj
;
2243 const GLintptr end
= offset
+ length
;
2245 bufObj
= _mesa_lookup_bufferobj(ctx
, buffer
);
2247 _mesa_error(ctx
, GL_INVALID_VALUE
,
2248 "glInvalidateBufferSubData(name = 0x%x) invalid object",
2253 /* The GL_ARB_invalidate_subdata spec says:
2255 * "An INVALID_VALUE error is generated if <offset> or <length> is
2256 * negative, or if <offset> + <length> is greater than the value of
2259 if (end
< 0 || end
> bufObj
->Size
) {
2260 _mesa_error(ctx
, GL_INVALID_VALUE
,
2261 "glInvalidateBufferSubData(invalid offset or length)");
2265 /* The GL_ARB_invalidate_subdata spec says:
2267 * "An INVALID_OPERATION error is generated if the buffer is currently
2268 * mapped by MapBuffer, or if the invalidate range intersects the range
2269 * currently mapped by MapBufferRange."
2271 if (_mesa_bufferobj_mapped(bufObj
)) {
2272 const GLintptr mapEnd
= bufObj
->Offset
+ bufObj
->Length
;
2274 /* The regions do not overlap if and only if the end of the discard
2275 * region is before the mapped region or the start of the discard region
2276 * is after the mapped region.
2278 * Note that 'end' and 'mapEnd' are the first byte *after* the discard
2279 * region and the mapped region, repsectively. It is okay for that byte
2280 * to be mapped (for 'end') or discarded (for 'mapEnd').
2282 if (!(end
<= bufObj
->Offset
|| offset
>= mapEnd
)) {
2283 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2284 "glInvalidateBufferSubData(intersection with mapped "
2290 /* We don't actually do anything for this yet. Just return after
2291 * validating the parameters and generating the required errors.
2297 _mesa_InvalidateBufferData(GLuint buffer
)
2299 GET_CURRENT_CONTEXT(ctx
);
2300 struct gl_buffer_object
*bufObj
;
2302 bufObj
= _mesa_lookup_bufferobj(ctx
, buffer
);
2304 _mesa_error(ctx
, GL_INVALID_VALUE
,
2305 "glInvalidateBufferData(name = 0x%x) invalid object",
2310 /* The GL_ARB_invalidate_subdata spec says:
2312 * "An INVALID_OPERATION error is generated if the buffer is currently
2313 * mapped by MapBuffer, or if the invalidate range intersects the range
2314 * currently mapped by MapBufferRange."
2316 if (_mesa_bufferobj_mapped(bufObj
)) {
2317 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2318 "glInvalidateBufferData(intersection with mapped "
2323 /* We don't actually do anything for this yet. Just return after
2324 * validating the parameters and generating the required errors.