Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / src / gallium / auxiliary / util / u_linear.h
1
2 #ifndef U_LINEAR_H
3 #define U_LINEAR_H
4
5 #include "pipe/p_format.h"
6 struct pipe_tile_info
7 {
8 unsigned size;
9 unsigned stride;
10
11 /* The number of tiles */
12 unsigned tiles_x;
13 unsigned tiles_y;
14
15 /* size of each tile expressed in blocks */
16 unsigned cols;
17 unsigned rows;
18
19 /* Describe the tile in pixels */
20 struct pipe_format_block tile;
21
22 /* Describe each block within the tile */
23 struct pipe_format_block block;
24 };
25
26 void pipe_linear_to_tile(size_t src_stride, void *src_ptr,
27 struct pipe_tile_info *t, void *dst_ptr);
28
29 void pipe_linear_from_tile(struct pipe_tile_info *t, void *src_ptr,
30 size_t dst_stride, void *dst_ptr);
31
32 /**
33 * Convenience function to fillout a pipe_tile_info struct.
34 * @t info to fill out.
35 * @block block info about pixel layout
36 * @tile_width the width of the tile in pixels
37 * @tile_height the height of the tile in pixels
38 * @tiles_x number of tiles in x axis
39 * @tiles_y number of tiles in y axis
40 */
41 void pipe_linear_fill_info(struct pipe_tile_info *t,
42 struct pipe_format_block *block,
43 unsigned tile_width, unsigned tile_height,
44 unsigned tiles_x, unsigned tiles_y);
45
46 static INLINE boolean pipe_linear_check_tile(struct pipe_tile_info *t)
47 {
48 if (t->tile.size != t->block.size * t->cols * t->rows)
49 return FALSE;
50
51 if (t->stride != t->block.size * t->cols * t->tiles_x)
52 return FALSE;
53
54 if (t->size < t->stride * t->rows * t->tiles_y)
55 return FALSE;
56
57 return TRUE;
58 }
59
60 #endif /* U_LINEAR_H */