2 * Copyright © 2011 Red Hat All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
14 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
16 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 * The above copyright notice and this permission notice (including the
22 * next paragraph) shall be included in all copies or substantial portions
27 * Jérôme Glisse <jglisse@redhat.com>
29 #ifndef RADEON_SURFACE_H
30 #define RADEON_SURFACE_H
34 * For texture array, the n layer are stored one after the other within each
35 * mipmap level. 0 value for field than can be hint is always valid.
38 #define RADEON_SURF_MAX_LEVEL 32
40 #define RADEON_SURF_TYPE_MASK 0xFF
41 #define RADEON_SURF_TYPE_SHIFT 0
42 #define RADEON_SURF_TYPE_1D 0
43 #define RADEON_SURF_TYPE_2D 1
44 #define RADEON_SURF_TYPE_3D 2
45 #define RADEON_SURF_TYPE_CUBEMAP 3
46 #define RADEON_SURF_TYPE_1D_ARRAY 4
47 #define RADEON_SURF_TYPE_2D_ARRAY 5
48 #define RADEON_SURF_MODE_MASK 0xFF
49 #define RADEON_SURF_MODE_SHIFT 8
50 #define RADEON_SURF_MODE_LINEAR 0
51 #define RADEON_SURF_MODE_LINEAR_ALIGNED 1
52 #define RADEON_SURF_MODE_1D 2
53 #define RADEON_SURF_MODE_2D 3
54 #define RADEON_SURF_SCANOUT (1 << 16)
55 #define RADEON_SURF_ZBUFFER (1 << 17)
56 #define RADEON_SURF_SBUFFER (1 << 18)
57 #define RADEON_SURF_HAS_SBUFFER_MIPTREE (1 << 19)
59 #define RADEON_SURF_GET(v, field) (((v) >> RADEON_SURF_ ## field ## _SHIFT) & RADEON_SURF_ ## field ## _MASK)
60 #define RADEON_SURF_SET(v, field) (((v) & RADEON_SURF_ ## field ## _MASK) << RADEON_SURF_ ## field ## _SHIFT)
61 #define RADEON_SURF_CLR(v, field) ((v) & ~(RADEON_SURF_ ## field ## _MASK << RADEON_SURF_ ## field ## _SHIFT))
63 /* first field up to mode need to match r6 struct so that we can reuse
64 * same function for linear & linear aligned
66 struct radeon_surface_level {
79 struct radeon_surface {
91 /* Following is updated/fill by the allocator. It's allowed to
92 * set some of the value but they are use as hint and can be
93 * overridden (things lile bankw/bankh on evergreen for
97 uint64_t bo_alignment;
103 uint32_t stencil_tile_split;
104 uint64_t stencil_offset;
105 struct radeon_surface_level level[RADEON_SURF_MAX_LEVEL];
106 struct radeon_surface_level stencil_level[RADEON_SURF_MAX_LEVEL];
109 struct radeon_surface_manager *radeon_surface_manager_new(int fd);
110 void radeon_surface_manager_free(struct radeon_surface_manager *surf_man);
111 int radeon_surface_init(struct radeon_surface_manager *surf_man,
112 struct radeon_surface *surf);
113 int radeon_surface_best(struct radeon_surface_manager *surf_man,
114 struct radeon_surface *surf);