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
);
107 _mesa_initialize_buffer_object(struct gl_context
*ctx
,
108 struct gl_buffer_object
*obj
,
112 _mesa_delete_buffer_object(struct gl_context
*ctx
,
113 struct gl_buffer_object
*bufObj
);
116 _mesa_reference_buffer_object_(struct gl_context
*ctx
,
117 struct gl_buffer_object
**ptr
,
118 struct gl_buffer_object
*bufObj
);
121 _mesa_reference_buffer_object(struct gl_context
*ctx
,
122 struct gl_buffer_object
**ptr
,
123 struct gl_buffer_object
*bufObj
)
126 _mesa_reference_buffer_object_(ctx
, ptr
, bufObj
);
130 _mesa_total_buffer_object_memory(struct gl_context
*ctx
);
133 _mesa_init_buffer_object_functions(struct dd_function_table
*driver
);
136 _mesa_buffer_storage(struct gl_context
*ctx
, struct gl_buffer_object
*bufObj
,
137 GLenum target
, GLsizeiptr size
, const GLvoid
*data
,
138 GLbitfield flags
, const char *func
);
141 _mesa_buffer_data(struct gl_context
*ctx
, struct gl_buffer_object
*bufObj
,
142 GLenum target
, GLsizeiptr size
, const GLvoid
*data
,
143 GLenum usage
, const char *func
);
146 _mesa_buffer_sub_data(struct gl_context
*ctx
, struct gl_buffer_object
*bufObj
,
147 GLintptr offset
, GLsizeiptr size
, const GLvoid
*data
,
151 _mesa_buffer_unmap_all_mappings(struct gl_context
*ctx
,
152 struct gl_buffer_object
*bufObj
);
155 _mesa_copy_buffer_sub_data(struct gl_context
*ctx
,
156 struct gl_buffer_object
*src
,
157 struct gl_buffer_object
*dst
,
158 GLintptr readOffset
, GLintptr writeOffset
,
159 GLsizeiptr size
, const char *func
);
162 _mesa_ClearBufferSubData_sw(struct gl_context
*ctx
,
163 GLintptr offset
, GLsizeiptr size
,
164 const GLvoid
*clearValue
,
165 GLsizeiptr clearValueSize
,
166 struct gl_buffer_object
*bufObj
);
169 _mesa_clear_buffer_sub_data(struct gl_context
*ctx
,
170 struct gl_buffer_object
*bufObj
,
171 GLenum internalformat
,
172 GLintptr offset
, GLsizeiptr size
,
173 GLenum format
, GLenum type
,
175 const char *func
, bool subdata
);
181 _mesa_BindBuffer(GLenum target
, GLuint buffer
);
184 _mesa_DeleteBuffers(GLsizei n
, const GLuint
* buffer
);
187 _mesa_GenBuffers(GLsizei n
, GLuint
*buffers
);
190 _mesa_CreateBuffers(GLsizei n
, GLuint
*buffers
);
193 _mesa_IsBuffer(GLuint buffer
);
196 _mesa_BufferStorage(GLenum target
, GLsizeiptr size
, const GLvoid
*data
,
200 _mesa_NamedBufferStorage(GLuint buffer
, GLsizeiptr size
, const GLvoid
*data
,
204 _mesa_BufferData(GLenum target
, GLsizeiptr size
,
205 const GLvoid
*data
, GLenum usage
);
208 _mesa_NamedBufferData(GLuint buffer
, GLsizeiptr size
,
209 const GLvoid
*data
, GLenum usage
);
212 _mesa_BufferSubData(GLenum target
, GLintptr offset
,
213 GLsizeiptr size
, const GLvoid
*data
);
216 _mesa_NamedBufferSubData(GLuint buffer
, GLintptr offset
,
217 GLsizeiptr size
, const GLvoid
*data
);
220 _mesa_GetBufferSubData(GLenum target
, GLintptr offset
,
221 GLsizeiptr size
, GLvoid
*data
);
224 _mesa_GetNamedBufferSubData(GLuint buffer
, GLintptr offset
,
225 GLsizeiptr size
, GLvoid
*data
);
228 _mesa_ClearBufferData(GLenum target
, GLenum internalformat
,
229 GLenum format
, GLenum type
,
233 _mesa_ClearNamedBufferData(GLuint buffer
, GLenum internalformat
,
234 GLenum format
, GLenum type
,
238 _mesa_ClearBufferSubData(GLenum target
, GLenum internalformat
,
239 GLintptr offset
, GLsizeiptr size
,
240 GLenum format
, GLenum type
,
244 _mesa_ClearNamedBufferSubData(GLuint buffer
, GLenum internalformat
,
245 GLintptr offset
, GLsizeiptr size
,
246 GLenum format
, GLenum type
,
250 _mesa_UnmapBuffer_no_error(GLenum target
);
252 _mesa_UnmapBuffer(GLenum target
);
255 _mesa_UnmapNamedBuffer_no_error(GLuint buffer
);
257 _mesa_UnmapNamedBuffer(GLuint buffer
);
260 _mesa_GetBufferParameteriv(GLenum target
, GLenum pname
, GLint
*params
);
263 _mesa_GetBufferParameteri64v(GLenum target
, GLenum pname
, GLint64
*params
);
266 _mesa_GetNamedBufferParameteriv(GLuint buffer
, GLenum pname
, GLint
*params
);
269 _mesa_GetNamedBufferParameteri64v(GLuint buffer
, GLenum pname
,
273 _mesa_GetBufferPointerv(GLenum target
, GLenum pname
, GLvoid
**params
);
276 _mesa_GetNamedBufferPointerv(GLuint buffer
, GLenum pname
, GLvoid
**params
);
280 _mesa_CopyBufferSubData(GLenum readTarget
, GLenum writeTarget
,
281 GLintptr readOffset
, GLintptr writeOffset
,
285 _mesa_CopyNamedBufferSubData(GLuint readBuffer
, GLuint writeBuffer
,
286 GLintptr readOffset
, GLintptr writeOffset
,
290 _mesa_MapBufferRange_no_error(GLenum target
, GLintptr offset
,
291 GLsizeiptr length
, GLbitfield access
);
293 _mesa_MapBufferRange(GLenum target
, GLintptr offset
, GLsizeiptr length
,
297 _mesa_MapNamedBufferRange_no_error(GLuint buffer
, GLintptr offset
,
298 GLsizeiptr length
, GLbitfield access
);
300 _mesa_MapNamedBufferRange(GLuint buffer
, GLintptr offset
, GLsizeiptr length
,
304 _mesa_MapBuffer_no_error(GLenum target
, GLenum access
);
306 _mesa_MapBuffer(GLenum target
, GLenum access
);
309 _mesa_MapNamedBuffer_no_error(GLuint buffer
, GLenum access
);
311 _mesa_MapNamedBuffer(GLuint buffer
, GLenum access
);
315 _mesa_FlushMappedBufferRange(GLenum target
,
316 GLintptr offset
, GLsizeiptr length
);
319 _mesa_FlushMappedNamedBufferRange(GLuint buffer
, GLintptr offset
,
323 _mesa_BindBufferRange(GLenum target
, GLuint index
,
324 GLuint buffer
, GLintptr offset
, GLsizeiptr size
);
327 _mesa_BindBufferBase(GLenum target
, GLuint index
, GLuint buffer
);
330 _mesa_BindBuffersRange(GLenum target
, GLuint first
, GLsizei count
,
331 const GLuint
*buffers
,
332 const GLintptr
*offsets
, const GLsizeiptr
*sizes
);
334 _mesa_BindBuffersBase(GLenum target
, GLuint first
, GLsizei count
,
335 const GLuint
*buffers
);
337 _mesa_InvalidateBufferSubData(GLuint buffer
, GLintptr offset
,
341 _mesa_InvalidateBufferData(GLuint buffer
);
344 _mesa_BufferPageCommitmentARB(GLenum target
, GLintptr offset
, GLsizeiptr size
,
348 _mesa_NamedBufferPageCommitmentARB(GLuint buffer
, GLintptr offset
,
349 GLsizeiptr size
, GLboolean commit
);