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_compiler.h"
37 #include "pipe/p_format.h"
39 struct u_linear_format_block
41 /** Block size in bytes */
44 /** Block width in pixels */
47 /** Block height in pixels */
57 /* The number of tiles */
61 /* size of each tile expressed in blocks */
65 /* Describe the tile in pixels */
66 struct u_linear_format_block tile
;
68 /* Describe each block within the tile */
69 struct u_linear_format_block block
;
72 void pipe_linear_to_tile(size_t src_stride
, const void *src_ptr
,
73 struct pipe_tile_info
*t
, void *dst_ptr
);
75 void pipe_linear_from_tile(struct pipe_tile_info
*t
, const void *src_ptr
,
76 size_t dst_stride
, void *dst_ptr
);
79 * Convenience function to fillout a pipe_tile_info struct.
80 * @t info to fill out.
81 * @block block info about pixel layout
82 * @tile_width the width of the tile in pixels
83 * @tile_height the height of the tile in pixels
84 * @tiles_x number of tiles in x axis
85 * @tiles_y number of tiles in y axis
87 void pipe_linear_fill_info(struct pipe_tile_info
*t
,
88 const struct u_linear_format_block
*block
,
89 unsigned tile_width
, unsigned tile_height
,
90 unsigned tiles_x
, unsigned tiles_y
);
92 static INLINE boolean
pipe_linear_check_tile(const struct pipe_tile_info
*t
)
94 if (t
->tile
.size
!= t
->block
.size
* t
->cols
* t
->rows
)
97 if (t
->stride
!= t
->block
.size
* t
->cols
* t
->tiles_x
)
100 if (t
->size
< t
->stride
* t
->rows
* t
->tiles_y
)
106 #endif /* U_LINEAR_H */