panfrost/midgard: Enable lower_find_lsb
[mesa.git] / src / gallium / drivers / panfrost / pan_resource.h
1 /*
2 * © Copyright2018-2019 Alyssa Rosenzweig
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 */
24
25
26 #ifndef PAN_RESOURCE_H
27 #define PAN_RESOURCE_H
28
29 #include <panfrost-job.h>
30 #include "pan_screen.h"
31 #include "pan_allocate.h"
32 #include "drm-uapi/drm.h"
33
34 /* Describes the memory layout of a BO */
35
36 enum panfrost_memory_layout {
37 PAN_LINEAR,
38 PAN_TILED,
39 PAN_AFBC
40 };
41
42 struct panfrost_slice {
43 unsigned offset;
44 unsigned stride;
45 };
46
47 struct panfrost_bo {
48 struct panfrost_slice slices[MAX_MIP_LEVELS];
49
50 /* Mapping for the entire object (all levels) */
51 uint8_t *cpu;
52
53 /* GPU address for the object */
54 mali_ptr gpu;
55
56 /* Size of all entire trees */
57 size_t size;
58
59 /* Distance from tree to tree */
60 unsigned cubemap_stride;
61
62 /* Set if this bo was imported rather than allocated */
63 bool imported;
64
65 /* Internal layout (tiled?) */
66 enum panfrost_memory_layout layout;
67
68 /* If AFBC is enabled for this resource, we lug around an AFBC
69 * metadata buffer as well. The actual AFBC resource is also in
70 * afbc_slab (only defined for AFBC) at position afbc_main_offset
71 */
72
73 struct panfrost_memory afbc_slab;
74 int afbc_metadata_size;
75
76 /* If transaciton elimination is enabled, we have a dedicated
77 * buffer for that as well. */
78
79 bool has_checksum;
80 struct panfrost_memory checksum_slab;
81 int checksum_stride;
82
83 int gem_handle;
84 };
85
86 struct panfrost_resource {
87 struct pipe_resource base;
88
89 struct panfrost_bo *bo;
90 struct renderonly_scanout *scanout;
91
92 struct panfrost_resource *separate_stencil;
93 };
94
95 static inline struct panfrost_resource *
96 pan_resource(struct pipe_resource *p)
97 {
98 return (struct panfrost_resource *)p;
99 }
100
101 struct panfrost_gtransfer {
102 struct pipe_transfer base;
103 void *map;
104 };
105
106 static inline struct panfrost_gtransfer *
107 pan_transfer(struct pipe_transfer *p)
108 {
109 return (struct panfrost_gtransfer *)p;
110 }
111
112 void panfrost_resource_screen_init(struct panfrost_screen *screen);
113
114 void panfrost_resource_context_init(struct pipe_context *pctx);
115
116 #endif /* PAN_RESOURCE_H */