1 /**************************************************************************
3 * Copyright 2009 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 * Functions for converting tiled data to linear and vice versa.
36 #include "pipe/p_format.h"
38 struct u_linear_format_block
40 /** Block size in bytes */
43 /** Block width in pixels */
46 /** Block height in pixels */
56 /* The number of tiles */
60 /* size of each tile expressed in blocks */
64 /* Describe the tile in pixels */
65 struct u_linear_format_block tile
;
67 /* Describe each block within the tile */
68 struct u_linear_format_block block
;
71 void pipe_linear_to_tile(size_t src_stride
, const void *src_ptr
,
72 struct pipe_tile_info
*t
, void *dst_ptr
);
74 void pipe_linear_from_tile(struct pipe_tile_info
*t
, const void *src_ptr
,
75 size_t dst_stride
, void *dst_ptr
);
78 * Convenience function to fillout a pipe_tile_info struct.
79 * @t info to fill out.
80 * @block block info about pixel layout
81 * @tile_width the width of the tile in pixels
82 * @tile_height the height of the tile in pixels
83 * @tiles_x number of tiles in x axis
84 * @tiles_y number of tiles in y axis
86 void pipe_linear_fill_info(struct pipe_tile_info
*t
,
87 const struct u_linear_format_block
*block
,
88 unsigned tile_width
, unsigned tile_height
,
89 unsigned tiles_x
, unsigned tiles_y
);
91 static INLINE boolean
pipe_linear_check_tile(const struct pipe_tile_info
*t
)
93 if (t
->tile
.size
!= t
->block
.size
* t
->cols
* t
->rows
)
96 if (t
->stride
!= t
->block
.size
* t
->cols
* t
->tiles_x
)
99 if (t
->size
< t
->stride
* t
->rows
* t
->tiles_y
)
105 #endif /* U_LINEAR_H */