i965: Silence unused variable warning.
[mesa.git] / src / mesa / drivers / dri / i965 / intel_buffer_objects.c
1 /**************************************************************************
2 *
3 * Copyright 2003 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 * @file intel_buffer_objects.c
30 *
31 * This provides core GL buffer object functionality.
32 */
33
34 #include "main/imports.h"
35 #include "main/mtypes.h"
36 #include "main/macros.h"
37 #include "main/bufferobj.h"
38
39 #include "brw_context.h"
40 #include "intel_blit.h"
41 #include "intel_buffer_objects.h"
42 #include "intel_batchbuffer.h"
43
44 /**
45 * Map a buffer object; issue performance warnings if mapping causes stalls.
46 *
47 * This matches the drm_intel_bo_map API, but takes an additional human-readable
48 * name for the buffer object to use in the performance debug message.
49 */
50 int
51 brw_bo_map(struct brw_context *brw,
52 drm_intel_bo *bo, int write_enable,
53 const char *bo_name)
54 {
55 if (likely(!brw->perf_debug) || !drm_intel_bo_busy(bo))
56 return drm_intel_bo_map(bo, write_enable);
57
58 double start_time = get_time();
59
60 int ret = drm_intel_bo_map(bo, write_enable);
61
62 perf_debug("CPU mapping a busy %s BO stalled and took %.03f ms.\n",
63 bo_name, (get_time() - start_time) * 1000);
64
65 return ret;
66 }
67
68 int
69 brw_bo_map_gtt(struct brw_context *brw, drm_intel_bo *bo, const char *bo_name)
70 {
71 if (likely(!brw->perf_debug) || !drm_intel_bo_busy(bo))
72 return drm_intel_gem_bo_map_gtt(bo);
73
74 double start_time = get_time();
75
76 int ret = drm_intel_gem_bo_map_gtt(bo);
77
78 perf_debug("GTT mapping a busy %s BO stalled and took %.03f ms.\n",
79 bo_name, (get_time() - start_time) * 1000);
80
81 return ret;
82 }
83
84 static GLboolean
85 intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj,
86 gl_map_buffer_index index);
87
88 static void
89 intel_bufferobj_mark_gpu_usage(struct intel_buffer_object *intel_obj,
90 uint32_t offset, uint32_t size)
91 {
92 intel_obj->gpu_active_start = MIN2(intel_obj->gpu_active_start, offset);
93 intel_obj->gpu_active_end = MAX2(intel_obj->gpu_active_end, offset + size);
94 }
95
96 static void
97 intel_bufferobj_mark_inactive(struct intel_buffer_object *intel_obj)
98 {
99 intel_obj->gpu_active_start = ~0;
100 intel_obj->gpu_active_end = 0;
101 }
102
103 /** Allocates a new drm_intel_bo to store the data for the buffer object. */
104 static void
105 intel_bufferobj_alloc_buffer(struct brw_context *brw,
106 struct intel_buffer_object *intel_obj)
107 {
108 intel_obj->buffer = drm_intel_bo_alloc(brw->bufmgr, "bufferobj",
109 intel_obj->Base.Size, 64);
110
111 /* the buffer might be bound as a uniform buffer, need to update it
112 */
113 if (intel_obj->Base.UsageHistory & USAGE_UNIFORM_BUFFER)
114 brw->state.dirty.brw |= BRW_NEW_UNIFORM_BUFFER;
115 if (intel_obj->Base.UsageHistory & USAGE_TEXTURE_BUFFER)
116 brw->state.dirty.brw |= BRW_NEW_TEXTURE_BUFFER;
117 if (intel_obj->Base.UsageHistory & USAGE_ATOMIC_COUNTER_BUFFER)
118 brw->state.dirty.brw |= BRW_NEW_ATOMIC_BUFFER;
119
120 intel_bufferobj_mark_inactive(intel_obj);
121 }
122
123 static void
124 release_buffer(struct intel_buffer_object *intel_obj)
125 {
126 drm_intel_bo_unreference(intel_obj->buffer);
127 intel_obj->buffer = NULL;
128 }
129
130 /**
131 * The NewBufferObject() driver hook.
132 *
133 * Allocates a new intel_buffer_object structure and initializes it.
134 *
135 * There is some duplication between mesa's bufferobjects and our
136 * bufmgr buffers. Both have an integer handle and a hashtable to
137 * lookup an opaque structure. It would be nice if the handles and
138 * internal structure where somehow shared.
139 */
140 static struct gl_buffer_object *
141 intel_bufferobj_alloc(struct gl_context * ctx, GLuint name)
142 {
143 struct intel_buffer_object *obj = CALLOC_STRUCT(intel_buffer_object);
144 if (!obj) {
145 _mesa_error_no_memory(__func__);
146 }
147
148 _mesa_initialize_buffer_object(ctx, &obj->Base, name);
149
150 obj->buffer = NULL;
151
152 return &obj->Base;
153 }
154
155 /**
156 * The DeleteBuffer() driver hook.
157 *
158 * Deletes a single OpenGL buffer object. Used by glDeleteBuffers().
159 */
160 static void
161 intel_bufferobj_free(struct gl_context * ctx, struct gl_buffer_object *obj)
162 {
163 struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
164
165 assert(intel_obj);
166
167 /* Buffer objects are automatically unmapped when deleting according
168 * to the spec, but Mesa doesn't do UnmapBuffer for us at context destroy
169 * (though it does if you call glDeleteBuffers)
170 */
171 _mesa_buffer_unmap_all_mappings(ctx, obj);
172
173 drm_intel_bo_unreference(intel_obj->buffer);
174 free(intel_obj);
175 }
176
177
178 /**
179 * The BufferData() driver hook.
180 *
181 * Implements glBufferData(), which recreates a buffer object's data store
182 * and populates it with the given data, if present.
183 *
184 * Any data that was previously stored in the buffer object is lost.
185 *
186 * \return true for success, false if out of memory
187 */
188 static GLboolean
189 intel_bufferobj_data(struct gl_context * ctx,
190 GLenum target,
191 GLsizeiptrARB size,
192 const GLvoid * data,
193 GLenum usage,
194 GLbitfield storageFlags,
195 struct gl_buffer_object *obj)
196 {
197 struct brw_context *brw = brw_context(ctx);
198 struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
199
200 /* Part of the ABI, but this function doesn't use it.
201 */
202 (void) target;
203
204 intel_obj->Base.Size = size;
205 intel_obj->Base.Usage = usage;
206 intel_obj->Base.StorageFlags = storageFlags;
207
208 assert(!obj->Mappings[MAP_USER].Pointer); /* Mesa should have unmapped it */
209 assert(!obj->Mappings[MAP_INTERNAL].Pointer);
210
211 if (intel_obj->buffer != NULL)
212 release_buffer(intel_obj);
213
214 if (size != 0) {
215 intel_bufferobj_alloc_buffer(brw, intel_obj);
216 if (!intel_obj->buffer)
217 return false;
218
219 if (data != NULL)
220 drm_intel_bo_subdata(intel_obj->buffer, 0, size, data);
221 }
222
223 return true;
224 }
225
226
227 /**
228 * The BufferSubData() driver hook.
229 *
230 * Implements glBufferSubData(), which replaces a portion of the data in a
231 * buffer object.
232 *
233 * If the data range specified by (size + offset) extends beyond the end of
234 * the buffer or if data is NULL, no copy is performed.
235 */
236 static void
237 intel_bufferobj_subdata(struct gl_context * ctx,
238 GLintptrARB offset,
239 GLsizeiptrARB size,
240 const GLvoid * data, struct gl_buffer_object *obj)
241 {
242 struct brw_context *brw = brw_context(ctx);
243 struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
244 bool busy;
245
246 if (size == 0)
247 return;
248
249 assert(intel_obj);
250
251 /* See if we can unsynchronized write the data into the user's BO. This
252 * avoids GPU stalls in unfortunately common user patterns (uploading
253 * sequentially into a BO, with draw calls in between each upload).
254 *
255 * Once we've hit this path, we mark this GL BO as preferring stalling to
256 * blits, so that we can hopefully hit this path again in the future
257 * (otherwise, an app that might occasionally stall but mostly not will end
258 * up with blitting all the time, at the cost of bandwidth)
259 */
260 if (brw->has_llc) {
261 if (offset + size <= intel_obj->gpu_active_start ||
262 intel_obj->gpu_active_end <= offset) {
263 drm_intel_gem_bo_map_unsynchronized(intel_obj->buffer);
264 memcpy(intel_obj->buffer->virtual + offset, data, size);
265 drm_intel_bo_unmap(intel_obj->buffer);
266
267 if (intel_obj->gpu_active_end > intel_obj->gpu_active_start)
268 intel_obj->prefer_stall_to_blit = true;
269 return;
270 }
271 }
272
273 busy =
274 drm_intel_bo_busy(intel_obj->buffer) ||
275 drm_intel_bo_references(brw->batch.bo, intel_obj->buffer);
276
277 if (busy) {
278 if (size == intel_obj->Base.Size) {
279 /* Replace the current busy bo so the subdata doesn't stall. */
280 drm_intel_bo_unreference(intel_obj->buffer);
281 intel_bufferobj_alloc_buffer(brw, intel_obj);
282 } else if (!intel_obj->prefer_stall_to_blit) {
283 perf_debug("Using a blit copy to avoid stalling on "
284 "glBufferSubData(%ld, %ld) (%ldkb) to a busy "
285 "(%d-%d) buffer object.\n",
286 (long)offset, (long)offset + size, (long)(size/1024),
287 intel_obj->gpu_active_start,
288 intel_obj->gpu_active_end);
289 drm_intel_bo *temp_bo =
290 drm_intel_bo_alloc(brw->bufmgr, "subdata temp", size, 64);
291
292 drm_intel_bo_subdata(temp_bo, 0, size, data);
293
294 intel_emit_linear_blit(brw,
295 intel_obj->buffer, offset,
296 temp_bo, 0,
297 size);
298
299 drm_intel_bo_unreference(temp_bo);
300 return;
301 } else {
302 perf_debug("Stalling on glBufferSubData(%ld, %ld) (%ldkb) to a busy "
303 "(%d-%d) buffer object. Use glMapBufferRange() to "
304 "avoid this.\n",
305 (long)offset, (long)offset + size, (long)(size/1024),
306 intel_obj->gpu_active_start,
307 intel_obj->gpu_active_end);
308 intel_batchbuffer_flush(brw);
309 }
310 }
311
312 drm_intel_bo_subdata(intel_obj->buffer, offset, size, data);
313 intel_bufferobj_mark_inactive(intel_obj);
314 }
315
316
317 /**
318 * The GetBufferSubData() driver hook.
319 *
320 * Implements glGetBufferSubData(), which copies a subrange of a buffer
321 * object into user memory.
322 */
323 static void
324 intel_bufferobj_get_subdata(struct gl_context * ctx,
325 GLintptrARB offset,
326 GLsizeiptrARB size,
327 GLvoid * data, struct gl_buffer_object *obj)
328 {
329 struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
330 struct brw_context *brw = brw_context(ctx);
331
332 assert(intel_obj);
333 if (drm_intel_bo_references(brw->batch.bo, intel_obj->buffer)) {
334 intel_batchbuffer_flush(brw);
335 }
336 drm_intel_bo_get_subdata(intel_obj->buffer, offset, size, data);
337
338 intel_bufferobj_mark_inactive(intel_obj);
339 }
340
341
342 /**
343 * The MapBufferRange() driver hook.
344 *
345 * This implements both glMapBufferRange() and glMapBuffer().
346 *
347 * The goal of this extension is to allow apps to accumulate their rendering
348 * at the same time as they accumulate their buffer object. Without it,
349 * you'd end up blocking on execution of rendering every time you mapped
350 * the buffer to put new data in.
351 *
352 * We support it in 3 ways: If unsynchronized, then don't bother
353 * flushing the batchbuffer before mapping the buffer, which can save blocking
354 * in many cases. If we would still block, and they allow the whole buffer
355 * to be invalidated, then just allocate a new buffer to replace the old one.
356 * If not, and we'd block, and they allow the subrange of the buffer to be
357 * invalidated, then we can make a new little BO, let them write into that,
358 * and blit it into the real BO at unmap time.
359 */
360 static void *
361 intel_bufferobj_map_range(struct gl_context * ctx,
362 GLintptr offset, GLsizeiptr length,
363 GLbitfield access, struct gl_buffer_object *obj,
364 gl_map_buffer_index index)
365 {
366 struct brw_context *brw = brw_context(ctx);
367 struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
368
369 assert(intel_obj);
370
371 /* _mesa_MapBufferRange (GL entrypoint) sets these, but the vbo module also
372 * internally uses our functions directly.
373 */
374 obj->Mappings[index].Offset = offset;
375 obj->Mappings[index].Length = length;
376 obj->Mappings[index].AccessFlags = access;
377
378 if (intel_obj->buffer == NULL) {
379 obj->Mappings[index].Pointer = NULL;
380 return NULL;
381 }
382
383 /* If the access is synchronized (like a normal buffer mapping), then get
384 * things flushed out so the later mapping syncs appropriately through GEM.
385 * If the user doesn't care about existing buffer contents and mapping would
386 * cause us to block, then throw out the old buffer.
387 *
388 * If they set INVALIDATE_BUFFER, we can pitch the current contents to
389 * achieve the required synchronization.
390 */
391 if (!(access & GL_MAP_UNSYNCHRONIZED_BIT)) {
392 if (drm_intel_bo_references(brw->batch.bo, intel_obj->buffer)) {
393 if (access & GL_MAP_INVALIDATE_BUFFER_BIT) {
394 drm_intel_bo_unreference(intel_obj->buffer);
395 intel_bufferobj_alloc_buffer(brw, intel_obj);
396 } else {
397 perf_debug("Stalling on the GPU for mapping a busy buffer "
398 "object\n");
399 intel_batchbuffer_flush(brw);
400 }
401 } else if (drm_intel_bo_busy(intel_obj->buffer) &&
402 (access & GL_MAP_INVALIDATE_BUFFER_BIT)) {
403 drm_intel_bo_unreference(intel_obj->buffer);
404 intel_bufferobj_alloc_buffer(brw, intel_obj);
405 }
406 }
407
408 /* If the user is mapping a range of an active buffer object but
409 * doesn't require the current contents of that range, make a new
410 * BO, and we'll copy what they put in there out at unmap or
411 * FlushRange time.
412 *
413 * That is, unless they're looking for a persistent mapping -- we would
414 * need to do blits in the MemoryBarrier call, and it's easier to just do a
415 * GPU stall and do a mapping.
416 */
417 if (!(access & (GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_PERSISTENT_BIT)) &&
418 (access & GL_MAP_INVALIDATE_RANGE_BIT) &&
419 drm_intel_bo_busy(intel_obj->buffer)) {
420 /* Ensure that the base alignment of the allocation meets the alignment
421 * guarantees the driver has advertised to the application.
422 */
423 const unsigned alignment = ctx->Const.MinMapBufferAlignment;
424
425 intel_obj->map_extra[index] = (uintptr_t) offset % alignment;
426 intel_obj->range_map_bo[index] = drm_intel_bo_alloc(brw->bufmgr,
427 "BO blit temp",
428 length +
429 intel_obj->map_extra[index],
430 alignment);
431 if (brw->has_llc) {
432 brw_bo_map(brw, intel_obj->range_map_bo[index],
433 (access & GL_MAP_WRITE_BIT) != 0, "range-map");
434 } else {
435 drm_intel_gem_bo_map_gtt(intel_obj->range_map_bo[index]);
436 }
437 obj->Mappings[index].Pointer =
438 intel_obj->range_map_bo[index]->virtual + intel_obj->map_extra[index];
439 return obj->Mappings[index].Pointer;
440 }
441
442 if (access & GL_MAP_UNSYNCHRONIZED_BIT)
443 drm_intel_gem_bo_map_unsynchronized(intel_obj->buffer);
444 else if (!brw->has_llc && (!(access & GL_MAP_READ_BIT) ||
445 (access & GL_MAP_PERSISTENT_BIT))) {
446 drm_intel_gem_bo_map_gtt(intel_obj->buffer);
447 intel_bufferobj_mark_inactive(intel_obj);
448 } else {
449 brw_bo_map(brw, intel_obj->buffer, (access & GL_MAP_WRITE_BIT) != 0,
450 "MapBufferRange");
451 intel_bufferobj_mark_inactive(intel_obj);
452 }
453
454 obj->Mappings[index].Pointer = intel_obj->buffer->virtual + offset;
455 return obj->Mappings[index].Pointer;
456 }
457
458 /**
459 * The FlushMappedBufferRange() driver hook.
460 *
461 * Implements glFlushMappedBufferRange(), which signifies that modifications
462 * have been made to a range of a mapped buffer, and it should be flushed.
463 *
464 * This is only used for buffers mapped with GL_MAP_FLUSH_EXPLICIT_BIT.
465 *
466 * Ideally we'd use a BO to avoid taking up cache space for the temporary
467 * data, but FlushMappedBufferRange may be followed by further writes to
468 * the pointer, so we would have to re-map after emitting our blit, which
469 * would defeat the point.
470 */
471 static void
472 intel_bufferobj_flush_mapped_range(struct gl_context *ctx,
473 GLintptr offset, GLsizeiptr length,
474 struct gl_buffer_object *obj,
475 gl_map_buffer_index index)
476 {
477 struct brw_context *brw = brw_context(ctx);
478 struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
479
480 assert(obj->Mappings[index].AccessFlags & GL_MAP_FLUSH_EXPLICIT_BIT);
481
482 /* If we gave a direct mapping of the buffer instead of using a temporary,
483 * then there's nothing to do.
484 */
485 if (intel_obj->range_map_bo[index] == NULL)
486 return;
487
488 if (length == 0)
489 return;
490
491 /* Note that we're not unmapping our buffer while executing the blit. We
492 * need to have a mapping still at the end of this call, since the user
493 * gets to make further modifications and glFlushMappedBufferRange() calls.
494 * This is safe, because:
495 *
496 * - On LLC platforms, we're using a CPU mapping that's coherent with the
497 * GPU (except for the render caches), so the kernel doesn't need to do
498 * any flushing work for us except for what happens at batch exec time
499 * anyway.
500 *
501 * - On non-LLC platforms, we're using a GTT mapping that writes directly
502 * to system memory (except for the chipset cache that gets flushed at
503 * batch exec time).
504 *
505 * In both cases we don't need to stall for the previous blit to complete
506 * so we can re-map (and we definitely don't want to, since that would be
507 * slow): If the user edits a part of their buffer that's previously been
508 * blitted, then our lack of synchoronization is fine, because either
509 * they'll get some too-new data in the first blit and not do another blit
510 * of that area (but in that case the results are undefined), or they'll do
511 * another blit of that area and the complete newer data will land the
512 * second time.
513 */
514 intel_emit_linear_blit(brw,
515 intel_obj->buffer,
516 obj->Mappings[index].Offset + offset,
517 intel_obj->range_map_bo[index],
518 intel_obj->map_extra[index] + offset,
519 length);
520 intel_bufferobj_mark_gpu_usage(intel_obj,
521 obj->Mappings[index].Offset + offset,
522 length);
523 }
524
525
526 /**
527 * The UnmapBuffer() driver hook.
528 *
529 * Implements glUnmapBuffer().
530 */
531 static GLboolean
532 intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj,
533 gl_map_buffer_index index)
534 {
535 struct brw_context *brw = brw_context(ctx);
536 struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
537
538 assert(intel_obj);
539 assert(obj->Mappings[index].Pointer);
540 if (intel_obj->range_map_bo[index] != NULL) {
541 drm_intel_bo_unmap(intel_obj->range_map_bo[index]);
542
543 if (!(obj->Mappings[index].AccessFlags & GL_MAP_FLUSH_EXPLICIT_BIT)) {
544 intel_emit_linear_blit(brw,
545 intel_obj->buffer, obj->Mappings[index].Offset,
546 intel_obj->range_map_bo[index],
547 intel_obj->map_extra[index],
548 obj->Mappings[index].Length);
549 intel_bufferobj_mark_gpu_usage(intel_obj, obj->Mappings[index].Offset,
550 obj->Mappings[index].Length);
551 }
552
553 /* Since we've emitted some blits to buffers that will (likely) be used
554 * in rendering operations in other cache domains in this batch, emit a
555 * flush. Once again, we wish for a domain tracker in libdrm to cover
556 * usage inside of a batchbuffer.
557 */
558 intel_batchbuffer_emit_mi_flush(brw);
559
560 drm_intel_bo_unreference(intel_obj->range_map_bo[index]);
561 intel_obj->range_map_bo[index] = NULL;
562 } else if (intel_obj->buffer != NULL) {
563 drm_intel_bo_unmap(intel_obj->buffer);
564 }
565 obj->Mappings[index].Pointer = NULL;
566 obj->Mappings[index].Offset = 0;
567 obj->Mappings[index].Length = 0;
568
569 return true;
570 }
571
572 /**
573 * Gets a pointer to the object's BO, and marks the given range as being used
574 * on the GPU.
575 *
576 * Anywhere that uses buffer objects in the pipeline should be using this to
577 * mark the range of the buffer that is being accessed by the pipeline.
578 */
579 drm_intel_bo *
580 intel_bufferobj_buffer(struct brw_context *brw,
581 struct intel_buffer_object *intel_obj,
582 uint32_t offset, uint32_t size)
583 {
584 /* This is needed so that things like transform feedback and texture buffer
585 * objects that need a BO but don't want to check that they exist for
586 * draw-time validation can just always get a BO from a GL buffer object.
587 */
588 if (intel_obj->buffer == NULL)
589 intel_bufferobj_alloc_buffer(brw, intel_obj);
590
591 intel_bufferobj_mark_gpu_usage(intel_obj, offset, size);
592
593 return intel_obj->buffer;
594 }
595
596 /**
597 * The CopyBufferSubData() driver hook.
598 *
599 * Implements glCopyBufferSubData(), which copies a portion of one buffer
600 * object's data to another. Independent source and destination offsets
601 * are allowed.
602 */
603 static void
604 intel_bufferobj_copy_subdata(struct gl_context *ctx,
605 struct gl_buffer_object *src,
606 struct gl_buffer_object *dst,
607 GLintptr read_offset, GLintptr write_offset,
608 GLsizeiptr size)
609 {
610 struct brw_context *brw = brw_context(ctx);
611 struct intel_buffer_object *intel_src = intel_buffer_object(src);
612 struct intel_buffer_object *intel_dst = intel_buffer_object(dst);
613 drm_intel_bo *src_bo, *dst_bo;
614
615 if (size == 0)
616 return;
617
618 dst_bo = intel_bufferobj_buffer(brw, intel_dst, write_offset, size);
619 src_bo = intel_bufferobj_buffer(brw, intel_src, read_offset, size);
620
621 intel_emit_linear_blit(brw,
622 dst_bo, write_offset,
623 src_bo, read_offset, size);
624
625 /* Since we've emitted some blits to buffers that will (likely) be used
626 * in rendering operations in other cache domains in this batch, emit a
627 * flush. Once again, we wish for a domain tracker in libdrm to cover
628 * usage inside of a batchbuffer.
629 */
630 intel_batchbuffer_emit_mi_flush(brw);
631 }
632
633 void
634 intelInitBufferObjectFuncs(struct dd_function_table *functions)
635 {
636 functions->NewBufferObject = intel_bufferobj_alloc;
637 functions->DeleteBuffer = intel_bufferobj_free;
638 functions->BufferData = intel_bufferobj_data;
639 functions->BufferSubData = intel_bufferobj_subdata;
640 functions->GetBufferSubData = intel_bufferobj_get_subdata;
641 functions->MapBufferRange = intel_bufferobj_map_range;
642 functions->FlushMappedBufferRange = intel_bufferobj_flush_mapped_range;
643 functions->UnmapBuffer = intel_bufferobj_unmap;
644 functions->CopyBufferSubData = intel_bufferobj_copy_subdata;
645 }