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