2 #include "util/u_debug.h"
6 pipe_linear_to_tile(size_t src_stride
, const void *src_ptr
,
7 struct pipe_tile_info
*t
, void *dst_ptr
)
11 size_t bytes
= t
->cols
* t
->block
.size
;
12 char *dst_ptr2
= (char *) dst_ptr
;
14 assert(pipe_linear_check_tile(t
));
16 /* lets write lineary to the tiled buffer */
17 for (y
= 0; y
< t
->tiles_y
; y
++) {
18 for (x
= 0; x
< t
->tiles_x
; x
++) {
19 /* this inner loop could be replace with SSE magic */
20 ptr
= (char*)src_ptr
+ src_stride
* t
->rows
* y
+ bytes
* x
;
21 for (z
= 0; z
< t
->rows
; z
++) {
22 memcpy(dst_ptr2
, ptr
, bytes
);
30 void pipe_linear_from_tile(struct pipe_tile_info
*t
, const void *src_ptr
,
31 size_t dst_stride
, void *dst_ptr
)
35 size_t bytes
= t
->cols
* t
->block
.size
;
36 const char *src_ptr2
= (const char *) src_ptr
;
38 /* lets read lineary from the tiled buffer */
39 for (y
= 0; y
< t
->tiles_y
; y
++) {
40 for (x
= 0; x
< t
->tiles_x
; x
++) {
41 /* this inner loop could be replace with SSE magic */
42 ptr
= (char*)dst_ptr
+ dst_stride
* t
->rows
* y
+ bytes
* x
;
43 for (z
= 0; z
< t
->rows
; z
++) {
44 memcpy(ptr
, src_ptr2
, bytes
);
53 pipe_linear_fill_info(struct pipe_tile_info
*t
,
54 const struct pipe_format_block
*block
,
55 unsigned tile_width
, unsigned tile_height
,
56 unsigned tiles_x
, unsigned tiles_y
)
60 t
->tile
.width
= tile_width
;
61 t
->tile
.height
= tile_height
;
62 t
->cols
= t
->tile
.width
/ t
->block
.width
;
63 t
->rows
= t
->tile
.height
/ t
->block
.height
;
64 t
->tile
.size
= t
->cols
* t
->rows
* t
->block
.size
;
68 t
->stride
= t
->cols
* t
->tiles_x
* t
->block
.size
;
69 t
->size
= t
->tiles_x
* t
->tiles_y
* t
->tile
.size
;