llvmpipe: remove misleading debug string
[mesa.git] / src / gallium / drivers / llvmpipe / lp_texture.c
1 /**************************************************************************
2 *
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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 * Authors:
29 * Keith Whitwell <keith@tungstengraphics.com>
30 * Michel Dänzer <michel@tungstengraphics.com>
31 */
32
33 #include <stdio.h>
34
35 #include "pipe/p_context.h"
36 #include "pipe/p_defines.h"
37
38 #include "util/u_inlines.h"
39 #include "util/u_cpu_detect.h"
40 #include "util/u_format.h"
41 #include "util/u_math.h"
42 #include "util/u_memory.h"
43 #include "util/u_simple_list.h"
44 #include "util/u_transfer.h"
45
46 #include "lp_context.h"
47 #include "lp_flush.h"
48 #include "lp_screen.h"
49 #include "lp_tile_image.h"
50 #include "lp_texture.h"
51 #include "lp_setup.h"
52 #include "lp_state.h"
53
54 #include "state_tracker/sw_winsys.h"
55
56
57 #ifdef DEBUG
58 static struct llvmpipe_resource resource_list;
59 #endif
60 static unsigned id_counter = 0;
61
62
63 static INLINE boolean
64 resource_is_texture(const struct pipe_resource *resource)
65 {
66 switch (resource->target) {
67 case PIPE_BUFFER:
68 return FALSE;
69 case PIPE_TEXTURE_1D:
70 case PIPE_TEXTURE_2D:
71 case PIPE_TEXTURE_RECT:
72 case PIPE_TEXTURE_3D:
73 case PIPE_TEXTURE_CUBE:
74 return TRUE;
75 default:
76 assert(0);
77 return FALSE;
78 }
79 }
80
81
82
83 /**
84 * Allocate storage for llvmpipe_texture::layout array.
85 * The number of elements is width_in_tiles * height_in_tiles.
86 */
87 static enum lp_texture_layout *
88 alloc_layout_array(unsigned num_slices, unsigned width, unsigned height)
89 {
90 const unsigned tx = align(width, TILE_SIZE) / TILE_SIZE;
91 const unsigned ty = align(height, TILE_SIZE) / TILE_SIZE;
92
93 assert(num_slices * tx * ty > 0);
94 assert(LP_TEX_LAYOUT_NONE == 0); /* calloc'ing LP_TEX_LAYOUT_NONE here */
95
96 return (enum lp_texture_layout *)
97 CALLOC(num_slices * tx * ty, sizeof(enum lp_texture_layout));
98 }
99
100
101
102 /**
103 * Conventional allocation path for non-display textures:
104 * Just compute row strides here. Storage is allocated on demand later.
105 */
106 static boolean
107 llvmpipe_texture_layout(struct llvmpipe_screen *screen,
108 struct llvmpipe_resource *lpr)
109 {
110 struct pipe_resource *pt = &lpr->base;
111 unsigned level;
112 unsigned width = pt->width0;
113 unsigned height = pt->height0;
114 unsigned depth = pt->depth0;
115
116 assert(LP_MAX_TEXTURE_2D_LEVELS <= LP_MAX_TEXTURE_LEVELS);
117 assert(LP_MAX_TEXTURE_3D_LEVELS <= LP_MAX_TEXTURE_LEVELS);
118
119 for (level = 0; level <= pt->last_level; level++) {
120
121 /* Row stride and image stride (for linear layout) */
122 {
123 unsigned alignment, nblocksx, nblocksy, block_size;
124
125 /* For non-compressed formats we need to align the texture size
126 * to the tile size to facilitate render-to-texture.
127 */
128 if (util_format_is_compressed(pt->format))
129 alignment = 1;
130 else
131 alignment = TILE_SIZE;
132
133 nblocksx = util_format_get_nblocksx(pt->format,
134 align(width, alignment));
135 nblocksy = util_format_get_nblocksy(pt->format,
136 align(height, alignment));
137 block_size = util_format_get_blocksize(pt->format);
138
139 lpr->row_stride[level] = align(nblocksx * block_size, 16);
140
141 lpr->img_stride[level] = lpr->row_stride[level] * nblocksy;
142 }
143
144 /* Size of the image in tiles (for tiled layout) */
145 {
146 const unsigned width_t = align(width, TILE_SIZE) / TILE_SIZE;
147 const unsigned height_t = align(height, TILE_SIZE) / TILE_SIZE;
148 lpr->tiles_per_row[level] = width_t;
149 lpr->tiles_per_image[level] = width_t * height_t;
150 }
151
152 /* Number of 3D image slices or cube faces */
153 {
154 unsigned num_slices;
155
156 if (lpr->base.target == PIPE_TEXTURE_CUBE)
157 num_slices = 6;
158 else if (lpr->base.target == PIPE_TEXTURE_3D)
159 num_slices = depth;
160 else
161 num_slices = 1;
162
163 lpr->num_slices_faces[level] = num_slices;
164
165 lpr->layout[level] = alloc_layout_array(num_slices, width, height);
166 }
167
168 /* Compute size of next mipmap level */
169 width = u_minify(width, 1);
170 height = u_minify(height, 1);
171 depth = u_minify(depth, 1);
172 }
173
174 return TRUE;
175 }
176
177
178
179 static boolean
180 llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
181 struct llvmpipe_resource *lpr)
182 {
183 struct sw_winsys *winsys = screen->winsys;
184
185 /* Round up the surface size to a multiple of the tile size to
186 * avoid tile clipping.
187 */
188 const unsigned width = align(lpr->base.width0, TILE_SIZE);
189 const unsigned height = align(lpr->base.height0, TILE_SIZE);
190 const unsigned width_t = width / TILE_SIZE;
191 const unsigned height_t = height / TILE_SIZE;
192
193 lpr->tiles_per_row[0] = width_t;
194 lpr->tiles_per_image[0] = width_t * height_t;
195 lpr->num_slices_faces[0] = 1;
196 lpr->img_stride[0] = 0;
197
198 lpr->layout[0] = alloc_layout_array(1, width, height);
199 //lpr->layout[0][0] = LP_TEX_LAYOUT_LINEAR;
200
201 lpr->dt = winsys->displaytarget_create(winsys,
202 lpr->base.bind,
203 lpr->base.format,
204 width, height,
205 16,
206 &lpr->row_stride[0] );
207
208 return lpr->dt != NULL;
209 }
210
211
212 static struct pipe_resource *
213 llvmpipe_resource_create(struct pipe_screen *_screen,
214 const struct pipe_resource *templat)
215 {
216 struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
217 struct llvmpipe_resource *lpr = CALLOC_STRUCT(llvmpipe_resource);
218 if (!lpr)
219 return NULL;
220
221 lpr->base = *templat;
222 pipe_reference_init(&lpr->base.reference, 1);
223 lpr->base.screen = &screen->base;
224
225 /* assert(lpr->base.bind); */
226
227 if (resource_is_texture(&lpr->base)) {
228 if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) {
229 /* displayable surface */
230 if (!llvmpipe_displaytarget_layout(screen, lpr))
231 goto fail;
232 assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
233 }
234 else {
235 /* texture map */
236 if (!llvmpipe_texture_layout(screen, lpr))
237 goto fail;
238 assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
239 }
240 assert(lpr->layout[0]);
241 }
242 else {
243 /* other data (vertex buffer, const buffer, etc) */
244 const enum pipe_format format = templat->format;
245 const uint w = templat->width0 / util_format_get_blockheight(format);
246 const uint h = templat->height0 / util_format_get_blockwidth(format);
247 const uint d = templat->depth0;
248 const uint bpp = util_format_get_blocksize(format);
249 const uint bytes = w * h * d * bpp;
250 lpr->data = align_malloc(bytes, 16);
251 if (!lpr->data)
252 goto fail;
253 }
254
255 lpr->id = id_counter++;
256
257 #ifdef DEBUG
258 insert_at_tail(&resource_list, lpr);
259 #endif
260
261 return &lpr->base;
262
263 fail:
264 FREE(lpr);
265 return NULL;
266 }
267
268
269 static void
270 llvmpipe_resource_destroy(struct pipe_screen *pscreen,
271 struct pipe_resource *pt)
272 {
273 struct llvmpipe_screen *screen = llvmpipe_screen(pscreen);
274 struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
275
276 if (lpr->dt) {
277 /* display target */
278 struct sw_winsys *winsys = screen->winsys;
279 winsys->displaytarget_destroy(winsys, lpr->dt);
280
281 if (lpr->tiled[0].data) {
282 align_free(lpr->tiled[0].data);
283 lpr->tiled[0].data = NULL;
284 }
285
286 FREE(lpr->layout[0]);
287 }
288 else if (resource_is_texture(pt)) {
289 /* regular texture */
290 uint level;
291
292 /* free linear image data */
293 for (level = 0; level < Elements(lpr->linear); level++) {
294 if (lpr->linear[level].data) {
295 align_free(lpr->linear[level].data);
296 lpr->linear[level].data = NULL;
297 }
298 }
299
300 /* free tiled image data */
301 for (level = 0; level < Elements(lpr->tiled); level++) {
302 if (lpr->tiled[level].data) {
303 align_free(lpr->tiled[level].data);
304 lpr->tiled[level].data = NULL;
305 }
306 }
307
308 /* free layout flag arrays */
309 for (level = 0; level < Elements(lpr->tiled); level++) {
310 FREE(lpr->layout[level]);
311 lpr->layout[level] = NULL;
312 }
313 }
314 else if (!lpr->userBuffer) {
315 assert(lpr->data);
316 align_free(lpr->data);
317 }
318
319 #ifdef DEBUG
320 if (lpr->next)
321 remove_from_list(lpr);
322 #endif
323
324 FREE(lpr);
325 }
326
327
328 /**
329 * Map a resource for read/write.
330 */
331 void *
332 llvmpipe_resource_map(struct pipe_resource *resource,
333 unsigned face,
334 unsigned level,
335 unsigned zslice,
336 enum lp_texture_usage tex_usage,
337 enum lp_texture_layout layout)
338 {
339 struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
340 uint8_t *map;
341
342 assert(face < 6);
343 assert(level < LP_MAX_TEXTURE_LEVELS);
344
345 assert(tex_usage == LP_TEX_USAGE_READ ||
346 tex_usage == LP_TEX_USAGE_READ_WRITE ||
347 tex_usage == LP_TEX_USAGE_WRITE_ALL);
348
349 assert(layout == LP_TEX_LAYOUT_NONE ||
350 layout == LP_TEX_LAYOUT_TILED ||
351 layout == LP_TEX_LAYOUT_LINEAR);
352
353 if (lpr->dt) {
354 /* display target */
355 struct llvmpipe_screen *screen = llvmpipe_screen(resource->screen);
356 struct sw_winsys *winsys = screen->winsys;
357 unsigned dt_usage;
358 uint8_t *map2;
359
360 if (tex_usage == LP_TEX_USAGE_READ) {
361 dt_usage = PIPE_TRANSFER_READ;
362 }
363 else {
364 dt_usage = PIPE_TRANSFER_READ_WRITE;
365 }
366
367 assert(face == 0);
368 assert(level == 0);
369 assert(zslice == 0);
370
371 /* FIXME: keep map count? */
372 map = winsys->displaytarget_map(winsys, lpr->dt, dt_usage);
373
374 /* install this linear image in texture data structure */
375 lpr->linear[level].data = map;
376
377 /* make sure tiled data gets converted to linear data */
378 map2 = llvmpipe_get_texture_image(lpr, 0, 0, tex_usage, layout);
379 if (layout == LP_TEX_LAYOUT_LINEAR)
380 assert(map == map2);
381
382 return map2;
383 }
384 else if (resource_is_texture(resource)) {
385 /* regular texture */
386 if (resource->target != PIPE_TEXTURE_CUBE) {
387 assert(face == 0);
388 }
389 if (resource->target != PIPE_TEXTURE_3D) {
390 assert(zslice == 0);
391 }
392
393 map = llvmpipe_get_texture_image(lpr, face + zslice, level,
394 tex_usage, layout);
395 return map;
396 }
397 else {
398 return lpr->data;
399 }
400 }
401
402
403 /**
404 * Unmap a resource.
405 */
406 void
407 llvmpipe_resource_unmap(struct pipe_resource *resource,
408 unsigned face,
409 unsigned level,
410 unsigned zslice)
411 {
412 struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
413
414 if (lpr->dt) {
415 /* display target */
416 struct llvmpipe_screen *lp_screen = llvmpipe_screen(resource->screen);
417 struct sw_winsys *winsys = lp_screen->winsys;
418
419 assert(face == 0);
420 assert(level == 0);
421 assert(zslice == 0);
422
423 /* make sure linear image is up to date */
424 (void) llvmpipe_get_texture_image(lpr, face + zslice, level,
425 LP_TEX_USAGE_READ,
426 LP_TEX_LAYOUT_LINEAR);
427
428 winsys->displaytarget_unmap(winsys, lpr->dt);
429 }
430 }
431
432
433 void *
434 llvmpipe_resource_data(struct pipe_resource *resource)
435 {
436 struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
437
438 assert(!resource_is_texture(resource));
439
440 return lpr->data;
441 }
442
443
444 static struct pipe_resource *
445 llvmpipe_resource_from_handle(struct pipe_screen *screen,
446 const struct pipe_resource *template,
447 struct winsys_handle *whandle)
448 {
449 struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
450 struct llvmpipe_resource *lpr = CALLOC_STRUCT(llvmpipe_resource);
451 unsigned width, height, width_t, height_t;
452
453 /* XXX Seems like from_handled depth textures doesn't work that well */
454
455 if (!lpr)
456 return NULL;
457
458 lpr->base = *template;
459 pipe_reference_init(&lpr->base.reference, 1);
460 lpr->base.screen = screen;
461
462 width = align(lpr->base.width0, TILE_SIZE);
463 height = align(lpr->base.height0, TILE_SIZE);
464 width_t = width / TILE_SIZE;
465 height_t = height / TILE_SIZE;
466
467 /*
468 * Looks like unaligned displaytargets work just fine,
469 * at least sampler/render ones.
470 */
471 #if 0
472 assert(lpr->base.width0 == width);
473 assert(lpr->base.height0 == height);
474 #endif
475
476 lpr->tiles_per_row[0] = width_t;
477 lpr->tiles_per_image[0] = width_t * height_t;
478 lpr->num_slices_faces[0] = 1;
479 lpr->img_stride[0] = 0;
480
481 lpr->dt = winsys->displaytarget_from_handle(winsys,
482 template,
483 whandle,
484 &lpr->row_stride[0]);
485 if (!lpr->dt)
486 goto fail;
487
488 lpr->layout[0] = alloc_layout_array(1, lpr->base.width0, lpr->base.height0);
489
490 assert(lpr->layout[0]);
491 assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
492
493 lpr->id = id_counter++;
494
495 #ifdef DEBUG
496 insert_at_tail(&resource_list, lpr);
497 #endif
498
499 return &lpr->base;
500
501 fail:
502 FREE(lpr);
503 return NULL;
504 }
505
506
507 static boolean
508 llvmpipe_resource_get_handle(struct pipe_screen *screen,
509 struct pipe_resource *pt,
510 struct winsys_handle *whandle)
511 {
512 struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
513 struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
514
515 assert(lpr->dt);
516 if (!lpr->dt)
517 return FALSE;
518
519 return winsys->displaytarget_get_handle(winsys, lpr->dt, whandle);
520 }
521
522
523 static struct pipe_surface *
524 llvmpipe_get_tex_surface(struct pipe_screen *screen,
525 struct pipe_resource *pt,
526 unsigned face, unsigned level, unsigned zslice,
527 unsigned usage)
528 {
529 struct pipe_surface *ps;
530
531 assert(level <= pt->last_level);
532
533 ps = CALLOC_STRUCT(pipe_surface);
534 if (ps) {
535 pipe_reference_init(&ps->reference, 1);
536 pipe_resource_reference(&ps->texture, pt);
537 ps->format = pt->format;
538 ps->width = u_minify(pt->width0, level);
539 ps->height = u_minify(pt->height0, level);
540 ps->usage = usage;
541
542 ps->face = face;
543 ps->level = level;
544 ps->zslice = zslice;
545 }
546 return ps;
547 }
548
549
550 static void
551 llvmpipe_tex_surface_destroy(struct pipe_surface *surf)
552 {
553 /* Effectively do the texture_update work here - if texture images
554 * needed post-processing to put them into hardware layout, this is
555 * where it would happen. For llvmpipe, nothing to do.
556 */
557 assert(surf->texture);
558 pipe_resource_reference(&surf->texture, NULL);
559 FREE(surf);
560 }
561
562
563 static struct pipe_transfer *
564 llvmpipe_get_transfer(struct pipe_context *pipe,
565 struct pipe_resource *resource,
566 struct pipe_subresource sr,
567 unsigned usage,
568 const struct pipe_box *box)
569 {
570 struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
571 struct llvmpipe_resource *lprex = llvmpipe_resource(resource);
572 struct llvmpipe_transfer *lpr;
573
574 assert(resource);
575 assert(sr.level <= resource->last_level);
576
577 /*
578 * Transfers, like other pipe operations, must happen in order, so flush the
579 * context if necessary.
580 */
581 if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
582 boolean read_only = !(usage & PIPE_TRANSFER_WRITE);
583 boolean do_not_block = !!(usage & PIPE_TRANSFER_DONTBLOCK);
584 if (!llvmpipe_flush_resource(pipe, resource,
585 sr.face, sr.level,
586 0, /* flush_flags */
587 read_only,
588 TRUE, /* cpu_access */
589 do_not_block,
590 __FUNCTION__)) {
591 /*
592 * It would have blocked, but state tracker requested no to.
593 */
594 assert(do_not_block);
595 return NULL;
596 }
597 }
598
599 if (resource == llvmpipe->constants[PIPE_SHADER_FRAGMENT][0])
600 llvmpipe->dirty |= LP_NEW_CONSTANTS;
601
602 lpr = CALLOC_STRUCT(llvmpipe_transfer);
603 if (lpr) {
604 struct pipe_transfer *pt = &lpr->base;
605 pipe_resource_reference(&pt->resource, resource);
606 pt->box = *box;
607 pt->sr = sr;
608 pt->stride = lprex->row_stride[sr.level];
609 pt->slice_stride = lprex->img_stride[sr.level];
610 pt->usage = usage;
611
612 return pt;
613 }
614 return NULL;
615 }
616
617
618 static void
619 llvmpipe_transfer_destroy(struct pipe_context *pipe,
620 struct pipe_transfer *transfer)
621 {
622 /* Effectively do the texture_update work here - if texture images
623 * needed post-processing to put them into hardware layout, this is
624 * where it would happen. For llvmpipe, nothing to do.
625 */
626 assert (transfer->resource);
627 pipe_resource_reference(&transfer->resource, NULL);
628 FREE(transfer);
629 }
630
631
632 static void *
633 llvmpipe_transfer_map( struct pipe_context *pipe,
634 struct pipe_transfer *transfer )
635 {
636 struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
637 ubyte *map;
638 struct llvmpipe_resource *lpr;
639 enum pipe_format format;
640 enum lp_texture_usage tex_usage;
641 const char *mode;
642
643 assert(transfer->sr.face < 6);
644 assert(transfer->sr.level < LP_MAX_TEXTURE_LEVELS);
645
646 /*
647 printf("tex_transfer_map(%d, %d %d x %d of %d x %d, usage %d )\n",
648 transfer->x, transfer->y, transfer->width, transfer->height,
649 transfer->texture->width0,
650 transfer->texture->height0,
651 transfer->usage);
652 */
653
654 if (transfer->usage == PIPE_TRANSFER_READ) {
655 tex_usage = LP_TEX_USAGE_READ;
656 mode = "read";
657 }
658 else {
659 tex_usage = LP_TEX_USAGE_READ_WRITE;
660 mode = "read/write";
661 }
662
663 if (0) {
664 struct llvmpipe_resource *lpr = llvmpipe_resource(transfer->resource);
665 printf("transfer map tex %u mode %s\n", lpr->id, mode);
666 }
667
668
669 assert(transfer->resource);
670 lpr = llvmpipe_resource(transfer->resource);
671 format = lpr->base.format;
672
673 map = llvmpipe_resource_map(transfer->resource,
674 transfer->sr.face,
675 transfer->sr.level,
676 transfer->box.z,
677 tex_usage, LP_TEX_LAYOUT_LINEAR);
678
679
680 /* May want to do different things here depending on read/write nature
681 * of the map:
682 */
683 if (transfer->usage & PIPE_TRANSFER_WRITE) {
684 /* Do something to notify sharing contexts of a texture change.
685 */
686 screen->timestamp++;
687 }
688
689 map +=
690 transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
691 transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
692
693 return map;
694 }
695
696
697 static void
698 llvmpipe_transfer_unmap(struct pipe_context *pipe,
699 struct pipe_transfer *transfer)
700 {
701 assert(transfer->resource);
702
703 llvmpipe_resource_unmap(transfer->resource,
704 transfer->sr.face,
705 transfer->sr.level,
706 transfer->box.z);
707 }
708
709 static unsigned int
710 llvmpipe_is_resource_referenced( struct pipe_context *pipe,
711 struct pipe_resource *presource,
712 unsigned face, unsigned level)
713 {
714 struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe );
715
716 if (presource->target == PIPE_BUFFER)
717 return PIPE_UNREFERENCED;
718
719 return lp_setup_is_resource_referenced(llvmpipe->setup, presource);
720 }
721
722
723
724 /**
725 * Create buffer which wraps user-space data.
726 */
727 static struct pipe_resource *
728 llvmpipe_user_buffer_create(struct pipe_screen *screen,
729 void *ptr,
730 unsigned bytes,
731 unsigned bind_flags)
732 {
733 struct llvmpipe_resource *buffer;
734
735 buffer = CALLOC_STRUCT(llvmpipe_resource);
736 if(!buffer)
737 return NULL;
738
739 pipe_reference_init(&buffer->base.reference, 1);
740 buffer->base.screen = screen;
741 buffer->base.format = PIPE_FORMAT_R8_UNORM; /* ?? */
742 buffer->base.bind = bind_flags;
743 buffer->base.usage = PIPE_USAGE_IMMUTABLE;
744 buffer->base.flags = 0;
745 buffer->base.width0 = bytes;
746 buffer->base.height0 = 1;
747 buffer->base.depth0 = 1;
748 buffer->userBuffer = TRUE;
749 buffer->data = ptr;
750
751 return &buffer->base;
752 }
753
754
755 /**
756 * Compute size (in bytes) need to store a texture image / mipmap level,
757 * for just one cube face or one 3D texture slice
758 */
759 static unsigned
760 tex_image_face_size(const struct llvmpipe_resource *lpr, unsigned level,
761 enum lp_texture_layout layout)
762 {
763 const unsigned width = u_minify(lpr->base.width0, level);
764 const unsigned height = u_minify(lpr->base.height0, level);
765
766 assert(layout == LP_TEX_LAYOUT_TILED ||
767 layout == LP_TEX_LAYOUT_LINEAR);
768
769 if (layout == LP_TEX_LAYOUT_TILED) {
770 /* for tiled layout, force a 32bpp format */
771 const enum pipe_format format = PIPE_FORMAT_B8G8R8A8_UNORM;
772 const unsigned block_size = util_format_get_blocksize(format);
773 const unsigned nblocksy =
774 util_format_get_nblocksy(format, align(height, TILE_SIZE));
775 const unsigned nblocksx =
776 util_format_get_nblocksx(format, align(width, TILE_SIZE));
777 const unsigned buffer_size = block_size * nblocksy * nblocksx;
778 return buffer_size;
779 }
780 else {
781 /* we already computed this */
782 return lpr->img_stride[level];
783 }
784 }
785
786
787 /**
788 * Compute size (in bytes) need to store a texture image / mipmap level,
789 * including all cube faces or 3D image slices
790 */
791 static unsigned
792 tex_image_size(const struct llvmpipe_resource *lpr, unsigned level,
793 enum lp_texture_layout layout)
794 {
795 const unsigned buf_size = tex_image_face_size(lpr, level, layout);
796 return buf_size * lpr->num_slices_faces[level];
797 }
798
799
800 /**
801 * This function encapsulates some complicated logic for determining
802 * how to convert a tile of image data from linear layout to tiled
803 * layout, or vice versa.
804 * \param cur_layout the current tile layout
805 * \param target_layout the desired tile layout
806 * \param usage how the tile will be accessed (R/W vs. read-only, etc)
807 * \param new_layout_return returns the new layout mode
808 * \param convert_return returns TRUE if image conversion is needed
809 */
810 static void
811 layout_logic(enum lp_texture_layout cur_layout,
812 enum lp_texture_layout target_layout,
813 enum lp_texture_usage usage,
814 enum lp_texture_layout *new_layout_return,
815 boolean *convert)
816 {
817 enum lp_texture_layout other_layout, new_layout;
818
819 *convert = FALSE;
820
821 new_layout = 99; /* debug check */
822
823 if (target_layout == LP_TEX_LAYOUT_LINEAR) {
824 other_layout = LP_TEX_LAYOUT_TILED;
825 }
826 else {
827 assert(target_layout == LP_TEX_LAYOUT_TILED);
828 other_layout = LP_TEX_LAYOUT_LINEAR;
829 }
830
831 new_layout = target_layout; /* may get changed below */
832
833 if (cur_layout == LP_TEX_LAYOUT_BOTH) {
834 if (usage == LP_TEX_USAGE_READ) {
835 new_layout = LP_TEX_LAYOUT_BOTH;
836 }
837 }
838 else if (cur_layout == other_layout) {
839 if (usage != LP_TEX_USAGE_WRITE_ALL) {
840 /* need to convert tiled data to linear or vice versa */
841 *convert = TRUE;
842
843 if (usage == LP_TEX_USAGE_READ)
844 new_layout = LP_TEX_LAYOUT_BOTH;
845 }
846 }
847 else {
848 assert(cur_layout == LP_TEX_LAYOUT_NONE ||
849 cur_layout == target_layout);
850 }
851
852 assert(new_layout == LP_TEX_LAYOUT_BOTH ||
853 new_layout == target_layout);
854
855 *new_layout_return = new_layout;
856 }
857
858
859 /**
860 * Return pointer to a 2D texture image/face/slice.
861 * No tiled/linear conversion is done.
862 */
863 ubyte *
864 llvmpipe_get_texture_image_address(struct llvmpipe_resource *lpr,
865 unsigned face_slice, unsigned level,
866 enum lp_texture_layout layout)
867 {
868 struct llvmpipe_texture_image *img;
869 unsigned offset;
870
871 if (layout == LP_TEX_LAYOUT_LINEAR) {
872 img = &lpr->linear[level];
873 }
874 else {
875 assert (layout == LP_TEX_LAYOUT_TILED);
876 img = &lpr->tiled[level];
877 }
878
879 if (face_slice > 0)
880 offset = face_slice * tex_image_face_size(lpr, level, layout);
881 else
882 offset = 0;
883
884 return (ubyte *) img->data + offset;
885 }
886
887
888 static INLINE enum lp_texture_layout
889 llvmpipe_get_texture_tile_layout(const struct llvmpipe_resource *lpr,
890 unsigned face_slice, unsigned level,
891 unsigned x, unsigned y)
892 {
893 uint i;
894 assert(resource_is_texture(&lpr->base));
895 assert(x < lpr->tiles_per_row[level]);
896 i = face_slice * lpr->tiles_per_image[level]
897 + y * lpr->tiles_per_row[level] + x;
898 return lpr->layout[level][i];
899 }
900
901
902 static INLINE void
903 llvmpipe_set_texture_tile_layout(struct llvmpipe_resource *lpr,
904 unsigned face_slice, unsigned level,
905 unsigned x, unsigned y,
906 enum lp_texture_layout layout)
907 {
908 uint i;
909 assert(resource_is_texture(&lpr->base));
910 assert(x < lpr->tiles_per_row[level]);
911 i = face_slice * lpr->tiles_per_image[level]
912 + y * lpr->tiles_per_row[level] + x;
913 lpr->layout[level][i] = layout;
914 }
915
916
917 /**
918 * Set the layout mode for all tiles in a particular image.
919 */
920 static INLINE void
921 llvmpipe_set_texture_image_layout(struct llvmpipe_resource *lpr,
922 unsigned face_slice, unsigned level,
923 unsigned width_t, unsigned height_t,
924 enum lp_texture_layout layout)
925 {
926 const unsigned start = face_slice * lpr->tiles_per_image[level];
927 unsigned i;
928
929 for (i = 0; i < width_t * height_t; i++) {
930 lpr->layout[level][start + i] = layout;
931 }
932 }
933
934
935 /**
936 * Allocate storage for a linear or tile texture image (all cube
937 * faces and all 3D slices.
938 */
939 static void
940 alloc_image_data(struct llvmpipe_resource *lpr, unsigned level,
941 enum lp_texture_layout layout)
942 {
943 uint alignment = MAX2(16, util_cpu_caps.cacheline);
944
945 if (lpr->dt)
946 assert(level == 0);
947
948 if (layout == LP_TEX_LAYOUT_TILED) {
949 /* tiled data is stored in regular memory */
950 uint buffer_size = tex_image_size(lpr, level, layout);
951 lpr->tiled[level].data = align_malloc(buffer_size, alignment);
952 }
953 else {
954 assert(layout == LP_TEX_LAYOUT_LINEAR);
955 if (lpr->dt) {
956 /* we get the linear memory from the winsys */
957 struct llvmpipe_screen *screen = llvmpipe_screen(lpr->base.screen);
958 struct sw_winsys *winsys = screen->winsys;
959
960 lpr->linear[0].data =
961 winsys->displaytarget_map(winsys, lpr->dt,
962 PIPE_TRANSFER_READ_WRITE);
963 }
964 else {
965 /* not a display target - allocate regular memory */
966 uint buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_LINEAR);
967 lpr->linear[level].data = align_malloc(buffer_size, alignment);
968 }
969 }
970 }
971
972
973
974 /**
975 * Return pointer to texture image data (either linear or tiled layout)
976 * for a particular cube face or 3D texture slice.
977 *
978 * \param face_slice the cube face or 3D slice of interest
979 * \param usage one of LP_TEX_USAGE_READ/WRITE_ALL/READ_WRITE
980 * \param layout either LP_TEX_LAYOUT_LINEAR or _TILED or _NONE
981 */
982 void *
983 llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
984 unsigned face_slice, unsigned level,
985 enum lp_texture_usage usage,
986 enum lp_texture_layout layout)
987 {
988 /*
989 * 'target' refers to the image which we're retrieving (either in
990 * tiled or linear layout).
991 * 'other' refers to the same image but in the other layout. (it may
992 * or may not exist.
993 */
994 struct llvmpipe_texture_image *target_img;
995 struct llvmpipe_texture_image *other_img;
996 void *target_data;
997 void *other_data;
998 const unsigned width = u_minify(lpr->base.width0, level);
999 const unsigned height = u_minify(lpr->base.height0, level);
1000 const unsigned width_t = align(width, TILE_SIZE) / TILE_SIZE;
1001 const unsigned height_t = align(height, TILE_SIZE) / TILE_SIZE;
1002 enum lp_texture_layout other_layout;
1003 boolean only_allocate;
1004
1005 assert(layout == LP_TEX_LAYOUT_NONE ||
1006 layout == LP_TEX_LAYOUT_TILED ||
1007 layout == LP_TEX_LAYOUT_LINEAR);
1008
1009 assert(usage == LP_TEX_USAGE_READ ||
1010 usage == LP_TEX_USAGE_READ_WRITE ||
1011 usage == LP_TEX_USAGE_WRITE_ALL);
1012
1013 /* check for the special case of layout == LP_TEX_LAYOUT_NONE */
1014 if (layout == LP_TEX_LAYOUT_NONE) {
1015 only_allocate = TRUE;
1016 layout = LP_TEX_LAYOUT_TILED;
1017 }
1018 else {
1019 only_allocate = FALSE;
1020 }
1021
1022 if (lpr->dt) {
1023 assert(lpr->linear[level].data);
1024 }
1025
1026 /* which is target? which is other? */
1027 if (layout == LP_TEX_LAYOUT_LINEAR) {
1028 target_img = &lpr->linear[level];
1029 other_img = &lpr->tiled[level];
1030 other_layout = LP_TEX_LAYOUT_TILED;
1031 }
1032 else {
1033 target_img = &lpr->tiled[level];
1034 other_img = &lpr->linear[level];
1035 other_layout = LP_TEX_LAYOUT_LINEAR;
1036 }
1037
1038 target_data = target_img->data;
1039 other_data = other_img->data;
1040
1041 if (!target_data) {
1042 /* allocate memory for the target image now */
1043 alloc_image_data(lpr, level, layout);
1044 target_data = target_img->data;
1045 }
1046
1047 if (face_slice > 0) {
1048 unsigned target_offset, other_offset;
1049
1050 target_offset = face_slice * tex_image_face_size(lpr, level, layout);
1051 other_offset = face_slice * tex_image_face_size(lpr, level, other_layout);
1052 if (target_data) {
1053 target_data = (uint8_t *) target_data + target_offset;
1054 }
1055 if (other_data) {
1056 other_data = (uint8_t *) other_data + other_offset;
1057 }
1058 }
1059
1060 if (only_allocate) {
1061 /* Just allocating tiled memory. Don't initialize it from the
1062 * linear data if it exists.
1063 */
1064 return target_data;
1065 }
1066
1067 if (other_data) {
1068 /* may need to convert other data to the requested layout */
1069 enum lp_texture_layout new_layout;
1070 unsigned x, y;
1071
1072 /* loop over all image tiles, doing layout conversion where needed */
1073 for (y = 0; y < height_t; y++) {
1074 for (x = 0; x < width_t; x++) {
1075 enum lp_texture_layout cur_layout =
1076 llvmpipe_get_texture_tile_layout(lpr, face_slice, level, x, y);
1077 boolean convert;
1078
1079 layout_logic(cur_layout, layout, usage, &new_layout, &convert);
1080
1081 if (convert && other_data && target_data) {
1082 if (layout == LP_TEX_LAYOUT_TILED) {
1083 lp_linear_to_tiled(other_data, target_data,
1084 x * TILE_SIZE, y * TILE_SIZE,
1085 TILE_SIZE, TILE_SIZE,
1086 lpr->base.format,
1087 lpr->row_stride[level],
1088 lpr->tiles_per_row[level]);
1089 }
1090 else {
1091 assert(layout == LP_TEX_LAYOUT_LINEAR);
1092 lp_tiled_to_linear(other_data, target_data,
1093 x * TILE_SIZE, y * TILE_SIZE,
1094 TILE_SIZE, TILE_SIZE,
1095 lpr->base.format,
1096 lpr->row_stride[level],
1097 lpr->tiles_per_row[level]);
1098 }
1099 }
1100
1101 if (new_layout != cur_layout)
1102 llvmpipe_set_texture_tile_layout(lpr, face_slice, level, x, y,
1103 new_layout);
1104 }
1105 }
1106 }
1107 else {
1108 /* no other data */
1109 llvmpipe_set_texture_image_layout(lpr, face_slice, level,
1110 width_t, height_t, layout);
1111 }
1112
1113 return target_data;
1114 }
1115
1116
1117 /**
1118 * Return pointer to start of a texture image (1D, 2D, 3D, CUBE).
1119 * All cube faces and 3D slices will be converted to the requested
1120 * layout if needed.
1121 * This is typically used when we're about to sample from a texture.
1122 */
1123 void *
1124 llvmpipe_get_texture_image_all(struct llvmpipe_resource *lpr,
1125 unsigned level,
1126 enum lp_texture_usage usage,
1127 enum lp_texture_layout layout)
1128 {
1129 const int slices = lpr->num_slices_faces[level];
1130 int slice;
1131 void *map = NULL;
1132
1133 assert(slices > 0);
1134
1135 for (slice = slices - 1; slice >= 0; slice--) {
1136 map = llvmpipe_get_texture_image(lpr, slice, level, usage, layout);
1137 }
1138
1139 return map;
1140 }
1141
1142
1143 /**
1144 * Get pointer to a linear image (not the tile!) where the tile at (x,y)
1145 * is known to be in linear layout.
1146 * Conversion from tiled to linear will be done if necessary.
1147 * \return pointer to start of image/face (not the tile)
1148 */
1149 ubyte *
1150 llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr,
1151 unsigned face_slice, unsigned level,
1152 enum lp_texture_usage usage,
1153 unsigned x, unsigned y)
1154 {
1155 struct llvmpipe_texture_image *linear_img = &lpr->linear[level];
1156 enum lp_texture_layout cur_layout, new_layout;
1157 const unsigned tx = x / TILE_SIZE, ty = y / TILE_SIZE;
1158 boolean convert;
1159 uint8_t *tiled_image, *linear_image;
1160
1161 assert(resource_is_texture(&lpr->base));
1162 assert(x % TILE_SIZE == 0);
1163 assert(y % TILE_SIZE == 0);
1164
1165 if (!linear_img->data) {
1166 /* allocate memory for the linear image now */
1167 alloc_image_data(lpr, level, LP_TEX_LAYOUT_LINEAR);
1168 }
1169
1170 /* compute address of the slice/face of the image that contains the tile */
1171 tiled_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1172 LP_TEX_LAYOUT_TILED);
1173 linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1174 LP_TEX_LAYOUT_LINEAR);
1175
1176 /* get current tile layout and determine if data conversion is needed */
1177 cur_layout = llvmpipe_get_texture_tile_layout(lpr, face_slice, level, tx, ty);
1178
1179 layout_logic(cur_layout, LP_TEX_LAYOUT_LINEAR, usage,
1180 &new_layout, &convert);
1181
1182 if (convert && tiled_image && linear_image) {
1183 lp_tiled_to_linear(tiled_image, linear_image,
1184 x, y, TILE_SIZE, TILE_SIZE, lpr->base.format,
1185 lpr->row_stride[level],
1186 lpr->tiles_per_row[level]);
1187 }
1188
1189 if (new_layout != cur_layout)
1190 llvmpipe_set_texture_tile_layout(lpr, face_slice, level, tx, ty, new_layout);
1191
1192 return linear_image;
1193 }
1194
1195
1196 /**
1197 * Get pointer to tiled data for rendering.
1198 * \return pointer to the tiled data at the given tile position
1199 */
1200 ubyte *
1201 llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr,
1202 unsigned face_slice, unsigned level,
1203 enum lp_texture_usage usage,
1204 unsigned x, unsigned y)
1205 {
1206 struct llvmpipe_texture_image *tiled_img = &lpr->tiled[level];
1207 enum lp_texture_layout cur_layout, new_layout;
1208 const unsigned tx = x / TILE_SIZE, ty = y / TILE_SIZE;
1209 boolean convert;
1210 uint8_t *tiled_image, *linear_image;
1211 unsigned tile_offset;
1212
1213 assert(x % TILE_SIZE == 0);
1214 assert(y % TILE_SIZE == 0);
1215
1216 if (!tiled_img->data) {
1217 /* allocate memory for the tiled image now */
1218 alloc_image_data(lpr, level, LP_TEX_LAYOUT_TILED);
1219 }
1220
1221 /* compute address of the slice/face of the image that contains the tile */
1222 tiled_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1223 LP_TEX_LAYOUT_TILED);
1224 linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1225 LP_TEX_LAYOUT_LINEAR);
1226
1227 /* get current tile layout and see if we need to convert the data */
1228 cur_layout = llvmpipe_get_texture_tile_layout(lpr, face_slice, level, tx, ty);
1229
1230 layout_logic(cur_layout, LP_TEX_LAYOUT_TILED, usage, &new_layout, &convert);
1231 if (convert && linear_image && tiled_image) {
1232 lp_linear_to_tiled(linear_image, tiled_image,
1233 x, y, TILE_SIZE, TILE_SIZE, lpr->base.format,
1234 lpr->row_stride[level],
1235 lpr->tiles_per_row[level]);
1236 }
1237
1238 if (!tiled_image)
1239 return NULL;
1240
1241 if (new_layout != cur_layout)
1242 llvmpipe_set_texture_tile_layout(lpr, face_slice, level, tx, ty, new_layout);
1243
1244 /* compute, return address of the 64x64 tile */
1245 tile_offset = (ty * lpr->tiles_per_row[level] + tx)
1246 * TILE_SIZE * TILE_SIZE * 4;
1247
1248 return (ubyte *) tiled_image + tile_offset;
1249 }
1250
1251
1252 /**
1253 * Get pointer to tiled data for rendering.
1254 * \return pointer to the tiled data at the given tile position
1255 */
1256 void
1257 llvmpipe_unswizzle_cbuf_tile(struct llvmpipe_resource *lpr,
1258 unsigned face_slice, unsigned level,
1259 unsigned x, unsigned y,
1260 uint8_t *tile)
1261 {
1262 struct llvmpipe_texture_image *linear_img = &lpr->linear[level];
1263 const unsigned tx = x / TILE_SIZE, ty = y / TILE_SIZE;
1264 uint8_t *linear_image;
1265
1266 assert(x % TILE_SIZE == 0);
1267 assert(y % TILE_SIZE == 0);
1268
1269 if (!linear_img->data) {
1270 /* allocate memory for the linear image now */
1271 alloc_image_data(lpr, level, LP_TEX_LAYOUT_LINEAR);
1272 }
1273
1274 /* compute address of the slice/face of the image that contains the tile */
1275 linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1276 LP_TEX_LAYOUT_LINEAR);
1277
1278 {
1279 uint ii = x, jj = y;
1280 uint tile_offset = jj / TILE_SIZE + ii / TILE_SIZE;
1281 uint byte_offset = tile_offset * TILE_SIZE * TILE_SIZE * 4;
1282
1283 /* Note that lp_tiled_to_linear expects the tile parameter to
1284 * point at the first tile in a whole-image sized array. In
1285 * this code, we have only a single tile and have to do some
1286 * pointer arithmetic to figure out where the "image" would have
1287 * started.
1288 */
1289 lp_tiled_to_linear(tile - byte_offset, linear_image,
1290 x, y, TILE_SIZE, TILE_SIZE,
1291 lpr->base.format,
1292 lpr->row_stride[level],
1293 1); /* tiles per row */
1294 }
1295
1296 llvmpipe_set_texture_tile_layout(lpr, face_slice, level, tx, ty,
1297 LP_TEX_LAYOUT_LINEAR);
1298 }
1299
1300
1301 /**
1302 * Get pointer to tiled data for rendering.
1303 * \return pointer to the tiled data at the given tile position
1304 */
1305 void
1306 llvmpipe_swizzle_cbuf_tile(struct llvmpipe_resource *lpr,
1307 unsigned face_slice, unsigned level,
1308 unsigned x, unsigned y,
1309 uint8_t *tile)
1310 {
1311 uint8_t *linear_image;
1312
1313 assert(x % TILE_SIZE == 0);
1314 assert(y % TILE_SIZE == 0);
1315
1316 /* compute address of the slice/face of the image that contains the tile */
1317 linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1318 LP_TEX_LAYOUT_LINEAR);
1319
1320 if (linear_image) {
1321 uint ii = x, jj = y;
1322 uint tile_offset = jj / TILE_SIZE + ii / TILE_SIZE;
1323 uint byte_offset = tile_offset * TILE_SIZE * TILE_SIZE * 4;
1324
1325 /* Note that lp_linear_to_tiled expects the tile parameter to
1326 * point at the first tile in a whole-image sized array. In
1327 * this code, we have only a single tile and have to do some
1328 * pointer arithmetic to figure out where the "image" would have
1329 * started.
1330 */
1331 lp_linear_to_tiled(linear_image, tile - byte_offset,
1332 x, y, TILE_SIZE, TILE_SIZE,
1333 lpr->base.format,
1334 lpr->row_stride[level],
1335 1); /* tiles per row */
1336 }
1337 }
1338
1339
1340 /**
1341 * Return size of resource in bytes
1342 */
1343 unsigned
1344 llvmpipe_resource_size(const struct pipe_resource *resource)
1345 {
1346 const struct llvmpipe_resource *lpr = llvmpipe_resource_const(resource);
1347 unsigned lvl, size = 0;
1348
1349 for (lvl = 0; lvl <= lpr->base.last_level; lvl++) {
1350 if (lpr->linear[lvl].data)
1351 size += tex_image_size(lpr, lvl, LP_TEX_LAYOUT_LINEAR);
1352
1353 if (lpr->tiled[lvl].data)
1354 size += tex_image_size(lpr, lvl, LP_TEX_LAYOUT_TILED);
1355 }
1356
1357 return size;
1358 }
1359
1360
1361 #ifdef DEBUG
1362 void
1363 llvmpipe_print_resources(void)
1364 {
1365 struct llvmpipe_resource *lpr;
1366 unsigned n = 0, total = 0;
1367
1368 debug_printf("LLVMPIPE: current resources:\n");
1369 foreach(lpr, &resource_list) {
1370 unsigned size = llvmpipe_resource_size(&lpr->base);
1371 debug_printf("resource %u at %p, size %ux%ux%u: %u bytes, refcount %u\n",
1372 lpr->id, (void *) lpr,
1373 lpr->base.width0, lpr->base.height0, lpr->base.depth0,
1374 size, lpr->base.reference.count);
1375 total += size;
1376 n++;
1377 }
1378 debug_printf("LLVMPIPE: total size of %u resources: %u\n", n, total);
1379 }
1380 #endif
1381
1382
1383 void
1384 llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen)
1385 {
1386 #ifdef DEBUG
1387 /* init linked list for tracking resources */
1388 {
1389 static boolean first_call = TRUE;
1390 if (first_call) {
1391 memset(&resource_list, 0, sizeof(resource_list));
1392 make_empty_list(&resource_list);
1393 first_call = FALSE;
1394 }
1395 }
1396 #endif
1397
1398 screen->resource_create = llvmpipe_resource_create;
1399 screen->resource_destroy = llvmpipe_resource_destroy;
1400 screen->resource_from_handle = llvmpipe_resource_from_handle;
1401 screen->resource_get_handle = llvmpipe_resource_get_handle;
1402 screen->user_buffer_create = llvmpipe_user_buffer_create;
1403
1404 screen->get_tex_surface = llvmpipe_get_tex_surface;
1405 screen->tex_surface_destroy = llvmpipe_tex_surface_destroy;
1406 }
1407
1408
1409 void
1410 llvmpipe_init_context_resource_funcs(struct pipe_context *pipe)
1411 {
1412 pipe->get_transfer = llvmpipe_get_transfer;
1413 pipe->transfer_destroy = llvmpipe_transfer_destroy;
1414 pipe->transfer_map = llvmpipe_transfer_map;
1415 pipe->transfer_unmap = llvmpipe_transfer_unmap;
1416 pipe->is_resource_referenced = llvmpipe_is_resource_referenced;
1417
1418 pipe->transfer_flush_region = u_default_transfer_flush_region;
1419 pipe->transfer_inline_write = u_default_transfer_inline_write;
1420 }