util: fix no-op macro (bad number of arguments)
[mesa.git] / src / mesa / state_tracker / st_cb_bufferobjects.c
1 /**************************************************************************
2 *
3 * Copyright 2007 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29 /**
30 * Functions for pixel buffer objects and vertex/element buffer objects.
31 */
32
33
34 #include <inttypes.h> /* for PRId64 macro */
35
36 #include "main/errors.h"
37 #include "main/imports.h"
38 #include "main/mtypes.h"
39 #include "main/arrayobj.h"
40 #include "main/bufferobj.h"
41
42 #include "st_context.h"
43 #include "st_cb_bufferobjects.h"
44 #include "st_cb_memoryobjects.h"
45 #include "st_debug.h"
46 #include "st_util.h"
47
48 #include "pipe/p_context.h"
49 #include "pipe/p_defines.h"
50 #include "util/u_inlines.h"
51
52
53 /**
54 * There is some duplication between mesa's bufferobjects and our
55 * bufmgr buffers. Both have an integer handle and a hashtable to
56 * lookup an opaque structure. It would be nice if the handles and
57 * internal structure where somehow shared.
58 */
59 static struct gl_buffer_object *
60 st_bufferobj_alloc(struct gl_context *ctx, GLuint name)
61 {
62 struct st_buffer_object *st_obj = ST_CALLOC_STRUCT(st_buffer_object);
63
64 if (!st_obj)
65 return NULL;
66
67 _mesa_initialize_buffer_object(ctx, &st_obj->Base, name);
68
69 return &st_obj->Base;
70 }
71
72
73
74 /**
75 * Deallocate/free a vertex/pixel buffer object.
76 * Called via glDeleteBuffersARB().
77 */
78 static void
79 st_bufferobj_free(struct gl_context *ctx, struct gl_buffer_object *obj)
80 {
81 struct st_buffer_object *st_obj = st_buffer_object(obj);
82
83 assert(obj->RefCount == 0);
84 _mesa_buffer_unmap_all_mappings(ctx, obj);
85
86 if (st_obj->buffer)
87 pipe_resource_reference(&st_obj->buffer, NULL);
88
89 _mesa_delete_buffer_object(ctx, obj);
90 }
91
92
93
94 /**
95 * Replace data in a subrange of buffer object. If the data range
96 * specified by size + offset extends beyond the end of the buffer or
97 * if data is NULL, no copy is performed.
98 * Called via glBufferSubDataARB().
99 */
100 static void
101 st_bufferobj_subdata(struct gl_context *ctx,
102 GLintptrARB offset,
103 GLsizeiptrARB size,
104 const void * data, struct gl_buffer_object *obj)
105 {
106 struct st_buffer_object *st_obj = st_buffer_object(obj);
107
108 /* we may be called from VBO code, so double-check params here */
109 assert(offset >= 0);
110 assert(size >= 0);
111 assert(offset + size <= obj->Size);
112
113 if (!size)
114 return;
115
116 /*
117 * According to ARB_vertex_buffer_object specification, if data is null,
118 * then the contents of the buffer object's data store is undefined. We just
119 * ignore, and leave it unchanged.
120 */
121 if (!data)
122 return;
123
124 if (!st_obj->buffer) {
125 /* we probably ran out of memory during buffer allocation */
126 return;
127 }
128
129 /* Now that transfers are per-context, we don't have to figure out
130 * flushing here. Usually drivers won't need to flush in this case
131 * even if the buffer is currently referenced by hardware - they
132 * just queue the upload as dma rather than mapping the underlying
133 * buffer directly.
134 *
135 * If the buffer is mapped, suppress implicit buffer range invalidation
136 * by using PIPE_TRANSFER_MAP_DIRECTLY.
137 */
138 struct pipe_context *pipe = st_context(ctx)->pipe;
139
140 pipe->buffer_subdata(pipe, st_obj->buffer,
141 _mesa_bufferobj_mapped(obj, MAP_USER) ?
142 PIPE_TRANSFER_MAP_DIRECTLY : 0,
143 offset, size, data);
144 }
145
146
147 /**
148 * Called via glGetBufferSubDataARB().
149 */
150 static void
151 st_bufferobj_get_subdata(struct gl_context *ctx,
152 GLintptrARB offset,
153 GLsizeiptrARB size,
154 void * data, struct gl_buffer_object *obj)
155 {
156 struct st_buffer_object *st_obj = st_buffer_object(obj);
157
158 /* we may be called from VBO code, so double-check params here */
159 assert(offset >= 0);
160 assert(size >= 0);
161 assert(offset + size <= obj->Size);
162
163 if (!size)
164 return;
165
166 if (!st_obj->buffer) {
167 /* we probably ran out of memory during buffer allocation */
168 return;
169 }
170
171 pipe_buffer_read(st_context(ctx)->pipe, st_obj->buffer,
172 offset, size, data);
173 }
174
175
176 /**
177 * Return bitmask of PIPE_BIND_x flags corresponding a GL buffer target.
178 */
179 static unsigned
180 buffer_target_to_bind_flags(GLenum target)
181 {
182 switch (target) {
183 case GL_PIXEL_PACK_BUFFER_ARB:
184 case GL_PIXEL_UNPACK_BUFFER_ARB:
185 return PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
186 case GL_ARRAY_BUFFER_ARB:
187 return PIPE_BIND_VERTEX_BUFFER;
188 case GL_ELEMENT_ARRAY_BUFFER_ARB:
189 return PIPE_BIND_INDEX_BUFFER;
190 case GL_TEXTURE_BUFFER:
191 return PIPE_BIND_SAMPLER_VIEW;
192 case GL_TRANSFORM_FEEDBACK_BUFFER:
193 return PIPE_BIND_STREAM_OUTPUT;
194 case GL_UNIFORM_BUFFER:
195 return PIPE_BIND_CONSTANT_BUFFER;
196 case GL_DRAW_INDIRECT_BUFFER:
197 case GL_PARAMETER_BUFFER_ARB:
198 return PIPE_BIND_COMMAND_ARGS_BUFFER;
199 case GL_ATOMIC_COUNTER_BUFFER:
200 case GL_SHADER_STORAGE_BUFFER:
201 return PIPE_BIND_SHADER_BUFFER;
202 case GL_QUERY_BUFFER:
203 return PIPE_BIND_QUERY_BUFFER;
204 default:
205 return 0;
206 }
207 }
208
209
210 /**
211 * Return bitmask of PIPE_RESOURCE_x flags corresponding to GL_MAP_x flags.
212 */
213 static unsigned
214 storage_flags_to_buffer_flags(GLbitfield storageFlags)
215 {
216 unsigned flags = 0;
217 if (storageFlags & GL_MAP_PERSISTENT_BIT)
218 flags |= PIPE_RESOURCE_FLAG_MAP_PERSISTENT;
219 if (storageFlags & GL_MAP_COHERENT_BIT)
220 flags |= PIPE_RESOURCE_FLAG_MAP_COHERENT;
221 if (storageFlags & GL_SPARSE_STORAGE_BIT_ARB)
222 flags |= PIPE_RESOURCE_FLAG_SPARSE;
223 return flags;
224 }
225
226
227 /**
228 * From a buffer object's target, immutability flag, storage flags and
229 * usage hint, return a pipe_resource_usage value (PIPE_USAGE_DYNAMIC,
230 * STREAM, etc).
231 */
232 static enum pipe_resource_usage
233 buffer_usage(GLenum target, GLboolean immutable,
234 GLbitfield storageFlags, GLenum usage)
235 {
236 if (immutable) {
237 /* BufferStorage */
238 if (storageFlags & GL_CLIENT_STORAGE_BIT) {
239 if (storageFlags & GL_MAP_READ_BIT)
240 return PIPE_USAGE_STAGING;
241 else
242 return PIPE_USAGE_STREAM;
243 } else {
244 return PIPE_USAGE_DEFAULT;
245 }
246 }
247 else {
248 /* BufferData */
249 switch (usage) {
250 case GL_DYNAMIC_DRAW:
251 case GL_DYNAMIC_COPY:
252 return PIPE_USAGE_DYNAMIC;
253 case GL_STREAM_DRAW:
254 case GL_STREAM_COPY:
255 /* XXX: Remove this test and fall-through when we have PBO unpacking
256 * acceleration. Right now, PBO unpacking is done by the CPU, so we
257 * have to make sure CPU reads are fast.
258 */
259 if (target != GL_PIXEL_UNPACK_BUFFER_ARB) {
260 return PIPE_USAGE_STREAM;
261 }
262 /* fall through */
263 case GL_STATIC_READ:
264 case GL_DYNAMIC_READ:
265 case GL_STREAM_READ:
266 return PIPE_USAGE_STAGING;
267 case GL_STATIC_DRAW:
268 case GL_STATIC_COPY:
269 default:
270 return PIPE_USAGE_DEFAULT;
271 }
272 }
273 }
274
275
276 static ALWAYS_INLINE GLboolean
277 bufferobj_data(struct gl_context *ctx,
278 GLenum target,
279 GLsizeiptrARB size,
280 const void *data,
281 struct gl_memory_object *memObj,
282 GLuint64 offset,
283 GLenum usage,
284 GLbitfield storageFlags,
285 struct gl_buffer_object *obj)
286 {
287 struct st_context *st = st_context(ctx);
288 struct pipe_context *pipe = st->pipe;
289 struct pipe_screen *screen = pipe->screen;
290 struct st_buffer_object *st_obj = st_buffer_object(obj);
291 struct st_memory_object *st_mem_obj = st_memory_object(memObj);
292 bool is_mapped = _mesa_bufferobj_mapped(obj, MAP_USER);
293
294 if (target != GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD &&
295 size && st_obj->buffer &&
296 st_obj->Base.Size == size &&
297 st_obj->Base.Usage == usage &&
298 st_obj->Base.StorageFlags == storageFlags) {
299 if (data) {
300 /* Just discard the old contents and write new data.
301 * This should be the same as creating a new buffer, but we avoid
302 * a lot of validation in Mesa.
303 *
304 * If the buffer is mapped, we can't discard it.
305 *
306 * PIPE_TRANSFER_MAP_DIRECTLY supresses implicit buffer range
307 * invalidation.
308 */
309 pipe->buffer_subdata(pipe, st_obj->buffer,
310 is_mapped ? PIPE_TRANSFER_MAP_DIRECTLY :
311 PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE,
312 0, size, data);
313 return GL_TRUE;
314 } else if (is_mapped) {
315 return GL_TRUE; /* can't reallocate, nothing to do */
316 } else if (screen->get_param(screen, PIPE_CAP_INVALIDATE_BUFFER)) {
317 pipe->invalidate_resource(pipe, st_obj->buffer);
318 return GL_TRUE;
319 }
320 }
321
322 st_obj->Base.Size = size;
323 st_obj->Base.Usage = usage;
324 st_obj->Base.StorageFlags = storageFlags;
325
326 pipe_resource_reference( &st_obj->buffer, NULL );
327
328 const unsigned bindings = buffer_target_to_bind_flags(target);
329
330 if (ST_DEBUG & DEBUG_BUFFER) {
331 debug_printf("Create buffer size %" PRId64 " bind 0x%x\n",
332 (int64_t) size, bindings);
333 }
334
335 if (size != 0) {
336 struct pipe_resource buffer;
337
338 memset(&buffer, 0, sizeof buffer);
339 buffer.target = PIPE_BUFFER;
340 buffer.format = PIPE_FORMAT_R8_UNORM; /* want TYPELESS or similar */
341 buffer.bind = bindings;
342 buffer.usage =
343 buffer_usage(target, st_obj->Base.Immutable, storageFlags, usage);
344 buffer.flags = storage_flags_to_buffer_flags(storageFlags);
345 buffer.width0 = size;
346 buffer.height0 = 1;
347 buffer.depth0 = 1;
348 buffer.array_size = 1;
349
350 if (st_mem_obj) {
351 st_obj->buffer = screen->resource_from_memobj(screen, &buffer,
352 st_mem_obj->memory,
353 offset);
354 }
355 else if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
356 st_obj->buffer =
357 screen->resource_from_user_memory(screen, &buffer, (void*)data);
358 }
359 else {
360 st_obj->buffer = screen->resource_create(screen, &buffer);
361
362 if (st_obj->buffer && data)
363 pipe_buffer_write(pipe, st_obj->buffer, 0, size, data);
364 }
365
366 if (!st_obj->buffer) {
367 /* out of memory */
368 st_obj->Base.Size = 0;
369 return GL_FALSE;
370 }
371 }
372
373 /* The current buffer may be bound, so we have to revalidate all atoms that
374 * might be using it.
375 */
376 if (st_obj->Base.UsageHistory & USAGE_ARRAY_BUFFER)
377 ctx->NewDriverState |= ST_NEW_VERTEX_ARRAYS;
378 /* if (st_obj->Base.UsageHistory & USAGE_ELEMENT_ARRAY_BUFFER) */
379 /* ctx->NewDriverState |= TODO: Handle indices as gallium state; */
380 if (st_obj->Base.UsageHistory & USAGE_UNIFORM_BUFFER)
381 ctx->NewDriverState |= ST_NEW_UNIFORM_BUFFER;
382 if (st_obj->Base.UsageHistory & USAGE_SHADER_STORAGE_BUFFER)
383 ctx->NewDriverState |= ST_NEW_STORAGE_BUFFER;
384 if (st_obj->Base.UsageHistory & USAGE_TEXTURE_BUFFER)
385 ctx->NewDriverState |= ST_NEW_SAMPLER_VIEWS | ST_NEW_IMAGE_UNITS;
386 if (st_obj->Base.UsageHistory & USAGE_ATOMIC_COUNTER_BUFFER)
387 ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer;
388
389 return GL_TRUE;
390 }
391
392 /**
393 * Allocate space for and store data in a buffer object. Any data that was
394 * previously stored in the buffer object is lost. If data is NULL,
395 * memory will be allocated, but no copy will occur.
396 * Called via ctx->Driver.BufferData().
397 * \return GL_TRUE for success, GL_FALSE if out of memory
398 */
399 static GLboolean
400 st_bufferobj_data(struct gl_context *ctx,
401 GLenum target,
402 GLsizeiptrARB size,
403 const void *data,
404 GLenum usage,
405 GLbitfield storageFlags,
406 struct gl_buffer_object *obj)
407 {
408 return bufferobj_data(ctx, target, size, data, NULL, 0, usage, storageFlags, obj);
409 }
410
411 static GLboolean
412 st_bufferobj_data_mem(struct gl_context *ctx,
413 GLenum target,
414 GLsizeiptrARB size,
415 struct gl_memory_object *memObj,
416 GLuint64 offset,
417 GLenum usage,
418 struct gl_buffer_object *bufObj)
419 {
420 return bufferobj_data(ctx, target, size, NULL, memObj, offset, usage, 0, bufObj);
421 }
422
423 /**
424 * Called via glInvalidateBuffer(Sub)Data.
425 */
426 static void
427 st_bufferobj_invalidate(struct gl_context *ctx,
428 struct gl_buffer_object *obj,
429 GLintptr offset,
430 GLsizeiptr size)
431 {
432 struct st_context *st = st_context(ctx);
433 struct pipe_context *pipe = st->pipe;
434 struct st_buffer_object *st_obj = st_buffer_object(obj);
435
436 /* We ignore partial invalidates. */
437 if (offset != 0 || size != obj->Size)
438 return;
439
440 /* If the buffer is mapped, we can't invalidate it. */
441 if (!st_obj->buffer || _mesa_bufferobj_mapped(obj, MAP_USER))
442 return;
443
444 pipe->invalidate_resource(pipe, st_obj->buffer);
445 }
446
447
448 /**
449 * Convert GLbitfield of GL_MAP_x flags to gallium pipe_transfer_usage flags.
450 * \param wholeBuffer is the whole buffer being mapped?
451 */
452 enum pipe_transfer_usage
453 st_access_flags_to_transfer_flags(GLbitfield access, bool wholeBuffer)
454 {
455 enum pipe_transfer_usage flags = 0;
456
457 if (access & GL_MAP_WRITE_BIT)
458 flags |= PIPE_TRANSFER_WRITE;
459
460 if (access & GL_MAP_READ_BIT)
461 flags |= PIPE_TRANSFER_READ;
462
463 if (access & GL_MAP_FLUSH_EXPLICIT_BIT)
464 flags |= PIPE_TRANSFER_FLUSH_EXPLICIT;
465
466 if (access & GL_MAP_INVALIDATE_BUFFER_BIT) {
467 flags |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
468 }
469 else if (access & GL_MAP_INVALIDATE_RANGE_BIT) {
470 if (wholeBuffer)
471 flags |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
472 else
473 flags |= PIPE_TRANSFER_DISCARD_RANGE;
474 }
475
476 if (access & GL_MAP_UNSYNCHRONIZED_BIT)
477 flags |= PIPE_TRANSFER_UNSYNCHRONIZED;
478
479 if (access & GL_MAP_PERSISTENT_BIT)
480 flags |= PIPE_TRANSFER_PERSISTENT;
481
482 if (access & GL_MAP_COHERENT_BIT)
483 flags |= PIPE_TRANSFER_COHERENT;
484
485 /* ... other flags ...
486 */
487
488 if (access & MESA_MAP_NOWAIT_BIT)
489 flags |= PIPE_TRANSFER_DONTBLOCK;
490
491 return flags;
492 }
493
494
495 /**
496 * Called via glMapBufferRange().
497 */
498 static void *
499 st_bufferobj_map_range(struct gl_context *ctx,
500 GLintptr offset, GLsizeiptr length, GLbitfield access,
501 struct gl_buffer_object *obj,
502 gl_map_buffer_index index)
503 {
504 struct pipe_context *pipe = st_context(ctx)->pipe;
505 struct st_buffer_object *st_obj = st_buffer_object(obj);
506
507 assert(offset >= 0);
508 assert(length >= 0);
509 assert(offset < obj->Size);
510 assert(offset + length <= obj->Size);
511
512 const enum pipe_transfer_usage transfer_flags =
513 st_access_flags_to_transfer_flags(access,
514 offset == 0 && length == obj->Size);
515
516 obj->Mappings[index].Pointer = pipe_buffer_map_range(pipe,
517 st_obj->buffer,
518 offset, length,
519 transfer_flags,
520 &st_obj->transfer[index]);
521 if (obj->Mappings[index].Pointer) {
522 obj->Mappings[index].Offset = offset;
523 obj->Mappings[index].Length = length;
524 obj->Mappings[index].AccessFlags = access;
525 }
526 else {
527 st_obj->transfer[index] = NULL;
528 }
529
530 return obj->Mappings[index].Pointer;
531 }
532
533
534 static void
535 st_bufferobj_flush_mapped_range(struct gl_context *ctx,
536 GLintptr offset, GLsizeiptr length,
537 struct gl_buffer_object *obj,
538 gl_map_buffer_index index)
539 {
540 struct pipe_context *pipe = st_context(ctx)->pipe;
541 struct st_buffer_object *st_obj = st_buffer_object(obj);
542
543 /* Subrange is relative to mapped range */
544 assert(offset >= 0);
545 assert(length >= 0);
546 assert(offset + length <= obj->Mappings[index].Length);
547 assert(obj->Mappings[index].Pointer);
548
549 if (!length)
550 return;
551
552 pipe_buffer_flush_mapped_range(pipe, st_obj->transfer[index],
553 obj->Mappings[index].Offset + offset,
554 length);
555 }
556
557
558 /**
559 * Called via glUnmapBufferARB().
560 */
561 static GLboolean
562 st_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj,
563 gl_map_buffer_index index)
564 {
565 struct pipe_context *pipe = st_context(ctx)->pipe;
566 struct st_buffer_object *st_obj = st_buffer_object(obj);
567
568 if (obj->Mappings[index].Length)
569 pipe_buffer_unmap(pipe, st_obj->transfer[index]);
570
571 st_obj->transfer[index] = NULL;
572 obj->Mappings[index].Pointer = NULL;
573 obj->Mappings[index].Offset = 0;
574 obj->Mappings[index].Length = 0;
575 return GL_TRUE;
576 }
577
578
579 /**
580 * Called via glCopyBufferSubData().
581 */
582 static void
583 st_copy_buffer_subdata(struct gl_context *ctx,
584 struct gl_buffer_object *src,
585 struct gl_buffer_object *dst,
586 GLintptr readOffset, GLintptr writeOffset,
587 GLsizeiptr size)
588 {
589 struct pipe_context *pipe = st_context(ctx)->pipe;
590 struct st_buffer_object *srcObj = st_buffer_object(src);
591 struct st_buffer_object *dstObj = st_buffer_object(dst);
592 struct pipe_box box;
593
594 if (!size)
595 return;
596
597 /* buffer should not already be mapped */
598 assert(!_mesa_check_disallowed_mapping(src));
599 assert(!_mesa_check_disallowed_mapping(dst));
600
601 u_box_1d(readOffset, size, &box);
602
603 pipe->resource_copy_region(pipe, dstObj->buffer, 0, writeOffset, 0, 0,
604 srcObj->buffer, 0, &box);
605 }
606
607 /**
608 * Called via glClearBufferSubData().
609 */
610 static void
611 st_clear_buffer_subdata(struct gl_context *ctx,
612 GLintptr offset, GLsizeiptr size,
613 const void *clearValue,
614 GLsizeiptr clearValueSize,
615 struct gl_buffer_object *bufObj)
616 {
617 struct pipe_context *pipe = st_context(ctx)->pipe;
618 struct st_buffer_object *buf = st_buffer_object(bufObj);
619 static const char zeros[16] = {0};
620
621 if (!pipe->clear_buffer) {
622 _mesa_ClearBufferSubData_sw(ctx, offset, size,
623 clearValue, clearValueSize, bufObj);
624 return;
625 }
626
627 if (!clearValue)
628 clearValue = zeros;
629
630 pipe->clear_buffer(pipe, buf->buffer, offset, size,
631 clearValue, clearValueSize);
632 }
633
634 static void
635 st_bufferobj_page_commitment(struct gl_context *ctx,
636 struct gl_buffer_object *bufferObj,
637 GLintptr offset, GLsizeiptr size,
638 GLboolean commit)
639 {
640 struct pipe_context *pipe = st_context(ctx)->pipe;
641 struct st_buffer_object *buf = st_buffer_object(bufferObj);
642 struct pipe_box box;
643
644 u_box_1d(offset, size, &box);
645
646 if (!pipe->resource_commit(pipe, buf->buffer, 0, &box, commit)) {
647 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferPageCommitmentARB(out of memory)");
648 return;
649 }
650 }
651
652 void
653 st_init_bufferobject_functions(struct pipe_screen *screen,
654 struct dd_function_table *functions)
655 {
656 functions->NewBufferObject = st_bufferobj_alloc;
657 functions->DeleteBuffer = st_bufferobj_free;
658 functions->BufferData = st_bufferobj_data;
659 functions->BufferDataMem = st_bufferobj_data_mem;
660 functions->BufferSubData = st_bufferobj_subdata;
661 functions->GetBufferSubData = st_bufferobj_get_subdata;
662 functions->MapBufferRange = st_bufferobj_map_range;
663 functions->FlushMappedBufferRange = st_bufferobj_flush_mapped_range;
664 functions->UnmapBuffer = st_bufferobj_unmap;
665 functions->CopyBufferSubData = st_copy_buffer_subdata;
666 functions->ClearBufferSubData = st_clear_buffer_subdata;
667 functions->BufferPageCommitment = st_bufferobj_page_commitment;
668
669 if (screen->get_param(screen, PIPE_CAP_INVALIDATE_BUFFER))
670 functions->InvalidateBufferSubData = st_bufferobj_invalidate;
671 }