meson: add support for xlib glx
[mesa.git] / src / mesa / main / bufferobj.h
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
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
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 * 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.
67 */
68 static inline GLboolean
69 _mesa_is_bufferobj(const struct gl_buffer_object *obj)
70 {
71 return obj != NULL && obj->Name != 0;
72 }
73
74
75 extern void
76 _mesa_init_buffer_objects(struct gl_context *ctx);
77
78 extern void
79 _mesa_free_buffer_objects(struct gl_context *ctx);
80
81 extern bool
82 _mesa_handle_bind_buffer_gen(struct gl_context *ctx,
83 GLuint buffer,
84 struct gl_buffer_object **buf_handle,
85 const char *caller);
86
87 extern void
88 _mesa_update_default_objects_buffer_objects(struct gl_context *ctx);
89
90
91 extern struct gl_buffer_object *
92 _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer);
93
94 extern struct gl_buffer_object *
95 _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer);
96
97 extern struct gl_buffer_object *
98 _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
99 const char *caller);
100
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);
105
106 extern void
107 _mesa_initialize_buffer_object(struct gl_context *ctx,
108 struct gl_buffer_object *obj,
109 GLuint name);
110
111 extern void
112 _mesa_delete_buffer_object(struct gl_context *ctx,
113 struct gl_buffer_object *bufObj);
114
115 extern void
116 _mesa_reference_buffer_object_(struct gl_context *ctx,
117 struct gl_buffer_object **ptr,
118 struct gl_buffer_object *bufObj);
119
120 static inline void
121 _mesa_reference_buffer_object(struct gl_context *ctx,
122 struct gl_buffer_object **ptr,
123 struct gl_buffer_object *bufObj)
124 {
125 if (*ptr != bufObj)
126 _mesa_reference_buffer_object_(ctx, ptr, bufObj);
127 }
128
129 extern GLuint
130 _mesa_total_buffer_object_memory(struct gl_context *ctx);
131
132 extern void
133 _mesa_init_buffer_object_functions(struct dd_function_table *driver);
134
135 extern void
136 _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
137 GLenum target, GLsizeiptr size, const GLvoid *data,
138 GLenum usage, const char *func);
139
140 extern void
141 _mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
142 GLintptr offset, GLsizeiptr size, const GLvoid *data);
143
144 extern void
145 _mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
146 struct gl_buffer_object *bufObj);
147
148 extern void
149 _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
150 GLintptr offset, GLsizeiptr size,
151 const GLvoid *clearValue,
152 GLsizeiptr clearValueSize,
153 struct gl_buffer_object *bufObj);
154
155 /*
156 * API functions
157 */
158 void GLAPIENTRY
159 _mesa_BindBuffer_no_error(GLenum target, GLuint buffer);
160
161 void GLAPIENTRY
162 _mesa_BindBuffer(GLenum target, GLuint buffer);
163
164 void GLAPIENTRY
165 _mesa_DeleteBuffers_no_error(GLsizei n, const GLuint * buffer);
166
167 void GLAPIENTRY
168 _mesa_DeleteBuffers(GLsizei n, const GLuint * buffer);
169
170 void GLAPIENTRY
171 _mesa_GenBuffers_no_error(GLsizei n, GLuint *buffers);
172
173 void GLAPIENTRY
174 _mesa_GenBuffers(GLsizei n, GLuint *buffers);
175
176 void GLAPIENTRY
177 _mesa_CreateBuffers_no_error(GLsizei n, GLuint *buffers);
178
179 void GLAPIENTRY
180 _mesa_CreateBuffers(GLsizei n, GLuint *buffers);
181
182 GLboolean GLAPIENTRY
183 _mesa_IsBuffer(GLuint buffer);
184
185 void GLAPIENTRY
186 _mesa_BufferStorage_no_error(GLenum target, GLsizeiptr size,
187 const GLvoid *data, GLbitfield flags);
188 void GLAPIENTRY
189 _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
190 GLbitfield flags);
191 void GLAPIENTRY
192 _mesa_BufferStorageMemEXT(GLenum target, GLsizeiptr size,
193 GLuint memory, GLuint64 offset);
194 void GLAPIENTRY
195 _mesa_BufferStorageMemEXT_no_error(GLenum target, GLsizeiptr size,
196 GLuint memory, GLuint64 offset);
197 void GLAPIENTRY
198 _mesa_NamedBufferStorage_no_error(GLuint buffer, GLsizeiptr size,
199 const GLvoid *data, GLbitfield flags);
200 void GLAPIENTRY
201 _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
202 GLbitfield flags);
203 void GLAPIENTRY
204 _mesa_NamedBufferStorageMemEXT(GLuint buffer, GLsizeiptr size,
205 GLuint memory, GLuint64 offset);
206 void GLAPIENTRY
207 _mesa_NamedBufferStorageMemEXT_no_error(GLuint buffer, GLsizeiptr size,
208 GLuint memory, GLuint64 offset);
209
210 void GLAPIENTRY
211 _mesa_BufferData_no_error(GLenum target, GLsizeiptr size,
212 const GLvoid *data, GLenum usage);
213
214 void GLAPIENTRY
215 _mesa_BufferData(GLenum target, GLsizeiptr size,
216 const GLvoid *data, GLenum usage);
217
218 void GLAPIENTRY
219 _mesa_NamedBufferData_no_error(GLuint buffer, GLsizeiptr size,
220 const GLvoid *data, GLenum usage);
221
222 void GLAPIENTRY
223 _mesa_NamedBufferData(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
240 void GLAPIENTRY
241 _mesa_GetBufferSubData(GLenum target, GLintptr offset,
242 GLsizeiptr size, GLvoid *data);
243
244 void GLAPIENTRY
245 _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
246 GLsizeiptr size, GLvoid *data);
247
248 void GLAPIENTRY
249 _mesa_ClearBufferData_no_error(GLenum target, GLenum internalformat,
250 GLenum format, GLenum type, const GLvoid *data);
251
252 void GLAPIENTRY
253 _mesa_ClearBufferData(GLenum target, GLenum internalformat,
254 GLenum format, GLenum type,
255 const GLvoid *data);
256
257 void GLAPIENTRY
258 _mesa_ClearNamedBufferData_no_error(GLuint buffer, GLenum internalformat,
259 GLenum format, GLenum type,
260 const GLvoid *data);
261
262 void GLAPIENTRY
263 _mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat,
264 GLenum format, GLenum type,
265 const GLvoid *data);
266
267 void GLAPIENTRY
268 _mesa_ClearBufferSubData_no_error(GLenum target, GLenum internalformat,
269 GLintptr offset, GLsizeiptr size,
270 GLenum format, GLenum type,
271 const GLvoid *data);
272
273 void GLAPIENTRY
274 _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
275 GLintptr offset, GLsizeiptr size,
276 GLenum format, GLenum type,
277 const GLvoid *data);
278
279 void GLAPIENTRY
280 _mesa_ClearNamedBufferSubData_no_error(GLuint buffer, GLenum internalformat,
281 GLintptr offset, GLsizeiptr size,
282 GLenum format, GLenum type,
283 const GLvoid *data);
284
285 void GLAPIENTRY
286 _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
287 GLintptr offset, GLsizeiptr size,
288 GLenum format, GLenum type,
289 const GLvoid *data);
290
291 GLboolean GLAPIENTRY
292 _mesa_UnmapBuffer_no_error(GLenum target);
293 GLboolean GLAPIENTRY
294 _mesa_UnmapBuffer(GLenum target);
295
296 GLboolean GLAPIENTRY
297 _mesa_UnmapNamedBuffer_no_error(GLuint buffer);
298 GLboolean GLAPIENTRY
299 _mesa_UnmapNamedBuffer(GLuint buffer);
300
301 void GLAPIENTRY
302 _mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params);
303
304 void GLAPIENTRY
305 _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params);
306
307 void GLAPIENTRY
308 _mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params);
309
310 void GLAPIENTRY
311 _mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname,
312 GLint64 *params);
313
314 void GLAPIENTRY
315 _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params);
316
317 void GLAPIENTRY
318 _mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params);
319
320 void GLAPIENTRY
321 _mesa_CopyBufferSubData_no_error(GLenum readTarget, GLenum writeTarget,
322 GLintptr readOffset, GLintptr writeOffset,
323 GLsizeiptr size);
324 void GLAPIENTRY
325 _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
326 GLintptr readOffset, GLintptr writeOffset,
327 GLsizeiptr size);
328
329 void GLAPIENTRY
330 _mesa_CopyNamedBufferSubData_no_error(GLuint readBuffer, GLuint writeBuffer,
331 GLintptr readOffset,
332 GLintptr writeOffset, GLsizeiptr size);
333 void GLAPIENTRY
334 _mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer,
335 GLintptr readOffset, GLintptr writeOffset,
336 GLsizeiptr size);
337
338 void * GLAPIENTRY
339 _mesa_MapBufferRange_no_error(GLenum target, GLintptr offset,
340 GLsizeiptr length, GLbitfield access);
341 void * GLAPIENTRY
342 _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
343 GLbitfield access);
344
345 void * GLAPIENTRY
346 _mesa_MapNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
347 GLsizeiptr length, GLbitfield access);
348 void * GLAPIENTRY
349 _mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
350 GLbitfield access);
351
352 void * GLAPIENTRY
353 _mesa_MapBuffer_no_error(GLenum target, GLenum access);
354 void * GLAPIENTRY
355 _mesa_MapBuffer(GLenum target, GLenum access);
356
357 void * GLAPIENTRY
358 _mesa_MapNamedBuffer_no_error(GLuint buffer, GLenum access);
359 void * GLAPIENTRY
360 _mesa_MapNamedBuffer(GLuint buffer, GLenum access);
361
362 void GLAPIENTRY
363 _mesa_FlushMappedBufferRange_no_error(GLenum target, GLintptr offset,
364 GLsizeiptr length);
365 void GLAPIENTRY
366 _mesa_FlushMappedBufferRange(GLenum target,
367 GLintptr offset, GLsizeiptr length);
368
369 void GLAPIENTRY
370 _mesa_FlushMappedNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
371 GLsizeiptr length);
372 void GLAPIENTRY
373 _mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
374 GLsizeiptr length);
375
376 void GLAPIENTRY
377 _mesa_BindBufferRange_no_error(GLenum target, GLuint index, GLuint buffer,
378 GLintptr offset, GLsizeiptr size);
379 void GLAPIENTRY
380 _mesa_BindBufferRange(GLenum target, GLuint index,
381 GLuint buffer, GLintptr offset, GLsizeiptr size);
382
383 void GLAPIENTRY
384 _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer);
385
386 void GLAPIENTRY
387 _mesa_BindBuffersRange(GLenum target, GLuint first, GLsizei count,
388 const GLuint *buffers,
389 const GLintptr *offsets, const GLsizeiptr *sizes);
390 void GLAPIENTRY
391 _mesa_BindBuffersBase(GLenum target, GLuint first, GLsizei count,
392 const GLuint *buffers);
393
394 void GLAPIENTRY
395 _mesa_InvalidateBufferSubData_no_error(GLuint buffer, GLintptr offset,
396 GLsizeiptr length);
397
398 void GLAPIENTRY
399 _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset,
400 GLsizeiptr length);
401
402 void GLAPIENTRY
403 _mesa_InvalidateBufferData_no_error(GLuint buffer);
404
405 void GLAPIENTRY
406 _mesa_InvalidateBufferData(GLuint buffer);
407
408 void GLAPIENTRY
409 _mesa_BufferPageCommitmentARB(GLenum target, GLintptr offset, GLsizeiptr size,
410 GLboolean commit);
411
412 void GLAPIENTRY
413 _mesa_NamedBufferPageCommitmentARB(GLuint buffer, GLintptr offset,
414 GLsizeiptr size, GLboolean commit);
415
416 #endif