vc4: Just stream out fallback IB contents.
[mesa.git] / src / gallium / drivers / vc4 / vc4_resource.c
1 /*
2 * Copyright © 2014 Broadcom
3 * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
25 #include "util/u_memory.h"
26 #include "util/u_format.h"
27 #include "util/u_inlines.h"
28 #include "util/u_surface.h"
29 #include "util/u_upload_mgr.h"
30
31 #include "vc4_screen.h"
32 #include "vc4_context.h"
33 #include "vc4_resource.h"
34 #include "vc4_tiling.h"
35
36 static bool miptree_debug = false;
37
38 static void
39 vc4_resource_bo_alloc(struct vc4_resource *rsc)
40 {
41 struct pipe_resource *prsc = &rsc->base.b;
42 struct pipe_screen *pscreen = prsc->screen;
43
44 if (miptree_debug) {
45 fprintf(stderr, "alloc %p: size %d + offset %d -> %d\n",
46 rsc,
47 rsc->slices[0].size,
48 rsc->slices[0].offset,
49 rsc->slices[0].offset +
50 rsc->slices[0].size +
51 rsc->cube_map_stride * (prsc->array_size - 1));
52 }
53
54 vc4_bo_unreference(&rsc->bo);
55 rsc->bo = vc4_bo_alloc(vc4_screen(pscreen),
56 rsc->slices[0].offset +
57 rsc->slices[0].size +
58 rsc->cube_map_stride * (prsc->array_size - 1),
59 "resource");
60 }
61
62 static void
63 vc4_resource_transfer_unmap(struct pipe_context *pctx,
64 struct pipe_transfer *ptrans)
65 {
66 struct vc4_context *vc4 = vc4_context(pctx);
67 struct vc4_transfer *trans = vc4_transfer(ptrans);
68 struct pipe_resource *prsc = ptrans->resource;
69 struct vc4_resource *rsc = vc4_resource(prsc);
70 struct vc4_resource_slice *slice = &rsc->slices[ptrans->level];
71
72 if (trans->map) {
73 if (ptrans->usage & PIPE_TRANSFER_WRITE) {
74 vc4_store_tiled_image(rsc->bo->map + slice->offset +
75 ptrans->box.z * rsc->cube_map_stride,
76 slice->stride,
77 trans->map, ptrans->stride,
78 slice->tiling, rsc->cpp,
79 &ptrans->box);
80 }
81 free(trans->map);
82 }
83
84 pipe_resource_reference(&ptrans->resource, NULL);
85 util_slab_free(&vc4->transfer_pool, ptrans);
86 }
87
88 static void *
89 vc4_resource_transfer_map(struct pipe_context *pctx,
90 struct pipe_resource *prsc,
91 unsigned level, unsigned usage,
92 const struct pipe_box *box,
93 struct pipe_transfer **pptrans)
94 {
95 struct vc4_context *vc4 = vc4_context(pctx);
96 struct vc4_resource *rsc = vc4_resource(prsc);
97 struct vc4_resource_slice *slice = &rsc->slices[level];
98 struct vc4_transfer *trans;
99 struct pipe_transfer *ptrans;
100 enum pipe_format format = prsc->format;
101 char *buf;
102
103 if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
104 vc4_resource_bo_alloc(rsc);
105 } else if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
106 if (vc4_cl_references_bo(pctx, rsc->bo)) {
107 if ((usage & PIPE_TRANSFER_DISCARD_RANGE) &&
108 prsc->last_level == 0 &&
109 prsc->width0 == box->width &&
110 prsc->height0 == box->height &&
111 prsc->depth0 == box->depth) {
112 vc4_resource_bo_alloc(rsc);
113 } else {
114 vc4_flush(pctx);
115 }
116 }
117 }
118
119 if (usage & PIPE_TRANSFER_WRITE)
120 rsc->writes++;
121
122 trans = util_slab_alloc(&vc4->transfer_pool);
123 if (!trans)
124 return NULL;
125
126 /* XXX: Handle DONTBLOCK, DISCARD_RANGE, PERSISTENT, COHERENT. */
127
128 /* util_slab_alloc() doesn't zero: */
129 memset(trans, 0, sizeof(*trans));
130 ptrans = &trans->base;
131
132 pipe_resource_reference(&ptrans->resource, prsc);
133 ptrans->level = level;
134 ptrans->usage = usage;
135 ptrans->box = *box;
136
137 /* Note that the current kernel implementation is synchronous, so no
138 * need to do syncing stuff here yet.
139 */
140
141 if (usage & PIPE_TRANSFER_UNSYNCHRONIZED)
142 buf = vc4_bo_map_unsynchronized(rsc->bo);
143 else
144 buf = vc4_bo_map(rsc->bo);
145 if (!buf) {
146 fprintf(stderr, "Failed to map bo\n");
147 goto fail;
148 }
149
150 *pptrans = ptrans;
151
152 if (rsc->tiled) {
153 uint32_t utile_w = vc4_utile_width(rsc->cpp);
154 uint32_t utile_h = vc4_utile_height(rsc->cpp);
155
156 /* No direct mappings of tiled, since we need to manually
157 * tile/untile.
158 */
159 if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
160 return NULL;
161
162 /* We need to align the box to utile boundaries, since that's
163 * what load/store operate on.
164 */
165 uint32_t box_start_x = ptrans->box.x & (utile_w - 1);
166 uint32_t box_start_y = ptrans->box.y & (utile_h - 1);
167 ptrans->box.width += box_start_x;
168 ptrans->box.x -= box_start_x;
169 ptrans->box.height += box_start_y;
170 ptrans->box.y -= box_start_y;
171 ptrans->box.width = align(ptrans->box.width, utile_w);
172 ptrans->box.height = align(ptrans->box.height, utile_h);
173
174 ptrans->stride = ptrans->box.width * rsc->cpp;
175 ptrans->layer_stride = ptrans->stride;
176
177 trans->map = malloc(ptrans->stride * ptrans->box.height);
178 if (usage & PIPE_TRANSFER_READ) {
179 vc4_load_tiled_image(trans->map, ptrans->stride,
180 buf + slice->offset +
181 box->z * rsc->cube_map_stride,
182 slice->stride,
183 slice->tiling, rsc->cpp,
184 &ptrans->box);
185 }
186 return (trans->map +
187 box_start_x * rsc->cpp +
188 box_start_y * ptrans->stride);
189 } else {
190 ptrans->stride = slice->stride;
191 ptrans->layer_stride = ptrans->stride;
192
193 return buf + slice->offset +
194 box->y / util_format_get_blockheight(format) * ptrans->stride +
195 box->x / util_format_get_blockwidth(format) * rsc->cpp +
196 box->z * rsc->cube_map_stride;
197 }
198
199
200 fail:
201 vc4_resource_transfer_unmap(pctx, ptrans);
202 return NULL;
203 }
204
205 static void
206 vc4_resource_destroy(struct pipe_screen *pscreen,
207 struct pipe_resource *prsc)
208 {
209 struct vc4_resource *rsc = vc4_resource(prsc);
210 pipe_resource_reference(&rsc->shadow_parent, NULL);
211 vc4_bo_unreference(&rsc->bo);
212 free(rsc);
213 }
214
215 static boolean
216 vc4_resource_get_handle(struct pipe_screen *pscreen,
217 struct pipe_resource *prsc,
218 struct winsys_handle *handle)
219 {
220 struct vc4_resource *rsc = vc4_resource(prsc);
221
222 return vc4_screen_bo_get_handle(pscreen, rsc->bo, rsc->slices[0].stride,
223 handle);
224 }
225
226 static const struct u_resource_vtbl vc4_resource_vtbl = {
227 .resource_get_handle = vc4_resource_get_handle,
228 .resource_destroy = vc4_resource_destroy,
229 .transfer_map = vc4_resource_transfer_map,
230 .transfer_flush_region = u_default_transfer_flush_region,
231 .transfer_unmap = vc4_resource_transfer_unmap,
232 .transfer_inline_write = u_default_transfer_inline_write,
233 };
234
235 static void
236 vc4_setup_slices(struct vc4_resource *rsc)
237 {
238 struct pipe_resource *prsc = &rsc->base.b;
239 uint32_t width = prsc->width0;
240 uint32_t height = prsc->height0;
241 uint32_t pot_width = util_next_power_of_two(width);
242 uint32_t pot_height = util_next_power_of_two(height);
243 uint32_t offset = 0;
244 uint32_t utile_w = vc4_utile_width(rsc->cpp);
245 uint32_t utile_h = vc4_utile_height(rsc->cpp);
246
247 for (int i = prsc->last_level; i >= 0; i--) {
248 struct vc4_resource_slice *slice = &rsc->slices[i];
249
250 uint32_t level_width, level_height;
251 if (i == 0) {
252 level_width = width;
253 level_height = height;
254 } else {
255 level_width = u_minify(pot_width, i);
256 level_height = u_minify(pot_height, i);
257 }
258
259 if (!rsc->tiled) {
260 slice->tiling = VC4_TILING_FORMAT_LINEAR;
261 level_width = align(level_width, utile_w);
262 } else {
263 if (vc4_size_is_lt(level_width, level_height,
264 rsc->cpp)) {
265 slice->tiling = VC4_TILING_FORMAT_LT;
266 level_width = align(level_width, utile_w);
267 level_height = align(level_height, utile_h);
268 } else {
269 slice->tiling = VC4_TILING_FORMAT_T;
270 level_width = align(level_width,
271 4 * 2 * utile_w);
272 level_height = align(level_height,
273 4 * 2 * utile_h);
274 }
275 }
276
277 slice->offset = offset;
278 slice->stride = level_width * rsc->cpp;
279 slice->size = level_height * slice->stride;
280
281 offset += slice->size;
282
283 if (miptree_debug) {
284 static const char tiling_chars[] = {
285 [VC4_TILING_FORMAT_LINEAR] = 'R',
286 [VC4_TILING_FORMAT_LT] = 'L',
287 [VC4_TILING_FORMAT_T] = 'T'
288 };
289 fprintf(stderr,
290 "rsc setup %p (format %d), %dx%d: "
291 "level %d (%c) -> %dx%d, stride %d@0x%08x\n",
292 rsc, rsc->vc4_format,
293 prsc->width0, prsc->height0,
294 i, tiling_chars[slice->tiling],
295 level_width, level_height,
296 slice->stride, slice->offset);
297 }
298 }
299
300 /* The texture base pointer that has to point to level 0 doesn't have
301 * intra-page bits, so we have to align it, and thus shift up all the
302 * smaller slices.
303 */
304 uint32_t page_align_offset = (align(rsc->slices[0].offset, 4096) -
305 rsc->slices[0].offset);
306 if (page_align_offset) {
307 for (int i = 0; i <= prsc->last_level; i++)
308 rsc->slices[i].offset += page_align_offset;
309 }
310
311 /* Cube map faces appear as whole miptrees at a page-aligned offset
312 * from the first face's miptree.
313 */
314 if (prsc->target == PIPE_TEXTURE_CUBE) {
315 rsc->cube_map_stride = align(rsc->slices[0].offset +
316 rsc->slices[0].size, 4096);
317 }
318 }
319
320 static struct vc4_resource *
321 vc4_resource_setup(struct pipe_screen *pscreen,
322 const struct pipe_resource *tmpl)
323 {
324 struct vc4_resource *rsc = CALLOC_STRUCT(vc4_resource);
325 if (!rsc)
326 return NULL;
327 struct pipe_resource *prsc = &rsc->base.b;
328
329 *prsc = *tmpl;
330
331 pipe_reference_init(&prsc->reference, 1);
332 prsc->screen = pscreen;
333
334 rsc->base.vtbl = &vc4_resource_vtbl;
335 rsc->cpp = util_format_get_blocksize(tmpl->format);
336
337 assert(rsc->cpp);
338
339 return rsc;
340 }
341
342 static enum vc4_texture_data_type
343 get_resource_texture_format(struct pipe_resource *prsc)
344 {
345 struct vc4_resource *rsc = vc4_resource(prsc);
346 uint8_t format = vc4_get_tex_format(prsc->format);
347
348 if (!rsc->tiled) {
349 assert(format == VC4_TEXTURE_TYPE_RGBA8888);
350 return VC4_TEXTURE_TYPE_RGBA32R;
351 }
352
353 return format;
354 }
355
356 struct pipe_resource *
357 vc4_resource_create(struct pipe_screen *pscreen,
358 const struct pipe_resource *tmpl)
359 {
360 struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl);
361 struct pipe_resource *prsc = &rsc->base.b;
362
363 /* We have to make shared be untiled, since we don't have any way to
364 * communicate metadata about tiling currently.
365 */
366 if (tmpl->target == PIPE_BUFFER ||
367 (tmpl->bind & (PIPE_BIND_SCANOUT |
368 PIPE_BIND_LINEAR |
369 PIPE_BIND_SHARED |
370 PIPE_BIND_CURSOR))) {
371 rsc->tiled = false;
372 } else {
373 rsc->tiled = true;
374 }
375
376 if (tmpl->target != PIPE_BUFFER)
377 rsc->vc4_format = get_resource_texture_format(prsc);
378
379 vc4_setup_slices(rsc);
380 vc4_resource_bo_alloc(rsc);
381 if (!rsc->bo)
382 goto fail;
383
384 return prsc;
385 fail:
386 vc4_resource_destroy(pscreen, prsc);
387 return NULL;
388 }
389
390 static struct pipe_resource *
391 vc4_resource_from_handle(struct pipe_screen *pscreen,
392 const struct pipe_resource *tmpl,
393 struct winsys_handle *handle)
394 {
395 struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl);
396 struct pipe_resource *prsc = &rsc->base.b;
397 struct vc4_resource_slice *slice = &rsc->slices[0];
398
399 if (!rsc)
400 return NULL;
401
402 rsc->tiled = false;
403 rsc->bo = vc4_screen_bo_from_handle(pscreen, handle);
404 if (!rsc->bo)
405 goto fail;
406
407 if (!using_vc4_simulator)
408 slice->stride = handle->stride;
409 else
410 slice->stride = align(prsc->width0 * rsc->cpp, 16);
411
412 slice->tiling = VC4_TILING_FORMAT_LINEAR;
413
414 rsc->vc4_format = get_resource_texture_format(prsc);
415
416 if (miptree_debug) {
417 fprintf(stderr,
418 "rsc import %p (format %d), %dx%d: "
419 "level 0 (R) -> stride %d@0x%08x\n",
420 rsc, rsc->vc4_format,
421 prsc->width0, prsc->height0,
422 slice->stride, slice->offset);
423 }
424
425 return prsc;
426
427 fail:
428 vc4_resource_destroy(pscreen, prsc);
429 return NULL;
430 }
431
432 static struct pipe_surface *
433 vc4_create_surface(struct pipe_context *pctx,
434 struct pipe_resource *ptex,
435 const struct pipe_surface *surf_tmpl)
436 {
437 struct vc4_surface *surface = CALLOC_STRUCT(vc4_surface);
438 struct vc4_resource *rsc = vc4_resource(ptex);
439
440 if (!surface)
441 return NULL;
442
443 assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
444
445 struct pipe_surface *psurf = &surface->base;
446 unsigned level = surf_tmpl->u.tex.level;
447
448 pipe_reference_init(&psurf->reference, 1);
449 pipe_resource_reference(&psurf->texture, ptex);
450
451 psurf->context = pctx;
452 psurf->format = surf_tmpl->format;
453 psurf->width = u_minify(ptex->width0, level);
454 psurf->height = u_minify(ptex->height0, level);
455 psurf->u.tex.level = level;
456 psurf->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
457 psurf->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
458 surface->offset = rsc->slices[level].offset;
459 surface->tiling = rsc->slices[level].tiling;
460
461 return &surface->base;
462 }
463
464 static void
465 vc4_surface_destroy(struct pipe_context *pctx, struct pipe_surface *psurf)
466 {
467 pipe_resource_reference(&psurf->texture, NULL);
468 FREE(psurf);
469 }
470
471 /** Debug routine to dump the contents of an 8888 surface to the console */
472 void
473 vc4_dump_surface(struct pipe_surface *psurf)
474 {
475 if (!psurf)
476 return;
477
478 struct pipe_resource *prsc = psurf->texture;
479 struct vc4_resource *rsc = vc4_resource(prsc);
480 uint32_t *map = vc4_bo_map(rsc->bo);
481 uint32_t stride = rsc->slices[0].stride / 4;
482 uint32_t width = psurf->width;
483 uint32_t height = psurf->height;
484 uint32_t chunk_w = width / 79;
485 uint32_t chunk_h = height / 40;
486 uint32_t found_colors[10];
487 uint32_t num_found_colors = 0;
488
489 if (rsc->vc4_format != VC4_TEXTURE_TYPE_RGBA32R) {
490 fprintf(stderr, "%s: Unsupported format %s\n",
491 __func__, util_format_short_name(psurf->format));
492 return;
493 }
494
495 for (int by = 0; by < height; by += chunk_h) {
496 for (int bx = 0; bx < width; bx += chunk_w) {
497 int all_found_color = -1; /* nothing found */
498
499 for (int y = by; y < MIN2(height, by + chunk_h); y++) {
500 for (int x = bx; x < MIN2(width, bx + chunk_w); x++) {
501 uint32_t pix = map[y * stride + x];
502
503 int i;
504 for (i = 0; i < num_found_colors; i++) {
505 if (pix == found_colors[i])
506 break;
507 }
508 if (i == num_found_colors &&
509 num_found_colors <
510 ARRAY_SIZE(found_colors)) {
511 found_colors[num_found_colors++] = pix;
512 }
513
514 if (i < num_found_colors) {
515 if (all_found_color == -1)
516 all_found_color = i;
517 else if (i != all_found_color)
518 all_found_color = ARRAY_SIZE(found_colors);
519 }
520 }
521 }
522 /* If all pixels for this chunk have a consistent
523 * value, then print a character for it. Either a
524 * fixed name (particularly common for piglit tests),
525 * or a runtime-generated number.
526 */
527 if (all_found_color >= 0 &&
528 all_found_color < ARRAY_SIZE(found_colors)) {
529 static const struct {
530 uint32_t val;
531 const char *c;
532 } named_colors[] = {
533 { 0xff000000, "█" },
534 { 0x00000000, "█" },
535 { 0xffff0000, "r" },
536 { 0xff00ff00, "g" },
537 { 0xff0000ff, "b" },
538 { 0xffffffff, "w" },
539 };
540 int i;
541 for (i = 0; i < ARRAY_SIZE(named_colors); i++) {
542 if (named_colors[i].val ==
543 found_colors[all_found_color]) {
544 fprintf(stderr, "%s",
545 named_colors[i].c);
546 break;
547 }
548 }
549 /* For unnamed colors, print a number and the
550 * numbers will have values printed at the
551 * end.
552 */
553 if (i == ARRAY_SIZE(named_colors)) {
554 fprintf(stderr, "%c",
555 '0' + all_found_color);
556 }
557 } else {
558 /* If there's no consistent color, print this.
559 */
560 fprintf(stderr, ".");
561 }
562 }
563 fprintf(stderr, "\n");
564 }
565
566 for (int i = 0; i < num_found_colors; i++) {
567 fprintf(stderr, "color %d: 0x%08x\n", i, found_colors[i]);
568 }
569 }
570
571 static void
572 vc4_flush_resource(struct pipe_context *pctx, struct pipe_resource *resource)
573 {
574 /* All calls to flush_resource are followed by a flush of the context,
575 * so there's nothing to do.
576 */
577 }
578
579 void
580 vc4_update_shadow_baselevel_texture(struct pipe_context *pctx,
581 struct pipe_sampler_view *view)
582 {
583 struct vc4_resource *shadow = vc4_resource(view->texture);
584 struct vc4_resource *orig = vc4_resource(shadow->shadow_parent);
585 assert(orig);
586
587 if (shadow->writes == orig->writes && orig->bo->private)
588 return;
589
590 perf_debug("Updating shadow texture due to %s\n",
591 view->u.tex.first_level ? "base level" : "raster layout");
592
593 for (int i = 0; i <= shadow->base.b.last_level; i++) {
594 unsigned width = u_minify(shadow->base.b.width0, i);
595 unsigned height = u_minify(shadow->base.b.height0, i);
596 struct pipe_blit_info info = {
597 .dst = {
598 .resource = &shadow->base.b,
599 .level = i,
600 .box = {
601 .x = 0,
602 .y = 0,
603 .z = 0,
604 .width = width,
605 .height = height,
606 .depth = 1,
607 },
608 .format = shadow->base.b.format,
609 },
610 .src = {
611 .resource = &orig->base.b,
612 .level = view->u.tex.first_level + i,
613 .box = {
614 .x = 0,
615 .y = 0,
616 .z = 0,
617 .width = width,
618 .height = height,
619 .depth = 1,
620 },
621 .format = orig->base.b.format,
622 },
623 .mask = ~0,
624 };
625 pctx->blit(pctx, &info);
626 }
627
628 shadow->writes = orig->writes;
629 }
630
631 /**
632 * Converts a 4-byte index buffer to 2 bytes.
633 *
634 * Since GLES2 only has support for 1 and 2-byte indices, the hardware doesn't
635 * include 4-byte index support, and we have to shrink it down.
636 *
637 * There's no fallback support for when indices end up being larger than 2^16,
638 * though it will at least assertion fail. Also, if the original index data
639 * was in user memory, it would be nice to not have uploaded it to a VBO
640 * before translating.
641 */
642 struct pipe_resource *
643 vc4_get_shadow_index_buffer(struct pipe_context *pctx,
644 const struct pipe_index_buffer *ib,
645 uint32_t count,
646 uint32_t *shadow_offset)
647 {
648 struct vc4_context *vc4 = vc4_context(pctx);
649 struct vc4_resource *orig = vc4_resource(ib->buffer);
650 perf_debug("Fallback conversion for %d uint indices\n", count);
651
652 void *data;
653 struct pipe_resource *shadow_rsc = NULL;
654 u_upload_alloc(vc4->uploader, 0, count * 2,
655 shadow_offset, &shadow_rsc, &data);
656 uint16_t *dst = data;
657
658 struct pipe_transfer *src_transfer;
659 uint32_t *src = pipe_buffer_map_range(pctx, &orig->base.b,
660 ib->offset,
661 count * 4,
662 PIPE_TRANSFER_READ, &src_transfer);
663
664 for (int i = 0; i < count; i++) {
665 uint32_t src_index = src[i];
666 assert(src_index <= 0xffff);
667 dst[i] = src_index;
668 }
669
670 pctx->transfer_unmap(pctx, src_transfer);
671
672 return shadow_rsc;
673 }
674
675 void
676 vc4_resource_screen_init(struct pipe_screen *pscreen)
677 {
678 pscreen->resource_create = vc4_resource_create;
679 pscreen->resource_from_handle = vc4_resource_from_handle;
680 pscreen->resource_get_handle = u_resource_get_handle_vtbl;
681 pscreen->resource_destroy = u_resource_destroy_vtbl;
682 }
683
684 void
685 vc4_resource_context_init(struct pipe_context *pctx)
686 {
687 pctx->transfer_map = u_transfer_map_vtbl;
688 pctx->transfer_flush_region = u_transfer_flush_region_vtbl;
689 pctx->transfer_unmap = u_transfer_unmap_vtbl;
690 pctx->transfer_inline_write = u_transfer_inline_write_vtbl;
691 pctx->create_surface = vc4_create_surface;
692 pctx->surface_destroy = vc4_surface_destroy;
693 pctx->resource_copy_region = util_resource_copy_region;
694 pctx->blit = vc4_blit;
695 pctx->flush_resource = vc4_flush_resource;
696 }