1 /*
2 * Copyright (C) 2019 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 <[email protected]>
25 */
26
27 #ifndef PAN_PROPS_H
28 #define PAN_PROPS_H
29
30 #include <stdbool.h>
31 #include <stdint.h>
32
33 struct pan_kmod_dev;
34 struct pan_kmod_dev_props;
35
36 /** Implementation-defined tiler features */
37 struct panfrost_tiler_features {
38 /** Number of bytes per tiler bin */
39 unsigned bin_size;
40
41 /** Maximum number of levels that may be simultaneously enabled.
42 * Invariant: bitcount(hierarchy_mask) <= max_levels */
43 unsigned max_levels;
44 };
45
46 struct panfrost_model {
47 /* GPU ID */
48 uint32_t gpu_id;
49
50 /* GPU variant. */
51 uint32_t gpu_variant;
52
53 /* Marketing name for the GPU, used as the GL_RENDERER */
54 const char *name;
55
56 /* Set of associated performance counters */
57 const char *performance_counters;
58
59 /* Minimum GPU revision required for anisotropic filtering. ~0 and 0
60 * means "no revisions support anisotropy" and "all revisions support
61 * anistropy" respectively -- so checking for anisotropy is simply
62 * comparing the reivsion.
63 */
64 uint32_t min_rev_anisotropic;
65
66 /* Default tilebuffer size in bytes for the model. */
67 unsigned tilebuffer_size;
68
69 struct {
70 /* The GPU lacks the capability for hierarchical tiling, without
71 * an "Advanced Tiling Unit", instead requiring a single bin
72 * size for the entire framebuffer be selected by the driver
73 */
74 bool no_hierarchical_tiling;
75 } quirks;
76 };
77
78 const struct panfrost_model *panfrost_get_model(uint32_t gpu_id,
79 uint32_t gpu_variant);
80
81 unsigned panfrost_query_l2_slices(const struct pan_kmod_dev_props *props);
82
83 struct panfrost_tiler_features
84 panfrost_query_tiler_features(const struct pan_kmod_dev_props *props);
85
86 unsigned
87 panfrost_query_thread_tls_alloc(const struct pan_kmod_dev_props *props);
88
89 uint32_t
90 panfrost_query_compressed_formats(const struct pan_kmod_dev_props *props);
91
92 unsigned panfrost_query_core_count(const struct pan_kmod_dev_props *props,
93 unsigned *core_id_range);
94
95 bool panfrost_query_afbc(const struct pan_kmod_dev_props *props);
96
97 bool panfrost_query_afrc(const struct pan_kmod_dev_props *props);
98
99 unsigned panfrost_query_optimal_tib_size(const struct panfrost_model *model);
100
101 uint64_t panfrost_clamp_to_usable_va_range(const struct pan_kmod_dev *dev,
102 uint64_t va);
103
104 unsigned
105 panfrost_compute_max_thread_count(const struct pan_kmod_dev_props *props,
106 unsigned work_reg_count);
107
108 /* Returns the architecture version given a GPU ID, either from a table for
109 * old-style Midgard versions or directly for new-style Bifrost/Valhall
110 * versions */
111
112 static inline unsigned
pan_arch(unsigned gpu_id)113 pan_arch(unsigned gpu_id)
114 {
115 switch (gpu_id) {
116 case 0x600:
117 case 0x620:
118 case 0x720:
119 return 4;
120 case 0x750:
121 case 0x820:
122 case 0x830:
123 case 0x860:
124 case 0x880:
125 return 5;
126 default:
127 return gpu_id >> 12;
128 }
129 }
130
131 #endif
132