2af06208f2c697225151ca0002e70dea9ecac5f9
[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 "pan_texture.h"
33 #include "drm-uapi/drm.h"
34 #include "util/u_range.h"
35
36 struct panfrost_resource {
37 struct pipe_resource base;
38 struct {
39 struct pipe_box biggest_rect;
40 struct pipe_scissor_state extent;
41 } damage;
42
43 struct panfrost_bo *bo;
44 struct renderonly_scanout *scanout;
45
46 struct panfrost_resource *separate_stencil;
47
48 struct util_range valid_buffer_range;
49
50 /* Description of the mip levels */
51 struct panfrost_slice slices[MAX_MIP_LEVELS];
52
53 /* Distance from tree to tree */
54 unsigned cubemap_stride;
55
56 /* Internal layout (tiled?) */
57 enum mali_texture_layout layout;
58
59 /* Is transaciton elimination enabled? */
60 bool checksummed;
61
62 enum pipe_format internal_format;
63 };
64
65 static inline struct panfrost_resource *
66 pan_resource(struct pipe_resource *p)
67 {
68 return (struct panfrost_resource *)p;
69 }
70
71 struct panfrost_gtransfer {
72 struct pipe_transfer base;
73 void *map;
74 };
75
76 static inline struct panfrost_gtransfer *
77 pan_transfer(struct pipe_transfer *p)
78 {
79 return (struct panfrost_gtransfer *)p;
80 }
81
82 mali_ptr
83 panfrost_get_texture_address(
84 struct panfrost_resource *rsrc,
85 unsigned level, unsigned face);
86
87 void panfrost_resource_screen_init(struct panfrost_screen *screen);
88
89 void panfrost_resource_context_init(struct pipe_context *pctx);
90
91 void
92 panfrost_resource_hint_layout(
93 struct panfrost_screen *screen,
94 struct panfrost_resource *rsrc,
95 enum mali_texture_layout layout,
96 signed weight);
97
98 /* AFBC */
99
100 bool
101 panfrost_format_supports_afbc(enum pipe_format format);
102
103 unsigned
104 panfrost_afbc_header_size(unsigned width, unsigned height);
105
106 /* Blitting */
107
108 void
109 panfrost_blit(struct pipe_context *pipe,
110 const struct pipe_blit_info *info);
111
112 void
113 panfrost_blit_wallpaper(struct panfrost_context *ctx,
114 struct pipe_box *box);
115
116 void
117 panfrost_resource_reset_damage(struct panfrost_resource *pres);
118
119 void
120 panfrost_resource_set_damage_region(struct pipe_screen *screen,
121 struct pipe_resource *res,
122 unsigned int nrects,
123 const struct pipe_box *rects);
124
125 #endif /* PAN_RESOURCE_H */