1 /**************************************************************************
3 * Copyright 2006 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
29 * Keith Whitwell <keithw@vmware.com>
30 * Michel Dänzer <daenzer@vmware.com>
35 #include "pipe/p_context.h"
36 #include "pipe/p_defines.h"
38 #include "util/u_inlines.h"
39 #include "util/u_cpu_detect.h"
40 #include "util/format/u_format.h"
41 #include "util/u_math.h"
42 #include "util/u_memory.h"
43 #include "util/simple_list.h"
44 #include "util/u_transfer.h"
46 #include "lp_context.h"
48 #include "lp_screen.h"
49 #include "lp_texture.h"
54 #include "frontend/sw_winsys.h"
58 static struct llvmpipe_resource resource_list
;
60 static unsigned id_counter
= 0;
64 * Conventional allocation path for non-display textures:
65 * Compute strides and allocate data (unless asked not to).
68 llvmpipe_texture_layout(struct llvmpipe_screen
*screen
,
69 struct llvmpipe_resource
*lpr
,
72 struct pipe_resource
*pt
= &lpr
->base
;
74 unsigned width
= pt
->width0
;
75 unsigned height
= pt
->height0
;
76 unsigned depth
= pt
->depth0
;
77 uint64_t total_size
= 0;
78 unsigned layers
= pt
->array_size
;
79 unsigned num_samples
= util_res_sample_count(pt
);
82 * This alignment here (same for displaytarget) was added for the purpose of
83 * ARB_map_buffer_alignment. I am not convinced it's needed for non-buffer
84 * resources. Otherwise we'd want the max of cacheline size and 16 (max size
85 * of a block for all formats) though this should not be strictly necessary
86 * neither. In any case it can only affect compressed or 1d textures.
88 unsigned mip_align
= MAX2(64, util_cpu_caps
.cacheline
);
90 assert(LP_MAX_TEXTURE_2D_LEVELS
<= LP_MAX_TEXTURE_LEVELS
);
91 assert(LP_MAX_TEXTURE_3D_LEVELS
<= LP_MAX_TEXTURE_LEVELS
);
93 for (level
= 0; level
<= pt
->last_level
; level
++) {
95 unsigned align_x
, align_y
, nblocksx
, nblocksy
, block_size
, num_slices
;
97 /* Row stride and image stride */
99 /* For non-compressed formats we need 4x4 pixel alignment
100 * so we can read/write LP_RASTER_BLOCK_SIZE when rendering to them.
101 * We also want cache line size in x direction,
102 * otherwise same cache line could end up in multiple threads.
103 * For explicit 1d resources however we reduce this to 4x1 and
104 * handle specially in render output code (as we need to do special
105 * handling there for buffers in any case).
107 if (util_format_is_compressed(pt
->format
))
108 align_x
= align_y
= 1;
110 align_x
= LP_RASTER_BLOCK_SIZE
;
111 if (llvmpipe_resource_is_1d(&lpr
->base
))
114 align_y
= LP_RASTER_BLOCK_SIZE
;
117 nblocksx
= util_format_get_nblocksx(pt
->format
,
118 align(width
, align_x
));
119 nblocksy
= util_format_get_nblocksy(pt
->format
,
120 align(height
, align_y
));
121 block_size
= util_format_get_blocksize(pt
->format
);
123 if (util_format_is_compressed(pt
->format
))
124 lpr
->row_stride
[level
] = nblocksx
* block_size
;
126 lpr
->row_stride
[level
] = align(nblocksx
* block_size
, util_cpu_caps
.cacheline
);
128 /* if row_stride * height > LP_MAX_TEXTURE_SIZE */
129 if ((uint64_t)lpr
->row_stride
[level
] * nblocksy
> LP_MAX_TEXTURE_SIZE
) {
130 /* image too large */
134 lpr
->img_stride
[level
] = lpr
->row_stride
[level
] * nblocksy
;
136 /* Number of 3D image slices, cube faces or texture array layers */
137 if (lpr
->base
.target
== PIPE_TEXTURE_CUBE
) {
141 if (lpr
->base
.target
== PIPE_TEXTURE_3D
)
143 else if (lpr
->base
.target
== PIPE_TEXTURE_1D_ARRAY
||
144 lpr
->base
.target
== PIPE_TEXTURE_2D_ARRAY
||
145 lpr
->base
.target
== PIPE_TEXTURE_CUBE
||
146 lpr
->base
.target
== PIPE_TEXTURE_CUBE_ARRAY
)
151 /* if img_stride * num_slices_faces > LP_MAX_TEXTURE_SIZE */
152 mipsize
= (uint64_t)lpr
->img_stride
[level
] * num_slices
;
153 if (mipsize
> LP_MAX_TEXTURE_SIZE
) {
154 /* volume too large */
158 lpr
->mip_offsets
[level
] = total_size
;
160 total_size
+= align((unsigned)mipsize
, mip_align
);
161 if (total_size
> LP_MAX_TEXTURE_SIZE
) {
165 /* Compute size of next mipmap level */
166 width
= u_minify(width
, 1);
167 height
= u_minify(height
, 1);
168 depth
= u_minify(depth
, 1);
171 lpr
->sample_stride
= total_size
;
172 total_size
*= num_samples
;
174 lpr
->size_required
= total_size
;
176 lpr
->tex_data
= align_malloc(total_size
, mip_align
);
177 if (!lpr
->tex_data
) {
181 memset(lpr
->tex_data
, 0, total_size
);
193 * Check the size of the texture specified by 'res'.
194 * \return TRUE if OK, FALSE if too large.
197 llvmpipe_can_create_resource(struct pipe_screen
*screen
,
198 const struct pipe_resource
*res
)
200 struct llvmpipe_resource lpr
;
201 memset(&lpr
, 0, sizeof(lpr
));
203 return llvmpipe_texture_layout(llvmpipe_screen(screen
), &lpr
, false);
208 llvmpipe_displaytarget_layout(struct llvmpipe_screen
*screen
,
209 struct llvmpipe_resource
*lpr
,
210 const void *map_front_private
)
212 struct sw_winsys
*winsys
= screen
->winsys
;
214 /* Round up the surface size to a multiple of the tile size to
215 * avoid tile clipping.
217 const unsigned width
= MAX2(1, align(lpr
->base
.width0
, TILE_SIZE
));
218 const unsigned height
= MAX2(1, align(lpr
->base
.height0
, TILE_SIZE
));
220 lpr
->dt
= winsys
->displaytarget_create(winsys
,
226 &lpr
->row_stride
[0] );
231 if (!map_front_private
) {
232 void *map
= winsys
->displaytarget_map(winsys
, lpr
->dt
,
233 PIPE_TRANSFER_WRITE
);
236 memset(map
, 0, height
* lpr
->row_stride
[0]);
238 winsys
->displaytarget_unmap(winsys
, lpr
->dt
);
245 static struct pipe_resource
*
246 llvmpipe_resource_create_all(struct pipe_screen
*_screen
,
247 const struct pipe_resource
*templat
,
248 const void *map_front_private
, bool alloc_backing
)
250 struct llvmpipe_screen
*screen
= llvmpipe_screen(_screen
);
251 struct llvmpipe_resource
*lpr
= CALLOC_STRUCT(llvmpipe_resource
);
255 lpr
->base
= *templat
;
256 pipe_reference_init(&lpr
->base
.reference
, 1);
257 lpr
->base
.screen
= &screen
->base
;
259 /* assert(lpr->base.bind); */
261 if (llvmpipe_resource_is_texture(&lpr
->base
)) {
262 if (lpr
->base
.bind
& (PIPE_BIND_DISPLAY_TARGET
|
265 /* displayable surface */
266 if (!llvmpipe_displaytarget_layout(screen
, lpr
, map_front_private
))
271 if (!llvmpipe_texture_layout(screen
, lpr
, alloc_backing
))
276 /* other data (vertex buffer, const buffer, etc) */
277 const uint bytes
= templat
->width0
;
278 assert(util_format_get_blocksize(templat
->format
) == 1);
279 assert(templat
->height0
== 1);
280 assert(templat
->depth0
== 1);
281 assert(templat
->last_level
== 0);
283 * Reserve some extra storage since if we'd render to a buffer we
284 * read/write always LP_RASTER_BLOCK_SIZE pixels, but the element
285 * offset doesn't need to be aligned to LP_RASTER_BLOCK_SIZE.
288 * buffers don't really have stride but it's probably safer
289 * (for code doing same calculations for buffers and textures)
290 * to put something sane in there.
292 lpr
->row_stride
[0] = bytes
;
294 lpr
->size_required
= bytes
;
295 if (!(templat
->flags
& PIPE_RESOURCE_FLAG_DONT_OVER_ALLOCATE
))
296 lpr
->size_required
+= (LP_RASTER_BLOCK_SIZE
- 1) * 4 * sizeof(float);
299 lpr
->data
= align_malloc(lpr
->size_required
, 64);
303 memset(lpr
->data
, 0, bytes
);
307 lpr
->id
= id_counter
++;
310 insert_at_tail(&resource_list
, lpr
);
320 static struct pipe_resource
*
321 llvmpipe_resource_create_front(struct pipe_screen
*_screen
,
322 const struct pipe_resource
*templat
,
323 const void *map_front_private
)
325 return llvmpipe_resource_create_all(_screen
, templat
, map_front_private
, true);
328 static struct pipe_resource
*
329 llvmpipe_resource_create(struct pipe_screen
*_screen
,
330 const struct pipe_resource
*templat
)
332 return llvmpipe_resource_create_front(_screen
, templat
, NULL
);
335 static struct pipe_resource
*
336 llvmpipe_resource_create_unbacked(struct pipe_screen
*_screen
,
337 const struct pipe_resource
*templat
,
338 uint64_t *size_required
)
340 struct pipe_resource
*pt
;
341 struct llvmpipe_resource
*lpr
;
342 pt
= llvmpipe_resource_create_all(_screen
, templat
, NULL
, false);
345 lpr
= llvmpipe_resource(pt
);
346 lpr
->backable
= true;
347 *size_required
= lpr
->size_required
;
352 llvmpipe_resource_destroy(struct pipe_screen
*pscreen
,
353 struct pipe_resource
*pt
)
355 struct llvmpipe_screen
*screen
= llvmpipe_screen(pscreen
);
356 struct llvmpipe_resource
*lpr
= llvmpipe_resource(pt
);
358 if (!lpr
->backable
) {
361 struct sw_winsys
*winsys
= screen
->winsys
;
362 winsys
->displaytarget_destroy(winsys
, lpr
->dt
);
364 else if (llvmpipe_resource_is_texture(pt
)) {
365 /* free linear image data */
367 align_free(lpr
->tex_data
);
368 lpr
->tex_data
= NULL
;
371 else if (!lpr
->userBuffer
) {
373 align_free(lpr
->data
);
378 remove_from_list(lpr
);
386 * Map a resource for read/write.
389 llvmpipe_resource_map(struct pipe_resource
*resource
,
392 enum lp_texture_usage tex_usage
)
394 struct llvmpipe_resource
*lpr
= llvmpipe_resource(resource
);
397 assert(level
< LP_MAX_TEXTURE_LEVELS
);
398 assert(layer
< (u_minify(resource
->depth0
, level
) + resource
->array_size
- 1));
400 assert(tex_usage
== LP_TEX_USAGE_READ
||
401 tex_usage
== LP_TEX_USAGE_READ_WRITE
||
402 tex_usage
== LP_TEX_USAGE_WRITE_ALL
);
406 struct llvmpipe_screen
*screen
= llvmpipe_screen(resource
->screen
);
407 struct sw_winsys
*winsys
= screen
->winsys
;
410 if (tex_usage
== LP_TEX_USAGE_READ
) {
411 dt_usage
= PIPE_TRANSFER_READ
;
414 dt_usage
= PIPE_TRANSFER_READ_WRITE
;
420 /* FIXME: keep map count? */
421 map
= winsys
->displaytarget_map(winsys
, lpr
->dt
, dt_usage
);
423 /* install this linear image in texture data structure */
428 else if (llvmpipe_resource_is_texture(resource
)) {
430 map
= llvmpipe_get_texture_image_address(lpr
, layer
, level
);
443 llvmpipe_resource_unmap(struct pipe_resource
*resource
,
447 struct llvmpipe_resource
*lpr
= llvmpipe_resource(resource
);
451 struct llvmpipe_screen
*lp_screen
= llvmpipe_screen(resource
->screen
);
452 struct sw_winsys
*winsys
= lp_screen
->winsys
;
457 winsys
->displaytarget_unmap(winsys
, lpr
->dt
);
463 llvmpipe_resource_data(struct pipe_resource
*resource
)
465 struct llvmpipe_resource
*lpr
= llvmpipe_resource(resource
);
467 assert(!llvmpipe_resource_is_texture(resource
));
473 static struct pipe_resource
*
474 llvmpipe_resource_from_handle(struct pipe_screen
*screen
,
475 const struct pipe_resource
*template,
476 struct winsys_handle
*whandle
,
479 struct sw_winsys
*winsys
= llvmpipe_screen(screen
)->winsys
;
480 struct llvmpipe_resource
*lpr
;
482 /* XXX Seems like from_handled depth textures doesn't work that well */
484 lpr
= CALLOC_STRUCT(llvmpipe_resource
);
489 lpr
->base
= *template;
490 pipe_reference_init(&lpr
->base
.reference
, 1);
491 lpr
->base
.screen
= screen
;
494 * Looks like unaligned displaytargets work just fine,
495 * at least sampler/render ones.
498 assert(lpr
->base
.width0
== width
);
499 assert(lpr
->base
.height0
== height
);
502 lpr
->dt
= winsys
->displaytarget_from_handle(winsys
,
505 &lpr
->row_stride
[0]);
510 lpr
->id
= id_counter
++;
513 insert_at_tail(&resource_list
, lpr
);
526 llvmpipe_resource_get_handle(struct pipe_screen
*screen
,
527 struct pipe_context
*ctx
,
528 struct pipe_resource
*pt
,
529 struct winsys_handle
*whandle
,
532 struct sw_winsys
*winsys
= llvmpipe_screen(screen
)->winsys
;
533 struct llvmpipe_resource
*lpr
= llvmpipe_resource(pt
);
539 return winsys
->displaytarget_get_handle(winsys
, lpr
->dt
, whandle
);
544 llvmpipe_transfer_map_ms( struct pipe_context
*pipe
,
545 struct pipe_resource
*resource
,
549 const struct pipe_box
*box
,
550 struct pipe_transfer
**transfer
)
552 struct llvmpipe_context
*llvmpipe
= llvmpipe_context(pipe
);
553 struct llvmpipe_screen
*screen
= llvmpipe_screen(pipe
->screen
);
554 struct llvmpipe_resource
*lpr
= llvmpipe_resource(resource
);
555 struct llvmpipe_transfer
*lpt
;
556 struct pipe_transfer
*pt
;
558 enum pipe_format format
;
559 enum lp_texture_usage tex_usage
;
563 assert(level
<= resource
->last_level
);
566 * Transfers, like other pipe operations, must happen in order, so flush the
567 * context if necessary.
569 if (!(usage
& PIPE_TRANSFER_UNSYNCHRONIZED
)) {
570 boolean read_only
= !(usage
& PIPE_TRANSFER_WRITE
);
571 boolean do_not_block
= !!(usage
& PIPE_TRANSFER_DONTBLOCK
);
572 if (!llvmpipe_flush_resource(pipe
, resource
,
575 TRUE
, /* cpu_access */
579 * It would have blocked, but gallium frontend requested no to.
581 assert(do_not_block
);
586 /* Check if we're mapping a current constant buffer */
587 if ((usage
& PIPE_TRANSFER_WRITE
) &&
588 (resource
->bind
& PIPE_BIND_CONSTANT_BUFFER
)) {
590 for (i
= 0; i
< ARRAY_SIZE(llvmpipe
->constants
[PIPE_SHADER_FRAGMENT
]); ++i
) {
591 if (resource
== llvmpipe
->constants
[PIPE_SHADER_FRAGMENT
][i
].buffer
) {
592 /* constants may have changed */
593 llvmpipe
->dirty
|= LP_NEW_FS_CONSTANTS
;
599 lpt
= CALLOC_STRUCT(llvmpipe_transfer
);
603 pipe_resource_reference(&pt
->resource
, resource
);
606 pt
->stride
= lpr
->row_stride
[level
];
607 pt
->layer_stride
= lpr
->img_stride
[level
];
611 assert(level
< LP_MAX_TEXTURE_LEVELS
);
614 printf("tex_transfer_map(%d, %d %d x %d of %d x %d, usage %d )\n",
615 transfer->x, transfer->y, transfer->width, transfer->height,
616 transfer->texture->width0,
617 transfer->texture->height0,
621 if (usage
== PIPE_TRANSFER_READ
) {
622 tex_usage
= LP_TEX_USAGE_READ
;
626 tex_usage
= LP_TEX_USAGE_READ_WRITE
;
631 printf("transfer map tex %u mode %s\n", lpr
->id
, mode
);
634 format
= lpr
->base
.format
;
636 map
= llvmpipe_resource_map(resource
,
642 /* May want to do different things here depending on read/write nature
645 if (usage
& PIPE_TRANSFER_WRITE
) {
646 /* Do something to notify sharing contexts of a texture change.
652 box
->y
/ util_format_get_blockheight(format
) * pt
->stride
+
653 box
->x
/ util_format_get_blockwidth(format
) * util_format_get_blocksize(format
);
655 map
+= sample
* lpr
->sample_stride
;
660 llvmpipe_transfer_map( struct pipe_context
*pipe
,
661 struct pipe_resource
*resource
,
664 const struct pipe_box
*box
,
665 struct pipe_transfer
**transfer
)
667 return llvmpipe_transfer_map_ms(pipe
, resource
, level
, usage
, 0, box
, transfer
);
671 llvmpipe_transfer_unmap(struct pipe_context
*pipe
,
672 struct pipe_transfer
*transfer
)
674 assert(transfer
->resource
);
676 llvmpipe_resource_unmap(transfer
->resource
,
680 /* Effectively do the texture_update work here - if texture images
681 * needed post-processing to put them into hardware layout, this is
682 * where it would happen. For llvmpipe, nothing to do.
684 assert (transfer
->resource
);
685 pipe_resource_reference(&transfer
->resource
, NULL
);
690 llvmpipe_is_resource_referenced( struct pipe_context
*pipe
,
691 struct pipe_resource
*presource
,
694 struct llvmpipe_context
*llvmpipe
= llvmpipe_context( pipe
);
695 if (!(presource
->bind
& (PIPE_BIND_DEPTH_STENCIL
|
696 PIPE_BIND_RENDER_TARGET
|
697 PIPE_BIND_SAMPLER_VIEW
|
698 PIPE_BIND_SHADER_BUFFER
|
699 PIPE_BIND_SHADER_IMAGE
)))
700 return LP_UNREFERENCED
;
702 return lp_setup_is_resource_referenced(llvmpipe
->setup
, presource
);
707 * Returns the largest possible alignment for a format in llvmpipe
710 llvmpipe_get_format_alignment( enum pipe_format format
)
712 const struct util_format_description
*desc
= util_format_description(format
);
717 for (i
= 0; i
< desc
->nr_channels
; ++i
) {
718 size
+= desc
->channel
[i
].size
;
723 if (!util_is_power_of_two_or_zero(bytes
)) {
724 bytes
/= desc
->nr_channels
;
727 if (bytes
% 2 || bytes
< 1) {
736 * Create buffer which wraps user-space data.
739 struct pipe_resource
*
740 llvmpipe_user_buffer_create(struct pipe_screen
*screen
,
745 struct llvmpipe_resource
*buffer
;
747 buffer
= CALLOC_STRUCT(llvmpipe_resource
);
751 pipe_reference_init(&buffer
->base
.reference
, 1);
752 buffer
->base
.screen
= screen
;
753 buffer
->base
.format
= PIPE_FORMAT_R8_UNORM
; /* ?? */
754 buffer
->base
.bind
= bind_flags
;
755 buffer
->base
.usage
= PIPE_USAGE_IMMUTABLE
;
756 buffer
->base
.flags
= 0;
757 buffer
->base
.width0
= bytes
;
758 buffer
->base
.height0
= 1;
759 buffer
->base
.depth0
= 1;
760 buffer
->base
.array_size
= 1;
761 buffer
->userBuffer
= TRUE
;
764 return &buffer
->base
;
769 * Compute size (in bytes) need to store a texture image / mipmap level,
770 * for just one cube face, one array layer or one 3D texture slice
773 tex_image_face_size(const struct llvmpipe_resource
*lpr
, unsigned level
)
775 return lpr
->img_stride
[level
];
780 * Return pointer to a 2D texture image/face/slice.
781 * No tiled/linear conversion is done.
784 llvmpipe_get_texture_image_address(struct llvmpipe_resource
*lpr
,
785 unsigned face_slice
, unsigned level
)
789 assert(llvmpipe_resource_is_texture(&lpr
->base
));
791 offset
= lpr
->mip_offsets
[level
];
794 offset
+= face_slice
* tex_image_face_size(lpr
, level
);
796 return (ubyte
*) lpr
->tex_data
+ offset
;
801 * Return size of resource in bytes
804 llvmpipe_resource_size(const struct pipe_resource
*resource
)
806 const struct llvmpipe_resource
*lpr
= llvmpipe_resource_const(resource
);
809 if (llvmpipe_resource_is_texture(resource
)) {
810 /* Note this will always return 0 for displaytarget resources */
811 size
= lpr
->total_alloc_size
;
814 size
= resource
->width0
;
820 llvmpipe_memory_barrier(struct pipe_context
*pipe
,
823 /* this may be an overly large hammer for this nut. */
824 llvmpipe_finish(pipe
, "barrier");
827 static struct pipe_memory_allocation
*llvmpipe_allocate_memory(struct pipe_screen
*screen
, uint64_t size
)
829 return os_malloc_aligned(size
, 256);
832 static void llvmpipe_free_memory(struct pipe_screen
*screen
,
833 struct pipe_memory_allocation
*pmem
)
835 os_free_aligned(pmem
);
838 static void llvmpipe_resource_bind_backing(struct pipe_screen
*screen
,
839 struct pipe_resource
*pt
,
840 struct pipe_memory_allocation
*pmem
,
843 struct llvmpipe_resource
*lpr
= llvmpipe_resource(pt
);
848 if (llvmpipe_resource_is_texture(&lpr
->base
))
849 lpr
->tex_data
= (char *)pmem
+ offset
;
851 lpr
->data
= (char *)pmem
+ offset
;
852 lpr
->backing_offset
= offset
;
855 static void *llvmpipe_map_memory(struct pipe_screen
*screen
,
856 struct pipe_memory_allocation
*pmem
)
861 static void llvmpipe_unmap_memory(struct pipe_screen
*screen
,
862 struct pipe_memory_allocation
*pmem
)
868 llvmpipe_print_resources(void)
870 struct llvmpipe_resource
*lpr
;
871 unsigned n
= 0, total
= 0;
873 debug_printf("LLVMPIPE: current resources:\n");
874 foreach(lpr
, &resource_list
) {
875 unsigned size
= llvmpipe_resource_size(&lpr
->base
);
876 debug_printf("resource %u at %p, size %ux%ux%u: %u bytes, refcount %u\n",
877 lpr
->id
, (void *) lpr
,
878 lpr
->base
.width0
, lpr
->base
.height0
, lpr
->base
.depth0
,
879 size
, lpr
->base
.reference
.count
);
883 debug_printf("LLVMPIPE: total size of %u resources: %u\n", n
, total
);
888 llvmpipe_get_resource_info(struct pipe_screen
*screen
,
889 struct pipe_resource
*resource
,
893 struct llvmpipe_resource
*lpr
= llvmpipe_resource(resource
);
895 *stride
= lpr
->row_stride
[0];
900 llvmpipe_init_screen_resource_funcs(struct pipe_screen
*screen
)
903 /* init linked list for tracking resources */
905 static boolean first_call
= TRUE
;
907 memset(&resource_list
, 0, sizeof(resource_list
));
908 make_empty_list(&resource_list
);
914 screen
->resource_create
= llvmpipe_resource_create
;
915 /* screen->resource_create_front = llvmpipe_resource_create_front; */
916 screen
->resource_destroy
= llvmpipe_resource_destroy
;
917 screen
->resource_from_handle
= llvmpipe_resource_from_handle
;
918 screen
->resource_get_handle
= llvmpipe_resource_get_handle
;
919 screen
->can_create_resource
= llvmpipe_can_create_resource
;
921 screen
->resource_create_unbacked
= llvmpipe_resource_create_unbacked
;
923 screen
->resource_get_info
= llvmpipe_get_resource_info
;
924 screen
->allocate_memory
= llvmpipe_allocate_memory
;
925 screen
->free_memory
= llvmpipe_free_memory
;
926 screen
->map_memory
= llvmpipe_map_memory
;
927 screen
->unmap_memory
= llvmpipe_unmap_memory
;
929 screen
->resource_bind_backing
= llvmpipe_resource_bind_backing
;
934 llvmpipe_init_context_resource_funcs(struct pipe_context
*pipe
)
936 pipe
->transfer_map
= llvmpipe_transfer_map
;
937 pipe
->transfer_unmap
= llvmpipe_transfer_unmap
;
939 pipe
->transfer_flush_region
= u_default_transfer_flush_region
;
940 pipe
->buffer_subdata
= u_default_buffer_subdata
;
941 pipe
->texture_subdata
= u_default_texture_subdata
;
943 pipe
->memory_barrier
= llvmpipe_memory_barrier
;