• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
6  *
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:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
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.
24  */
25 
26 
27 
28 #ifndef BUFFEROBJ_H
29 #define BUFFEROBJ_H
30 
31 #include <stdbool.h>
32 #include "mtypes.h"
33 
34 
35 /*
36  * Internal functions
37  */
38 
39 
40 /** Is the given buffer object currently mapped by the GL user? */
41 static inline GLboolean
_mesa_bufferobj_mapped(const struct gl_buffer_object * obj,gl_map_buffer_index index)42 _mesa_bufferobj_mapped(const struct gl_buffer_object *obj,
43                        gl_map_buffer_index index)
44 {
45    return obj->Mappings[index].Pointer != NULL;
46 }
47 
48 /**
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
54  */
55 static inline bool
_mesa_check_disallowed_mapping(const struct gl_buffer_object * obj)56 _mesa_check_disallowed_mapping(const struct gl_buffer_object *obj)
57 {
58    return _mesa_bufferobj_mapped(obj, MAP_USER) &&
59           !(obj->Mappings[MAP_USER].AccessFlags &
60             GL_MAP_PERSISTENT_BIT);
61 }
62 
63 
64 extern void
65 _mesa_init_buffer_objects(struct gl_context *ctx);
66 
67 extern void
68 _mesa_free_buffer_objects(struct gl_context *ctx);
69 
70 extern bool
71 _mesa_handle_bind_buffer_gen(struct gl_context *ctx,
72                              GLuint buffer,
73                              struct gl_buffer_object **buf_handle,
74                              const char *caller);
75 
76 extern void
77 _mesa_update_default_objects_buffer_objects(struct gl_context *ctx);
78 
79 
80 extern struct gl_buffer_object *
81 _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer);
82 
83 extern struct gl_buffer_object *
84 _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer);
85 
86 extern struct gl_buffer_object *
87 _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
88                            const char *caller);
89 
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,
94                                   bool *error);
95 
96 extern void
97 _mesa_initialize_buffer_object(struct gl_context *ctx,
98                                struct gl_buffer_object *obj,
99                                GLuint name);
100 
101 extern void
102 _mesa_delete_buffer_object(struct gl_context *ctx,
103                            struct gl_buffer_object *bufObj);
104 
105 extern void
106 _mesa_reference_buffer_object_(struct gl_context *ctx,
107                                struct gl_buffer_object **ptr,
108                                struct gl_buffer_object *bufObj);
109 
110 static inline void
_mesa_reference_buffer_object(struct gl_context * ctx,struct gl_buffer_object ** ptr,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)
114 {
115    if (*ptr != bufObj)
116       _mesa_reference_buffer_object_(ctx, ptr, bufObj);
117 }
118 
119 extern GLuint
120 _mesa_total_buffer_object_memory(struct gl_context *ctx);
121 
122 extern void
123 _mesa_init_buffer_object_functions(struct dd_function_table *driver);
124 
125 extern void
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);
129 
130 extern void
131 _mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
132                       GLintptr offset, GLsizeiptr size, const GLvoid *data);
133 
134 extern void
135 _mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
136                                 struct gl_buffer_object *bufObj);
137 
138 extern void
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);
144 
145 /*
146  * API functions
147  */
148 void GLAPIENTRY
149 _mesa_BindBuffer_no_error(GLenum target, GLuint buffer);
150 
151 void GLAPIENTRY
152 _mesa_BindBuffer(GLenum target, GLuint buffer);
153 
154 void
155 _mesa_InternalBindElementBuffer(struct gl_context *ctx,
156                                 struct gl_buffer_object *buf);
157 
158 void GLAPIENTRY
159 _mesa_DeleteBuffers_no_error(GLsizei n, const GLuint * buffer);
160 
161 void GLAPIENTRY
162 _mesa_DeleteBuffers(GLsizei n, const GLuint * buffer);
163 
164 void GLAPIENTRY
165 _mesa_GenBuffers_no_error(GLsizei n, GLuint *buffers);
166 
167 void GLAPIENTRY
168 _mesa_GenBuffers(GLsizei n, GLuint *buffers);
169 
170 void GLAPIENTRY
171 _mesa_CreateBuffers_no_error(GLsizei n, GLuint *buffers);
172 
173 void GLAPIENTRY
174 _mesa_CreateBuffers(GLsizei n, GLuint *buffers);
175 
176 GLboolean GLAPIENTRY
177 _mesa_IsBuffer(GLuint buffer);
178 
179 void GLAPIENTRY
180 _mesa_BufferStorage_no_error(GLenum target, GLsizeiptr size,
181                              const GLvoid *data, GLbitfield flags);
182 void GLAPIENTRY
183 _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
184                     GLbitfield flags);
185 void GLAPIENTRY
186 _mesa_NamedBufferStorageEXT(GLuint buffer, GLsizeiptr size,
187                             const GLvoid *data, GLbitfield flags);
188 void GLAPIENTRY
189 _mesa_BufferStorageMemEXT(GLenum target, GLsizeiptr size,
190                           GLuint memory, GLuint64 offset);
191 void GLAPIENTRY
192 _mesa_BufferStorageMemEXT_no_error(GLenum target, GLsizeiptr size,
193                                    GLuint memory, GLuint64 offset);
194 void GLAPIENTRY
195 _mesa_NamedBufferStorage_no_error(GLuint buffer, GLsizeiptr size,
196                                   const GLvoid *data, GLbitfield flags);
197 void GLAPIENTRY
198 _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
199                          GLbitfield flags);
200 void GLAPIENTRY
201 _mesa_NamedBufferStorageMemEXT(GLuint buffer, GLsizeiptr size,
202                                GLuint memory, GLuint64 offset);
203 void GLAPIENTRY
204 _mesa_NamedBufferStorageMemEXT_no_error(GLuint buffer, GLsizeiptr size,
205                                         GLuint memory, GLuint64 offset);
206 
207 void GLAPIENTRY
208 _mesa_BufferData_no_error(GLenum target, GLsizeiptr size,
209                           const GLvoid *data, GLenum usage);
210 
211 void GLAPIENTRY
212 _mesa_BufferData(GLenum target, GLsizeiptr size,
213                  const GLvoid *data, GLenum usage);
214 
215 void GLAPIENTRY
216 _mesa_NamedBufferData_no_error(GLuint buffer, GLsizeiptr size,
217                                const GLvoid *data, GLenum usage);
218 
219 void GLAPIENTRY
220 _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size,
221                       const GLvoid *data, GLenum usage);
222 void GLAPIENTRY
223 _mesa_NamedBufferDataEXT(GLuint buffer, GLsizeiptr size,
224                          const GLvoid *data, GLenum usage);
225 
226 void GLAPIENTRY
227 _mesa_BufferSubData_no_error(GLenum target, GLintptr offset,
228                              GLsizeiptr size, const GLvoid *data);
229 void GLAPIENTRY
230 _mesa_BufferSubData(GLenum target, GLintptr offset,
231                     GLsizeiptr size, const GLvoid *data);
232 
233 void GLAPIENTRY
234 _mesa_NamedBufferSubData_no_error(GLuint buffer, GLintptr offset,
235                                   GLsizeiptr size, const GLvoid *data);
236 void GLAPIENTRY
237 _mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,
238                          GLsizeiptr size, const GLvoid *data);
239 void GLAPIENTRY
240 _mesa_NamedBufferSubDataEXT(GLuint buffer, GLintptr offset,
241                             GLsizeiptr size, const GLvoid *data);
242 
243 void GLAPIENTRY
244 _mesa_GetBufferSubData(GLenum target, GLintptr offset,
245                        GLsizeiptr size, GLvoid *data);
246 
247 void GLAPIENTRY
248 _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
249                             GLsizeiptr size, GLvoid *data);
250 
251 void GLAPIENTRY
252 _mesa_GetNamedBufferSubDataEXT(GLuint buffer, GLintptr offset,
253                                GLsizeiptr size, GLvoid *data);
254 
255 void GLAPIENTRY
256 _mesa_ClearBufferData_no_error(GLenum target, GLenum internalformat,
257                                GLenum format, GLenum type, const GLvoid *data);
258 
259 void GLAPIENTRY
260 _mesa_ClearBufferData(GLenum target, GLenum internalformat,
261                       GLenum format, GLenum type,
262                       const GLvoid *data);
263 
264 void GLAPIENTRY
265 _mesa_ClearNamedBufferData_no_error(GLuint buffer, GLenum internalformat,
266                                     GLenum format, GLenum type,
267                                     const GLvoid *data);
268 
269 void GLAPIENTRY
270 _mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat,
271                            GLenum format, GLenum type,
272                            const GLvoid *data);
273 
274 void GLAPIENTRY
275 _mesa_ClearNamedBufferDataEXT(GLuint buffer, GLenum internalformat,
276                               GLenum format, GLenum type,
277                               const GLvoid *data);
278 
279 void GLAPIENTRY
280 _mesa_ClearBufferSubData_no_error(GLenum target, GLenum internalformat,
281                                   GLintptr offset, GLsizeiptr size,
282                                   GLenum format, GLenum type,
283                                   const GLvoid *data);
284 
285 void GLAPIENTRY
286 _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
287                          GLintptr offset, GLsizeiptr size,
288                          GLenum format, GLenum type,
289                          const GLvoid *data);
290 
291 void GLAPIENTRY
292 _mesa_ClearNamedBufferSubData_no_error(GLuint buffer, GLenum internalformat,
293                                        GLintptr offset, GLsizeiptr size,
294                                        GLenum format, GLenum type,
295                                        const GLvoid *data);
296 
297 void GLAPIENTRY
298 _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
299                               GLintptr offset, GLsizeiptr size,
300                               GLenum format, GLenum type,
301                               const GLvoid *data);
302 
303 void GLAPIENTRY
304 _mesa_ClearNamedBufferSubDataEXT(GLuint buffer, GLenum internalformat,
305                                  GLintptr offset, GLsizeiptr size,
306                                  GLenum format, GLenum type,
307                                  const GLvoid *data);
308 
309 GLboolean GLAPIENTRY
310 _mesa_UnmapBuffer_no_error(GLenum target);
311 GLboolean GLAPIENTRY
312 _mesa_UnmapBuffer(GLenum target);
313 
314 GLboolean GLAPIENTRY
315 _mesa_UnmapNamedBufferEXT_no_error(GLuint buffer);
316 GLboolean GLAPIENTRY
317 _mesa_UnmapNamedBufferEXT(GLuint buffer);
318 
319 void GLAPIENTRY
320 _mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params);
321 
322 void GLAPIENTRY
323 _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params);
324 
325 void GLAPIENTRY
326 _mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params);
327 
328 void GLAPIENTRY
329 _mesa_GetNamedBufferParameterivEXT(GLuint buffer, GLenum pname, GLint *params);
330 
331 void GLAPIENTRY
332 _mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname,
333                                   GLint64 *params);
334 
335 void GLAPIENTRY
336 _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params);
337 
338 void GLAPIENTRY
339 _mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params);
340 
341 void GLAPIENTRY
342 _mesa_GetNamedBufferPointervEXT(GLuint buffer, GLenum pname, GLvoid **params);
343 
344 void GLAPIENTRY
345 _mesa_CopyBufferSubData_no_error(GLenum readTarget, GLenum writeTarget,
346                                  GLintptr readOffset, GLintptr writeOffset,
347                                  GLsizeiptr size);
348 void GLAPIENTRY
349 _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
350                         GLintptr readOffset, GLintptr writeOffset,
351                         GLsizeiptr size);
352 
353 void GLAPIENTRY
354 _mesa_NamedCopyBufferSubDataEXT(GLuint readBuffer, GLuint writeBuffer,
355                                 GLintptr readOffset, GLintptr writeOffset,
356                                 GLsizeiptr size);
357 
358 void GLAPIENTRY
359 _mesa_CopyNamedBufferSubData_no_error(GLuint readBuffer, GLuint writeBuffer,
360                                       GLintptr readOffset,
361                                       GLintptr writeOffset, GLsizeiptr size);
362 void GLAPIENTRY
363 _mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer,
364                              GLintptr readOffset, GLintptr writeOffset,
365                              GLsizeiptr size);
366 void GLAPIENTRY
367 _mesa_InternalBufferSubDataCopyMESA(GLintptr srcBuffer, GLuint srcOffset,
368                                     GLuint dstTargetOrName, GLintptr dstOffset,
369                                     GLsizeiptr size, GLboolean named,
370                                     GLboolean ext_dsa);
371 
372 void * GLAPIENTRY
373 _mesa_MapBufferRange_no_error(GLenum target, GLintptr offset,
374                               GLsizeiptr length, GLbitfield access);
375 void * GLAPIENTRY
376 _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
377                      GLbitfield access);
378 
379 void * GLAPIENTRY
380 _mesa_MapNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
381                                    GLsizeiptr length, GLbitfield access);
382 void * GLAPIENTRY
383 _mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
384                           GLbitfield access);
385 void * GLAPIENTRY
386 _mesa_MapNamedBufferRangeEXT(GLuint buffer, GLintptr offset,
387                              GLsizeiptr length, GLbitfield access);
388 
389 void * GLAPIENTRY
390 _mesa_MapBuffer_no_error(GLenum target, GLenum access);
391 void * GLAPIENTRY
392 _mesa_MapBuffer(GLenum target, GLenum access);
393 
394 void * GLAPIENTRY
395 _mesa_MapNamedBuffer_no_error(GLuint buffer, GLenum access);
396 void * GLAPIENTRY
397 _mesa_MapNamedBuffer(GLuint buffer, GLenum access);
398 void * GLAPIENTRY
399 _mesa_MapNamedBufferEXT(GLuint buffer, GLenum access);
400 
401 void GLAPIENTRY
402 _mesa_FlushMappedBufferRange_no_error(GLenum target, GLintptr offset,
403                                       GLsizeiptr length);
404 void GLAPIENTRY
405 _mesa_FlushMappedBufferRange(GLenum target,
406                              GLintptr offset, GLsizeiptr length);
407 
408 void GLAPIENTRY
409 _mesa_FlushMappedNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
410                                            GLsizeiptr length);
411 void GLAPIENTRY
412 _mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
413                                   GLsizeiptr length);
414 
415 void GLAPIENTRY
416 _mesa_FlushMappedNamedBufferRangeEXT(GLuint buffer, GLintptr offset,
417                                      GLsizeiptr length);
418 
419 void GLAPIENTRY
420 _mesa_BindBufferRange_no_error(GLenum target, GLuint index, GLuint buffer,
421                                GLintptr offset, GLsizeiptr size);
422 void GLAPIENTRY
423 _mesa_BindBufferRange(GLenum target, GLuint index,
424                       GLuint buffer, GLintptr offset, GLsizeiptr size);
425 
426 void GLAPIENTRY
427 _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer);
428 
429 void GLAPIENTRY
430 _mesa_BindBuffersRange(GLenum target, GLuint first, GLsizei count,
431                        const GLuint *buffers,
432                        const GLintptr *offsets, const GLsizeiptr *sizes);
433 void GLAPIENTRY
434 _mesa_BindBuffersBase(GLenum target, GLuint first, GLsizei count,
435                       const GLuint *buffers);
436 
437 void GLAPIENTRY
438 _mesa_InvalidateBufferSubData_no_error(GLuint buffer, GLintptr offset,
439                                        GLsizeiptr length);
440 
441 void GLAPIENTRY
442 _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset,
443                               GLsizeiptr length);
444 
445 void GLAPIENTRY
446 _mesa_InvalidateBufferData_no_error(GLuint buffer);
447 
448 void GLAPIENTRY
449 _mesa_InvalidateBufferData(GLuint buffer);
450 
451 void GLAPIENTRY
452 _mesa_BufferPageCommitmentARB(GLenum target, GLintptr offset, GLsizeiptr size,
453                               GLboolean commit);
454 
455 void GLAPIENTRY
456 _mesa_NamedBufferPageCommitmentARB(GLuint buffer, GLintptr offset,
457                                    GLsizeiptr size, GLboolean commit);
458 
459 void GLAPIENTRY
460 _mesa_NamedBufferPageCommitmentEXT(GLuint buffer, GLintptr offset,
461                                    GLsizeiptr size, GLboolean commit);
462 
463 #endif
464