89ad8c20811a4e944482211c672b46c653be876e
[mesa.git] / src / gallium / drivers / ilo / ilo_resource.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2012-2013 LunarG, Inc.
5 *
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:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
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.
23 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
26 */
27
28 #ifndef ILO_RESOURCE_H
29 #define ILO_RESOURCE_H
30
31 #include "intel_winsys.h"
32
33 #include "ilo_common.h"
34
35 struct ilo_screen;
36 struct ilo_context;
37 struct winsys_handle;
38
39 /*
40 * TODO we should have
41 *
42 * ilo_resource, inherited by
43 * - ilo_buffer
44 * - ilo_texture
45 * - ilo_global_binding
46 */
47 struct ilo_resource {
48 struct pipe_resource base;
49 struct winsys_handle *handle;
50
51 struct intel_bo *bo;
52
53 /*
54 * These are the values passed to or returned from winsys for bo
55 * allocation. As such,
56 *
57 * - width and height are in blocks,
58 * - cpp is the block size in bytes, and
59 * - stride is the distance in bytes between two block rows.
60 */
61 int bo_width, bo_height, bo_cpp, bo_stride;
62 enum intel_tiling_mode tiling;
63
64 bool compressed;
65 unsigned block_width;
66 unsigned block_height;
67
68 /* true if the mip level alignments are stricter */
69 bool halign_8, valign_4;
70 /* true if space is reserved between layers */
71 bool array_spacing_full;
72 /* true if samples are interleaved */
73 bool interleaved;
74
75 /* 2D offsets into a layer/slice/face */
76 struct {
77 unsigned x;
78 unsigned y;
79 } *slice_offsets[PIPE_MAX_TEXTURE_LEVELS];
80 };
81
82 static inline struct ilo_resource *
83 ilo_resource(struct pipe_resource *res)
84 {
85 return (struct ilo_resource *) res;
86 }
87
88 void
89 ilo_init_resource_functions(struct ilo_screen *is);
90
91 void
92 ilo_init_transfer_functions(struct ilo_context *ilo);
93
94 unsigned
95 ilo_resource_get_slice_offset(const struct ilo_resource *res,
96 int level, int slice, bool tile_aligned,
97 unsigned *x_offset, unsigned *y_offset);
98
99 #endif /* ILO_RESOURCE_H */