• 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_DESC_H
29 #define __PAN_DESC_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    /* Sum of vertex counts (for non-indexed draws), index counts (for
73     * indexed draws on Valhall as a best effort), or ~0 if any indirect
74     * draws are used. Helps tune hierarchy masks.
75     */
76    uint32_t vertex_count;
77 
78    union {
79       mali_ptr bifrost;
80       struct {
81          bool disable;
82          bool no_hierarchical_tiling;
83          mali_ptr polygon_list;
84          struct {
85             mali_ptr start;
86             unsigned size;
87          } heap;
88       } midgard;
89    };
90 };
91 
92 struct pan_tls_info {
93    struct {
94       mali_ptr ptr;
95       unsigned size;
96    } tls;
97 
98    struct {
99       unsigned instances;
100       mali_ptr ptr;
101       unsigned size;
102    } wls;
103 };
104 
105 struct pan_fb_bifrost_info {
106    struct {
107       struct panfrost_ptr dcds;
108       unsigned modes[3];
109    } pre_post;
110 };
111 
112 struct pan_fb_info {
113    unsigned width, height;
114    struct {
115       /* Max values are inclusive */
116       unsigned minx, miny, maxx, maxy;
117    } extent;
118    unsigned nr_samples;
119    unsigned force_samples; /* samples used for rasterization */
120    unsigned rt_count;
121    struct pan_fb_color_attachment rts[8];
122    struct pan_fb_zs_attachment zs;
123 
124    struct {
125       unsigned stride;
126       mali_ptr base;
127    } tile_map;
128 
129    union {
130       struct pan_fb_bifrost_info bifrost;
131    };
132 
133    /* Optimal tile buffer size. */
134    unsigned tile_buf_budget;
135 
136    /* Sample position array. */
137    mali_ptr sample_positions;
138 
139    /* Only used on Valhall */
140    bool sprite_coord_origin;
141    bool first_provoking_vertex;
142 };
143 
144 static inline unsigned
pan_wls_instances(const struct pan_compute_dim * dim)145 pan_wls_instances(const struct pan_compute_dim *dim)
146 {
147    return util_next_power_of_two(dim->x) * util_next_power_of_two(dim->y) *
148           util_next_power_of_two(dim->z);
149 }
150 
151 static inline unsigned
pan_wls_adjust_size(unsigned wls_size)152 pan_wls_adjust_size(unsigned wls_size)
153 {
154    return util_next_power_of_two(MAX2(wls_size, 128));
155 }
156 
157 #ifdef PAN_ARCH
158 
159 #if PAN_ARCH >= 5
160 static inline enum mali_sample_pattern
pan_sample_pattern(unsigned samples)161 pan_sample_pattern(unsigned samples)
162 {
163    switch (samples) {
164    case 1:
165       return MALI_SAMPLE_PATTERN_SINGLE_SAMPLED;
166    case 4:
167       return MALI_SAMPLE_PATTERN_ROTATED_4X_GRID;
168    case 8:
169       return MALI_SAMPLE_PATTERN_D3D_8X_GRID;
170    case 16:
171       return MALI_SAMPLE_PATTERN_D3D_16X_GRID;
172    default:
173       unreachable("Unsupported sample count");
174    }
175 }
176 #endif
177 
178 void GENX(pan_emit_tls)(const struct pan_tls_info *info, void *out);
179 
180 int GENX(pan_select_crc_rt)(const struct pan_fb_info *fb, unsigned tile_size);
181 
182 unsigned GENX(pan_emit_fbd)(const struct pan_fb_info *fb,
183                             const struct pan_tls_info *tls,
184                             const struct pan_tiler_context *tiler_ctx,
185                             void *out);
186 
187 #if PAN_ARCH <= 9
188 void GENX(pan_emit_fragment_job)(const struct pan_fb_info *fb, mali_ptr fbd,
189                                  void *out);
190 #endif
191 
192 #endif /* ifdef PAN_ARCH */
193 
194 #endif
195