2 * Mesa 3-D graphics library
4 * Copyright (C) 2012-2013 LunarG, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Chia-I Wu <olv@lunarg.com>
28 #ifndef ILO_RESOURCE_H
29 #define ILO_RESOURCE_H
31 #include "intel_winsys.h"
33 #include "ilo_common.h"
38 struct pipe_resource base
;
46 struct pipe_resource base
;
51 enum pipe_format bo_format
;
55 * These are the values passed to or returned from winsys for bo
56 * allocation. As such,
58 * - width and height are in blocks,
59 * - cpp is the block size in bytes, and
60 * - stride is the distance in bytes between two block rows.
62 int bo_width
, bo_height
, bo_cpp
, bo_stride
;
63 enum intel_tiling_mode tiling
;
67 unsigned block_height
;
69 /* true if the mip level alignments are stricter */
70 bool halign_8
, valign_4
;
71 /* true if space is reserved between layers */
72 bool array_spacing_full
;
73 /* true if samples are interleaved */
76 /* 2D offsets into a layer/slice/face */
77 struct ilo_texture_slice
{
80 } *slice_offsets
[PIPE_MAX_TEXTURE_LEVELS
];
82 struct ilo_texture
*separate_s8
;
85 static inline struct ilo_buffer
*
86 ilo_buffer(struct pipe_resource
*res
)
88 return (struct ilo_buffer
*)
89 ((res
&& res
->target
== PIPE_BUFFER
) ? res
: NULL
);
92 static inline struct ilo_texture
*
93 ilo_texture(struct pipe_resource
*res
)
95 return (struct ilo_texture
*)
96 ((res
&& res
->target
!= PIPE_BUFFER
) ? res
: NULL
);
100 ilo_init_resource_functions(struct ilo_screen
*is
);
103 ilo_buffer_alloc_bo(struct ilo_buffer
*buf
);
106 ilo_texture_alloc_bo(struct ilo_texture
*tex
);
109 ilo_texture_get_slice_offset(const struct ilo_texture
*tex
,
110 int level
, int slice
,
111 unsigned *x_offset
, unsigned *y_offset
);
113 #endif /* ILO_RESOURCE_H */