2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
40 /** Is the given buffer object currently mapped by the GL user? */
41 static inline GLboolean
42 _mesa_bufferobj_mapped(const struct gl_buffer_object
*obj
,
43 gl_map_buffer_index index
)
45 return obj
->Mappings
[index
].Pointer
!= NULL
;
49 * Check whether the given buffer object is illegally mapped prior to
50 * drawing from (or reading back to) the buffer.
51 * Note that it's legal for a buffer to be mapped at draw/readback time
52 * if it was mapped persistently (See GL_ARB_buffer_storage spec).
53 * \return true if the buffer is illegally mapped, false otherwise
56 _mesa_check_disallowed_mapping(const struct gl_buffer_object
*obj
)
58 return _mesa_bufferobj_mapped(obj
, MAP_USER
) &&
59 !(obj
->Mappings
[MAP_USER
].AccessFlags
&
60 GL_MAP_PERSISTENT_BIT
);
65 _mesa_init_buffer_objects(struct gl_context
*ctx
);
68 _mesa_free_buffer_objects(struct gl_context
*ctx
);
71 _mesa_handle_bind_buffer_gen(struct gl_context
*ctx
,
73 struct gl_buffer_object
**buf_handle
,
77 _mesa_update_default_objects_buffer_objects(struct gl_context
*ctx
);
80 extern struct gl_buffer_object
*
81 _mesa_lookup_bufferobj(struct gl_context
*ctx
, GLuint buffer
);
83 extern struct gl_buffer_object
*
84 _mesa_lookup_bufferobj_locked(struct gl_context
*ctx
, GLuint buffer
);
86 extern struct gl_buffer_object
*
87 _mesa_lookup_bufferobj_err(struct gl_context
*ctx
, GLuint buffer
,
90 extern struct gl_buffer_object
*
91 _mesa_multi_bind_lookup_bufferobj(struct gl_context
*ctx
,
92 const GLuint
*buffers
,
93 GLuint index
, const char *caller
,
97 _mesa_initialize_buffer_object(struct gl_context
*ctx
,
98 struct gl_buffer_object
*obj
,
102 _mesa_delete_buffer_object(struct gl_context
*ctx
,
103 struct gl_buffer_object
*bufObj
);
106 _mesa_reference_buffer_object_(struct gl_context
*ctx
,
107 struct gl_buffer_object
**ptr
,
108 struct gl_buffer_object
*bufObj
);
111 _mesa_reference_buffer_object(struct gl_context
*ctx
,
112 struct gl_buffer_object
**ptr
,
113 struct gl_buffer_object
*bufObj
)
116 _mesa_reference_buffer_object_(ctx
, ptr
, bufObj
);
120 _mesa_total_buffer_object_memory(struct gl_context
*ctx
);
123 _mesa_init_buffer_object_functions(struct dd_function_table
*driver
);
126 _mesa_buffer_data(struct gl_context
*ctx
, struct gl_buffer_object
*bufObj
,
127 GLenum target
, GLsizeiptr size
, const GLvoid
*data
,
128 GLenum usage
, const char *func
);
131 _mesa_buffer_sub_data(struct gl_context
*ctx
, struct gl_buffer_object
*bufObj
,
132 GLintptr offset
, GLsizeiptr size
, const GLvoid
*data
);
135 _mesa_buffer_unmap_all_mappings(struct gl_context
*ctx
,
136 struct gl_buffer_object
*bufObj
);
139 _mesa_ClearBufferSubData_sw(struct gl_context
*ctx
,
140 GLintptr offset
, GLsizeiptr size
,
141 const GLvoid
*clearValue
,
142 GLsizeiptr clearValueSize
,
143 struct gl_buffer_object
*bufObj
);
149 _mesa_BindBuffer_no_error(GLenum target
, GLuint buffer
);
152 _mesa_BindBuffer(GLenum target
, GLuint buffer
);
155 _mesa_DeleteBuffers_no_error(GLsizei n
, const GLuint
* buffer
);
158 _mesa_DeleteBuffers(GLsizei n
, const GLuint
* buffer
);
161 _mesa_GenBuffers_no_error(GLsizei n
, GLuint
*buffers
);
164 _mesa_GenBuffers(GLsizei n
, GLuint
*buffers
);
167 _mesa_CreateBuffers_no_error(GLsizei n
, GLuint
*buffers
);
170 _mesa_CreateBuffers(GLsizei n
, GLuint
*buffers
);
173 _mesa_IsBuffer(GLuint buffer
);
176 _mesa_BufferStorage_no_error(GLenum target
, GLsizeiptr size
,
177 const GLvoid
*data
, GLbitfield flags
);
179 _mesa_BufferStorage(GLenum target
, GLsizeiptr size
, const GLvoid
*data
,
182 _mesa_NamedBufferStorageEXT(GLuint buffer
, GLsizeiptr size
,
183 const GLvoid
*data
, GLbitfield flags
);
185 _mesa_BufferStorageMemEXT(GLenum target
, GLsizeiptr size
,
186 GLuint memory
, GLuint64 offset
);
188 _mesa_BufferStorageMemEXT_no_error(GLenum target
, GLsizeiptr size
,
189 GLuint memory
, GLuint64 offset
);
191 _mesa_NamedBufferStorage_no_error(GLuint buffer
, GLsizeiptr size
,
192 const GLvoid
*data
, GLbitfield flags
);
194 _mesa_NamedBufferStorage(GLuint buffer
, GLsizeiptr size
, const GLvoid
*data
,
197 _mesa_NamedBufferStorageMemEXT(GLuint buffer
, GLsizeiptr size
,
198 GLuint memory
, GLuint64 offset
);
200 _mesa_NamedBufferStorageMemEXT_no_error(GLuint buffer
, GLsizeiptr size
,
201 GLuint memory
, GLuint64 offset
);
204 _mesa_BufferData_no_error(GLenum target
, GLsizeiptr size
,
205 const GLvoid
*data
, GLenum usage
);
208 _mesa_BufferData(GLenum target
, GLsizeiptr size
,
209 const GLvoid
*data
, GLenum usage
);
212 _mesa_NamedBufferData_no_error(GLuint buffer
, GLsizeiptr size
,
213 const GLvoid
*data
, GLenum usage
);
216 _mesa_NamedBufferData(GLuint buffer
, GLsizeiptr size
,
217 const GLvoid
*data
, GLenum usage
);
219 _mesa_NamedBufferDataEXT(GLuint buffer
, GLsizeiptr size
,
220 const GLvoid
*data
, GLenum usage
);
223 _mesa_BufferSubData_no_error(GLenum target
, GLintptr offset
,
224 GLsizeiptr size
, const GLvoid
*data
);
226 _mesa_BufferSubData(GLenum target
, GLintptr offset
,
227 GLsizeiptr size
, const GLvoid
*data
);
230 _mesa_NamedBufferSubData_no_error(GLuint buffer
, GLintptr offset
,
231 GLsizeiptr size
, const GLvoid
*data
);
233 _mesa_NamedBufferSubData(GLuint buffer
, GLintptr offset
,
234 GLsizeiptr size
, const GLvoid
*data
);
236 _mesa_NamedBufferSubDataEXT(GLuint buffer
, GLintptr offset
,
237 GLsizeiptr size
, const GLvoid
*data
);
240 _mesa_GetBufferSubData(GLenum target
, GLintptr offset
,
241 GLsizeiptr size
, GLvoid
*data
);
244 _mesa_GetNamedBufferSubData(GLuint buffer
, GLintptr offset
,
245 GLsizeiptr size
, GLvoid
*data
);
248 _mesa_GetNamedBufferSubDataEXT(GLuint buffer
, GLintptr offset
,
249 GLsizeiptr size
, GLvoid
*data
);
252 _mesa_ClearBufferData_no_error(GLenum target
, GLenum internalformat
,
253 GLenum format
, GLenum type
, const GLvoid
*data
);
256 _mesa_ClearBufferData(GLenum target
, GLenum internalformat
,
257 GLenum format
, GLenum type
,
261 _mesa_ClearNamedBufferData_no_error(GLuint buffer
, GLenum internalformat
,
262 GLenum format
, GLenum type
,
266 _mesa_ClearNamedBufferData(GLuint buffer
, GLenum internalformat
,
267 GLenum format
, GLenum type
,
271 _mesa_ClearNamedBufferDataEXT(GLuint buffer
, GLenum internalformat
,
272 GLenum format
, GLenum type
,
276 _mesa_ClearBufferSubData_no_error(GLenum target
, GLenum internalformat
,
277 GLintptr offset
, GLsizeiptr size
,
278 GLenum format
, GLenum type
,
282 _mesa_ClearBufferSubData(GLenum target
, GLenum internalformat
,
283 GLintptr offset
, GLsizeiptr size
,
284 GLenum format
, GLenum type
,
288 _mesa_ClearNamedBufferSubData_no_error(GLuint buffer
, GLenum internalformat
,
289 GLintptr offset
, GLsizeiptr size
,
290 GLenum format
, GLenum type
,
294 _mesa_ClearNamedBufferSubData(GLuint buffer
, GLenum internalformat
,
295 GLintptr offset
, GLsizeiptr size
,
296 GLenum format
, GLenum type
,
300 _mesa_ClearNamedBufferSubDataEXT(GLuint buffer
, GLenum internalformat
,
301 GLintptr offset
, GLsizeiptr size
,
302 GLenum format
, GLenum type
,
306 _mesa_UnmapBuffer_no_error(GLenum target
);
308 _mesa_UnmapBuffer(GLenum target
);
311 _mesa_UnmapNamedBufferEXT_no_error(GLuint buffer
);
313 _mesa_UnmapNamedBufferEXT(GLuint buffer
);
316 _mesa_GetBufferParameteriv(GLenum target
, GLenum pname
, GLint
*params
);
319 _mesa_GetBufferParameteri64v(GLenum target
, GLenum pname
, GLint64
*params
);
322 _mesa_GetNamedBufferParameteriv(GLuint buffer
, GLenum pname
, GLint
*params
);
325 _mesa_GetNamedBufferParameterivEXT(GLuint buffer
, GLenum pname
, GLint
*params
);
328 _mesa_GetNamedBufferParameteri64v(GLuint buffer
, GLenum pname
,
332 _mesa_GetBufferPointerv(GLenum target
, GLenum pname
, GLvoid
**params
);
335 _mesa_GetNamedBufferPointerv(GLuint buffer
, GLenum pname
, GLvoid
**params
);
338 _mesa_GetNamedBufferPointervEXT(GLuint buffer
, GLenum pname
, GLvoid
**params
);
341 _mesa_CopyBufferSubData_no_error(GLenum readTarget
, GLenum writeTarget
,
342 GLintptr readOffset
, GLintptr writeOffset
,
345 _mesa_CopyBufferSubData(GLenum readTarget
, GLenum writeTarget
,
346 GLintptr readOffset
, GLintptr writeOffset
,
350 _mesa_NamedCopyBufferSubDataEXT(GLuint readBuffer
, GLuint writeBuffer
,
351 GLintptr readOffset
, GLintptr writeOffset
,
355 _mesa_CopyNamedBufferSubData_no_error(GLuint readBuffer
, GLuint writeBuffer
,
357 GLintptr writeOffset
, GLsizeiptr size
);
359 _mesa_CopyNamedBufferSubData(GLuint readBuffer
, GLuint writeBuffer
,
360 GLintptr readOffset
, GLintptr writeOffset
,
363 _mesa_InternalBufferSubDataCopyMESA(GLintptr srcBuffer
, GLuint srcOffset
,
364 GLuint dstTargetOrName
, GLintptr dstOffset
,
365 GLsizeiptr size
, GLboolean named
,
369 _mesa_MapBufferRange_no_error(GLenum target
, GLintptr offset
,
370 GLsizeiptr length
, GLbitfield access
);
372 _mesa_MapBufferRange(GLenum target
, GLintptr offset
, GLsizeiptr length
,
376 _mesa_MapNamedBufferRange_no_error(GLuint buffer
, GLintptr offset
,
377 GLsizeiptr length
, GLbitfield access
);
379 _mesa_MapNamedBufferRange(GLuint buffer
, GLintptr offset
, GLsizeiptr length
,
382 _mesa_MapNamedBufferRangeEXT(GLuint buffer
, GLintptr offset
,
383 GLsizeiptr length
, GLbitfield access
);
386 _mesa_MapBuffer_no_error(GLenum target
, GLenum access
);
388 _mesa_MapBuffer(GLenum target
, GLenum access
);
391 _mesa_MapNamedBuffer_no_error(GLuint buffer
, GLenum access
);
393 _mesa_MapNamedBuffer(GLuint buffer
, GLenum access
);
395 _mesa_MapNamedBufferEXT(GLuint buffer
, GLenum access
);
398 _mesa_FlushMappedBufferRange_no_error(GLenum target
, GLintptr offset
,
401 _mesa_FlushMappedBufferRange(GLenum target
,
402 GLintptr offset
, GLsizeiptr length
);
405 _mesa_FlushMappedNamedBufferRange_no_error(GLuint buffer
, GLintptr offset
,
408 _mesa_FlushMappedNamedBufferRange(GLuint buffer
, GLintptr offset
,
412 _mesa_FlushMappedNamedBufferRangeEXT(GLuint buffer
, GLintptr offset
,
416 _mesa_BindBufferRange_no_error(GLenum target
, GLuint index
, GLuint buffer
,
417 GLintptr offset
, GLsizeiptr size
);
419 _mesa_BindBufferRange(GLenum target
, GLuint index
,
420 GLuint buffer
, GLintptr offset
, GLsizeiptr size
);
423 _mesa_BindBufferBase(GLenum target
, GLuint index
, GLuint buffer
);
426 _mesa_BindBuffersRange(GLenum target
, GLuint first
, GLsizei count
,
427 const GLuint
*buffers
,
428 const GLintptr
*offsets
, const GLsizeiptr
*sizes
);
430 _mesa_BindBuffersBase(GLenum target
, GLuint first
, GLsizei count
,
431 const GLuint
*buffers
);
434 _mesa_InvalidateBufferSubData_no_error(GLuint buffer
, GLintptr offset
,
438 _mesa_InvalidateBufferSubData(GLuint buffer
, GLintptr offset
,
442 _mesa_InvalidateBufferData_no_error(GLuint buffer
);
445 _mesa_InvalidateBufferData(GLuint buffer
);
448 _mesa_BufferPageCommitmentARB(GLenum target
, GLintptr offset
, GLsizeiptr size
,
452 _mesa_NamedBufferPageCommitmentARB(GLuint buffer
, GLintptr offset
,
453 GLsizeiptr size
, GLboolean commit
);
456 _mesa_NamedBufferPageCommitmentEXT(GLuint buffer
, GLintptr offset
,
457 GLsizeiptr size
, GLboolean commit
);