panfrost: Store internal format
[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 #include "util/u_range.h"
34
35 /* Describes the memory layout of a BO */
36
37 enum panfrost_memory_layout {
38 PAN_LINEAR,
39 PAN_TILED,
40 PAN_AFBC
41 };
42
43 struct panfrost_slice {
44 unsigned offset;
45 unsigned stride;
46 unsigned size0;
47
48 /* If there is a header preceding each slice, how big is
49 * that header? Used for AFBC */
50 unsigned header_size;
51
52 /* If checksumming is enabled following the slice, what
53 * is its offset/stride? */
54 unsigned checksum_offset;
55 unsigned checksum_stride;
56
57 /* Has anything been written to this slice? */
58 bool initialized;
59 };
60
61 struct panfrost_resource {
62 struct pipe_resource base;
63 struct {
64 struct pipe_box biggest_rect;
65 struct pipe_scissor_state extent;
66 } damage;
67
68 struct panfrost_bo *bo;
69 struct renderonly_scanout *scanout;
70
71 struct panfrost_resource *separate_stencil;
72
73 struct util_range valid_buffer_range;
74
75 /* Description of the mip levels */
76 struct panfrost_slice slices[MAX_MIP_LEVELS];
77
78 /* Distance from tree to tree */
79 unsigned cubemap_stride;
80
81 /* Internal layout (tiled?) */
82 enum panfrost_memory_layout layout;
83
84 /* Is transaciton elimination enabled? */
85 bool checksummed;
86
87 enum pipe_format internal_format;
88 };
89
90 static inline struct panfrost_resource *
91 pan_resource(struct pipe_resource *p)
92 {
93 return (struct panfrost_resource *)p;
94 }
95
96 struct panfrost_gtransfer {
97 struct pipe_transfer base;
98 void *map;
99 };
100
101 static inline struct panfrost_gtransfer *
102 pan_transfer(struct pipe_transfer *p)
103 {
104 return (struct panfrost_gtransfer *)p;
105 }
106
107 mali_ptr
108 panfrost_get_texture_address(
109 struct panfrost_resource *rsrc,
110 unsigned level, unsigned face);
111
112 void panfrost_resource_screen_init(struct panfrost_screen *screen);
113
114 void panfrost_resource_context_init(struct pipe_context *pctx);
115
116 void
117 panfrost_resource_hint_layout(
118 struct panfrost_screen *screen,
119 struct panfrost_resource *rsrc,
120 enum panfrost_memory_layout layout,
121 signed weight);
122
123 /* AFBC */
124
125 bool
126 panfrost_format_supports_afbc(enum pipe_format format);
127
128 unsigned
129 panfrost_afbc_header_size(unsigned width, unsigned height);
130
131 /* Blitting */
132
133 void
134 panfrost_blit(struct pipe_context *pipe,
135 const struct pipe_blit_info *info);
136
137 void
138 panfrost_blit_wallpaper(struct panfrost_context *ctx,
139 struct pipe_box *box);
140
141 void
142 panfrost_resource_reset_damage(struct panfrost_resource *pres);
143
144 void
145 panfrost_resource_set_damage_region(struct pipe_screen *screen,
146 struct pipe_resource *res,
147 unsigned int nrects,
148 const struct pipe_box *rects);
149
150 #endif /* PAN_RESOURCE_H */