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