• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Collabora, Ltd.
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  * Authors:
24  *   Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
25  *   Boris Brezillon <boris.brezillon@collabora.com>
26  */
27 
28 #ifndef __PAN_CS_H
29 #define __PAN_CS_H
30 
31 #include "genxml/gen_macros.h"
32 
33 #include "pan_texture.h"
34 
35 struct pan_compute_dim {
36         uint32_t x, y, z;
37 };
38 
39 struct pan_fb_color_attachment {
40         const struct pan_image_view *view;
41         bool *crc_valid;
42         bool clear;
43         bool preload;
44         bool discard;
45         uint32_t clear_value[4];
46 };
47 
48 struct pan_fb_zs_attachment {
49         struct {
50                 const struct pan_image_view *zs, *s;
51         } view;
52 
53         struct {
54                 bool z, s;
55         } clear;
56 
57         struct {
58                 bool z, s;
59         } discard;
60 
61         struct {
62                 bool z, s;
63         } preload;
64 
65         struct {
66                 float depth;
67                 uint8_t stencil;
68         } clear_value;
69 };
70 
71 struct pan_tiler_context {
72         union {
73                 mali_ptr bifrost;
74                 struct {
75                         bool disable;
76                         struct panfrost_bo *polygon_list;
77                 } midgard;
78         };
79 };
80 
81 struct pan_tls_info {
82         struct {
83                 mali_ptr ptr;
84                 unsigned size;
85         } tls;
86 
87         struct {
88                 struct pan_compute_dim dim;
89                 mali_ptr ptr;
90                 unsigned size;
91         } wls;
92 };
93 
94 struct pan_fb_bifrost_info {
95         struct {
96                 struct panfrost_ptr dcds;
97                 unsigned modes[3];
98         } pre_post;
99 };
100 
101 struct pan_fb_info {
102         unsigned width, height;
103         struct {
104                 /* Max values are inclusive */
105                 unsigned minx, miny, maxx, maxy;
106         } extent;
107         unsigned nr_samples;
108         unsigned rt_count;
109         struct pan_fb_color_attachment rts[8];
110         struct pan_fb_zs_attachment zs;
111 
112         struct {
113                 unsigned stride;
114                 mali_ptr base;
115         } tile_map;
116 
117         union {
118                 struct pan_fb_bifrost_info bifrost;
119         };
120 
121         /* Only used on Valhall */
122         bool sprite_coord_origin;
123         bool first_provoking_vertex;
124 };
125 
126 static inline unsigned
pan_wls_instances(const struct pan_compute_dim * dim)127 pan_wls_instances(const struct pan_compute_dim *dim)
128 {
129         return util_next_power_of_two(dim->x) *
130                util_next_power_of_two(dim->y) *
131                util_next_power_of_two(dim->z);
132 }
133 
134 static inline unsigned
pan_wls_adjust_size(unsigned wls_size)135 pan_wls_adjust_size(unsigned wls_size)
136 {
137         return util_next_power_of_two(MAX2(wls_size, 128));
138 }
139 
140 static inline unsigned
pan_wls_mem_size(const struct panfrost_device * dev,const struct pan_compute_dim * dim,unsigned wls_size)141 pan_wls_mem_size(const struct panfrost_device *dev,
142                  const struct pan_compute_dim *dim,
143                  unsigned wls_size)
144 {
145         unsigned instances = pan_wls_instances(dim);
146 
147         return pan_wls_adjust_size(wls_size) * instances * dev->core_id_range;
148 }
149 
150 #ifdef PAN_ARCH
151 void
152 GENX(pan_emit_tls)(const struct pan_tls_info *info,
153                    void *out);
154 
155 int
156 GENX(pan_select_crc_rt)(const struct pan_fb_info *fb, unsigned tile_size);
157 
158 unsigned
159 GENX(pan_emit_fbd)(const struct panfrost_device *dev,
160                    const struct pan_fb_info *fb,
161                    const struct pan_tls_info *tls,
162                    const struct pan_tiler_context *tiler_ctx,
163                    void *out);
164 
165 #if PAN_ARCH >= 6
166 void
167 GENX(pan_emit_tiler_heap)(const struct panfrost_device *dev,
168                           void *out);
169 
170 void
171 GENX(pan_emit_tiler_ctx)(const struct panfrost_device *dev,
172                          unsigned fb_width, unsigned fb_height,
173                          unsigned nr_samples, bool first_provoking_vertex,
174                          mali_ptr heap,
175                          void *out);
176 #endif
177 
178 void
179 GENX(pan_emit_fragment_job)(const struct pan_fb_info *fb,
180                             mali_ptr fbd,
181                             void *out);
182 #endif /* ifdef PAN_ARCH */
183 
184 #endif
185