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
);
64 * Is the given buffer object a user-created buffer object?
65 * Mesa uses default buffer objects in several places. Default buffers
66 * always have Name==0. User created buffers have Name!=0.
68 static inline GLboolean
69 _mesa_is_bufferobj(const struct gl_buffer_object
*obj
)
71 return obj
!= NULL
&& obj
->Name
!= 0;
76 _mesa_init_buffer_objects(struct gl_context
*ctx
);
79 _mesa_free_buffer_objects(struct gl_context
*ctx
);
82 _mesa_handle_bind_buffer_gen(struct gl_context
*ctx
,
84 struct gl_buffer_object
**buf_handle
,
88 _mesa_update_default_objects_buffer_objects(struct gl_context
*ctx
);
91 extern struct gl_buffer_object
*
92 _mesa_lookup_bufferobj(struct gl_context
*ctx
, GLuint buffer
);
94 extern struct gl_buffer_object
*
95 _mesa_lookup_bufferobj_locked(struct gl_context
*ctx
, GLuint buffer
);
97 extern struct gl_buffer_object
*
98 _mesa_lookup_bufferobj_err(struct gl_context
*ctx
, GLuint buffer
,
101 extern struct gl_buffer_object
*
102 _mesa_multi_bind_lookup_bufferobj(struct gl_context
*ctx
,
103 const GLuint
*buffers
,
104 GLuint index
, const char *caller
,
108 _mesa_initialize_buffer_object(struct gl_context
*ctx
,
109 struct gl_buffer_object
*obj
,
113 _mesa_delete_buffer_object(struct gl_context
*ctx
,
114 struct gl_buffer_object
*bufObj
);
117 _mesa_reference_buffer_object_(struct gl_context
*ctx
,
118 struct gl_buffer_object
**ptr
,
119 struct gl_buffer_object
*bufObj
);
122 _mesa_reference_buffer_object(struct gl_context
*ctx
,
123 struct gl_buffer_object
**ptr
,
124 struct gl_buffer_object
*bufObj
)
127 _mesa_reference_buffer_object_(ctx
, ptr
, bufObj
);
131 _mesa_total_buffer_object_memory(struct gl_context
*ctx
);
134 _mesa_init_buffer_object_functions(struct dd_function_table
*driver
);
137 _mesa_buffer_data(struct gl_context
*ctx
, struct gl_buffer_object
*bufObj
,
138 GLenum target
, GLsizeiptr size
, const GLvoid
*data
,
139 GLenum usage
, const char *func
);
142 _mesa_buffer_sub_data(struct gl_context
*ctx
, struct gl_buffer_object
*bufObj
,
143 GLintptr offset
, GLsizeiptr size
, const GLvoid
*data
);
146 _mesa_buffer_unmap_all_mappings(struct gl_context
*ctx
,
147 struct gl_buffer_object
*bufObj
);
150 _mesa_ClearBufferSubData_sw(struct gl_context
*ctx
,
151 GLintptr offset
, GLsizeiptr size
,
152 const GLvoid
*clearValue
,
153 GLsizeiptr clearValueSize
,
154 struct gl_buffer_object
*bufObj
);
160 _mesa_BindBuffer_no_error(GLenum target
, GLuint buffer
);
163 _mesa_BindBuffer(GLenum target
, GLuint buffer
);
166 _mesa_DeleteBuffers_no_error(GLsizei n
, const GLuint
* buffer
);
169 _mesa_DeleteBuffers(GLsizei n
, const GLuint
* buffer
);
172 _mesa_GenBuffers_no_error(GLsizei n
, GLuint
*buffers
);
175 _mesa_GenBuffers(GLsizei n
, GLuint
*buffers
);
178 _mesa_CreateBuffers_no_error(GLsizei n
, GLuint
*buffers
);
181 _mesa_CreateBuffers(GLsizei n
, GLuint
*buffers
);
184 _mesa_IsBuffer(GLuint buffer
);
187 _mesa_BufferStorage_no_error(GLenum target
, GLsizeiptr size
,
188 const GLvoid
*data
, GLbitfield flags
);
190 _mesa_BufferStorage(GLenum target
, GLsizeiptr size
, const GLvoid
*data
,
193 _mesa_NamedBufferStorageEXT(GLuint buffer
, GLsizeiptr size
,
194 const GLvoid
*data
, GLbitfield flags
);
196 _mesa_BufferStorageMemEXT(GLenum target
, GLsizeiptr size
,
197 GLuint memory
, GLuint64 offset
);
199 _mesa_BufferStorageMemEXT_no_error(GLenum target
, GLsizeiptr size
,
200 GLuint memory
, GLuint64 offset
);
202 _mesa_NamedBufferStorage_no_error(GLuint buffer
, GLsizeiptr size
,
203 const GLvoid
*data
, GLbitfield flags
);
205 _mesa_NamedBufferStorage(GLuint buffer
, GLsizeiptr size
, const GLvoid
*data
,
208 _mesa_NamedBufferStorageMemEXT(GLuint buffer
, GLsizeiptr size
,
209 GLuint memory
, GLuint64 offset
);
211 _mesa_NamedBufferStorageMemEXT_no_error(GLuint buffer
, GLsizeiptr size
,
212 GLuint memory
, GLuint64 offset
);
215 _mesa_BufferData_no_error(GLenum target
, GLsizeiptr size
,
216 const GLvoid
*data
, GLenum usage
);
219 _mesa_BufferData(GLenum target
, GLsizeiptr size
,
220 const GLvoid
*data
, GLenum usage
);
223 _mesa_NamedBufferData_no_error(GLuint buffer
, GLsizeiptr size
,
224 const GLvoid
*data
, GLenum usage
);
227 _mesa_NamedBufferData(GLuint buffer
, GLsizeiptr size
,
228 const GLvoid
*data
, GLenum usage
);
230 _mesa_NamedBufferDataEXT(GLuint buffer
, GLsizeiptr size
,
231 const GLvoid
*data
, GLenum usage
);
234 _mesa_BufferSubData_no_error(GLenum target
, GLintptr offset
,
235 GLsizeiptr size
, const GLvoid
*data
);
237 _mesa_BufferSubData(GLenum target
, GLintptr offset
,
238 GLsizeiptr size
, const GLvoid
*data
);
241 _mesa_NamedBufferSubData_no_error(GLuint buffer
, GLintptr offset
,
242 GLsizeiptr size
, const GLvoid
*data
);
244 _mesa_NamedBufferSubData(GLuint buffer
, GLintptr offset
,
245 GLsizeiptr size
, const GLvoid
*data
);
247 _mesa_NamedBufferSubDataEXT(GLuint buffer
, GLintptr offset
,
248 GLsizeiptr size
, const GLvoid
*data
);
251 _mesa_GetBufferSubData(GLenum target
, GLintptr offset
,
252 GLsizeiptr size
, GLvoid
*data
);
255 _mesa_GetNamedBufferSubData(GLuint buffer
, GLintptr offset
,
256 GLsizeiptr size
, GLvoid
*data
);
259 _mesa_GetNamedBufferSubDataEXT(GLuint buffer
, GLintptr offset
,
260 GLsizeiptr size
, GLvoid
*data
);
263 _mesa_ClearBufferData_no_error(GLenum target
, GLenum internalformat
,
264 GLenum format
, GLenum type
, const GLvoid
*data
);
267 _mesa_ClearBufferData(GLenum target
, GLenum internalformat
,
268 GLenum format
, GLenum type
,
272 _mesa_ClearNamedBufferData_no_error(GLuint buffer
, GLenum internalformat
,
273 GLenum format
, GLenum type
,
277 _mesa_ClearNamedBufferData(GLuint buffer
, GLenum internalformat
,
278 GLenum format
, GLenum type
,
282 _mesa_ClearNamedBufferDataEXT(GLuint buffer
, GLenum internalformat
,
283 GLenum format
, GLenum type
,
287 _mesa_ClearBufferSubData_no_error(GLenum target
, GLenum internalformat
,
288 GLintptr offset
, GLsizeiptr size
,
289 GLenum format
, GLenum type
,
293 _mesa_ClearBufferSubData(GLenum target
, GLenum internalformat
,
294 GLintptr offset
, GLsizeiptr size
,
295 GLenum format
, GLenum type
,
299 _mesa_ClearNamedBufferSubData_no_error(GLuint buffer
, GLenum internalformat
,
300 GLintptr offset
, GLsizeiptr size
,
301 GLenum format
, GLenum type
,
305 _mesa_ClearNamedBufferSubData(GLuint buffer
, GLenum internalformat
,
306 GLintptr offset
, GLsizeiptr size
,
307 GLenum format
, GLenum type
,
311 _mesa_ClearNamedBufferSubDataEXT(GLuint buffer
, GLenum internalformat
,
312 GLintptr offset
, GLsizeiptr size
,
313 GLenum format
, GLenum type
,
317 _mesa_UnmapBuffer_no_error(GLenum target
);
319 _mesa_UnmapBuffer(GLenum target
);
322 _mesa_UnmapNamedBufferEXT_no_error(GLuint buffer
);
324 _mesa_UnmapNamedBufferEXT(GLuint buffer
);
327 _mesa_GetBufferParameteriv(GLenum target
, GLenum pname
, GLint
*params
);
330 _mesa_GetBufferParameteri64v(GLenum target
, GLenum pname
, GLint64
*params
);
333 _mesa_GetNamedBufferParameteriv(GLuint buffer
, GLenum pname
, GLint
*params
);
336 _mesa_GetNamedBufferParameterivEXT(GLuint buffer
, GLenum pname
, GLint
*params
);
339 _mesa_GetNamedBufferParameteri64v(GLuint buffer
, GLenum pname
,
343 _mesa_GetBufferPointerv(GLenum target
, GLenum pname
, GLvoid
**params
);
346 _mesa_GetNamedBufferPointerv(GLuint buffer
, GLenum pname
, GLvoid
**params
);
349 _mesa_GetNamedBufferPointervEXT(GLuint buffer
, GLenum pname
, GLvoid
**params
);
352 _mesa_CopyBufferSubData_no_error(GLenum readTarget
, GLenum writeTarget
,
353 GLintptr readOffset
, GLintptr writeOffset
,
356 _mesa_CopyBufferSubData(GLenum readTarget
, GLenum writeTarget
,
357 GLintptr readOffset
, GLintptr writeOffset
,
361 _mesa_NamedCopyBufferSubDataEXT(GLuint readBuffer
, GLuint writeBuffer
,
362 GLintptr readOffset
, GLintptr writeOffset
,
366 _mesa_CopyNamedBufferSubData_no_error(GLuint readBuffer
, GLuint writeBuffer
,
368 GLintptr writeOffset
, GLsizeiptr size
);
370 _mesa_CopyNamedBufferSubData(GLuint readBuffer
, GLuint writeBuffer
,
371 GLintptr readOffset
, GLintptr writeOffset
,
375 _mesa_MapBufferRange_no_error(GLenum target
, GLintptr offset
,
376 GLsizeiptr length
, GLbitfield access
);
378 _mesa_MapBufferRange(GLenum target
, GLintptr offset
, GLsizeiptr length
,
382 _mesa_MapNamedBufferRange_no_error(GLuint buffer
, GLintptr offset
,
383 GLsizeiptr length
, GLbitfield access
);
385 _mesa_MapNamedBufferRange(GLuint buffer
, GLintptr offset
, GLsizeiptr length
,
388 _mesa_MapNamedBufferRangeEXT(GLuint buffer
, GLintptr offset
,
389 GLsizeiptr length
, GLbitfield access
);
392 _mesa_MapBuffer_no_error(GLenum target
, GLenum access
);
394 _mesa_MapBuffer(GLenum target
, GLenum access
);
397 _mesa_MapNamedBuffer_no_error(GLuint buffer
, GLenum access
);
399 _mesa_MapNamedBuffer(GLuint buffer
, GLenum access
);
401 _mesa_MapNamedBufferEXT(GLuint buffer
, GLenum access
);
404 _mesa_FlushMappedBufferRange_no_error(GLenum target
, GLintptr offset
,
407 _mesa_FlushMappedBufferRange(GLenum target
,
408 GLintptr offset
, GLsizeiptr length
);
411 _mesa_FlushMappedNamedBufferRange_no_error(GLuint buffer
, GLintptr offset
,
414 _mesa_FlushMappedNamedBufferRange(GLuint buffer
, GLintptr offset
,
418 _mesa_FlushMappedNamedBufferRangeEXT(GLuint buffer
, GLintptr offset
,
422 _mesa_BindBufferRange_no_error(GLenum target
, GLuint index
, GLuint buffer
,
423 GLintptr offset
, GLsizeiptr size
);
425 _mesa_BindBufferRange(GLenum target
, GLuint index
,
426 GLuint buffer
, GLintptr offset
, GLsizeiptr size
);
429 _mesa_BindBufferBase(GLenum target
, GLuint index
, GLuint buffer
);
432 _mesa_BindBuffersRange(GLenum target
, GLuint first
, GLsizei count
,
433 const GLuint
*buffers
,
434 const GLintptr
*offsets
, const GLsizeiptr
*sizes
);
436 _mesa_BindBuffersBase(GLenum target
, GLuint first
, GLsizei count
,
437 const GLuint
*buffers
);
440 _mesa_InvalidateBufferSubData_no_error(GLuint buffer
, GLintptr offset
,
444 _mesa_InvalidateBufferSubData(GLuint buffer
, GLintptr offset
,
448 _mesa_InvalidateBufferData_no_error(GLuint buffer
);
451 _mesa_InvalidateBufferData(GLuint buffer
);
454 _mesa_BufferPageCommitmentARB(GLenum target
, GLintptr offset
, GLsizeiptr size
,
458 _mesa_NamedBufferPageCommitmentARB(GLuint buffer
, GLintptr offset
,
459 GLsizeiptr size
, GLboolean commit
);
462 _mesa_NamedBufferPageCommitmentEXT(GLuint buffer
, GLintptr offset
,
463 GLsizeiptr size
, GLboolean commit
);