xref: /aosp_15_r20/external/mesa3d/src/amd/vulkan/radv_constants.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2016 Red Hat.
3  * Copyright © 2016 Bas Nieuwenhuizen
4  *
5  * based in part on anv driver which is:
6  * Copyright © 2015 Intel Corporation
7  *
8  * SPDX-License-Identifier: MIT
9  */
10 
11 #ifndef RADV_CONSTANTS_H
12 #define RADV_CONSTANTS_H
13 
14 #define ATI_VENDOR_ID 0x1002
15 
16 #define MAX_VBS                        32
17 #define MAX_VERTEX_ATTRIBS             32
18 #define MAX_RTS                        8
19 #define MAX_VIEWPORTS                  16
20 #define MAX_SCISSORS                   16
21 #define MAX_DISCARD_RECTANGLES         4
22 #define MAX_SAMPLE_LOCATIONS           32
23 #define MAX_PUSH_CONSTANTS_SIZE        256
24 #define MAX_PUSH_DESCRIPTORS           32
25 #define MAX_DYNAMIC_UNIFORM_BUFFERS    16
26 #define MAX_DYNAMIC_STORAGE_BUFFERS    8
27 #define MAX_DYNAMIC_BUFFERS            (MAX_DYNAMIC_UNIFORM_BUFFERS + MAX_DYNAMIC_STORAGE_BUFFERS)
28 #define MAX_SAMPLES_LOG2               4
29 #define NUM_META_FS_KEYS               12
30 #define RADV_MAX_DRM_DEVICES           8
31 #define MAX_VIEWS                      8
32 #define MAX_SO_STREAMS                 4
33 #define MAX_SO_BUFFERS                 4
34 #define MAX_SO_OUTPUTS                 128
35 #define MAX_INLINE_UNIFORM_BLOCK_SIZE  (4ull * 1024 * 1024)
36 #define MAX_INLINE_UNIFORM_BLOCK_COUNT 64
37 #define MAX_BIND_POINTS                3 /* compute + graphics + raytracing */
38 
39 #define NUM_DEPTH_CLEAR_PIPELINES      2
40 #define NUM_DEPTH_DECOMPRESS_PIPELINES 3
41 #define MAX_FRAMEBUFFER_WIDTH          (1u << 14)
42 #define MAX_FRAMEBUFFER_HEIGHT         (1u << 14)
43 
44 /*
45  * This is the point we switch from using CP to compute shader
46  * for certain buffer operations.
47  */
48 #define RADV_BUFFER_OPS_CS_THRESHOLD 4096
49 
50 #define RADV_BUFFER_UPDATE_THRESHOLD 1024
51 
52 /* descriptor index into scratch ring offsets */
53 #define RING_SCRATCH             0
54 #define RING_ESGS_VS             1
55 #define RING_ESGS_GS             2
56 #define RING_GSVS_VS             3
57 #define RING_GSVS_GS             4
58 #define RING_HS_TESS_FACTOR      5
59 #define RING_HS_TESS_OFFCHIP     6
60 #define RING_TS_DRAW             7
61 #define RING_TS_PAYLOAD          8
62 #define RING_MS_SCRATCH          9
63 #define RING_PS_ATTR             10
64 #define RING_PS_SAMPLE_POSITIONS 11
65 
66 #define SI_GS_PER_ES 128
67 
68 /* max number of descriptor sets */
69 #define MAX_SETS 32
70 
71 /* Make sure everything is addressable by a signed 32-bit int, and
72  * our largest descriptors are 96 bytes.
73  */
74 #define RADV_MAX_PER_SET_DESCRIPTORS ((1ull << 31) / 96)
75 
76 /* Our buffer size fields allow only 2**32 - 1. We round that down to a multiple
77  * of 4 bytes so we can align buffer sizes up.
78  */
79 #define RADV_MAX_MEMORY_ALLOCATION_SIZE 0xFFFFFFFCull
80 
81 /* Number of entries in the mesh shader scratch ring.
82  * This depends on VGT_GS_MAX_WAVE_ID which is set by the kernel
83  * and is impossible to query. We leave it on its maximum value
84  * because real applications are unlikely to use it.
85  *
86  * The maximum ID on GFX10.3 is 2047 (0x7ff), so we need 2048 entries.
87  */
88 #define RADV_MESH_SCRATCH_NUM_ENTRIES 2048
89 
90 /* Size of each entry in the mesh shader scratch ring.
91  * We must ensure that the absolute maximum mesh shader output fits here.
92  *
93  * Mesh shaders can create up to 256 vertices/primitives per workgroup,
94  * and up to the following amount of outputs:
95  * - 32 parameters
96  * - 4 positions (clip/cull distance, etc.)
97  * - 4 per-primitive built-in outputs (layer, view index, prim id, VRS rate)
98  * - primitive indices which are always kept in LDS
99  * That is a total of 32+4+4=40 output slots x 16 bytes per slot x 256 = 160K bytes.
100  */
101 #define RADV_MESH_SCRATCH_ENTRY_BYTES (160 * 1024)
102 
103 /* Number of invocations in each subgroup. */
104 #define RADV_SUBGROUP_SIZE 64
105 
106 /* The spec requires this to be 32. */
107 #define RADV_RT_HANDLE_SIZE 32
108 
109 #define RADV_MAX_HIT_ATTRIB_SIZE   32
110 #define RADV_MAX_HIT_ATTRIB_DWORDS (RADV_MAX_HIT_ATTRIB_SIZE / 4)
111 
112 #define RADV_SHADER_ALLOC_ALIGNMENT      256
113 #define RADV_SHADER_ALLOC_MIN_ARENA_SIZE (256 * 1024)
114 /* 256 KiB << 5 = 8 MiB */
115 #define RADV_SHADER_ALLOC_MAX_ARENA_SIZE_SHIFT 5u
116 #define RADV_SHADER_ALLOC_MIN_SIZE_CLASS       8
117 #define RADV_SHADER_ALLOC_MAX_SIZE_CLASS       15
118 #define RADV_SHADER_ALLOC_NUM_FREE_LISTS       (RADV_SHADER_ALLOC_MAX_SIZE_CLASS - RADV_SHADER_ALLOC_MIN_SIZE_CLASS + 1)
119 
120 #define PERF_CTR_MAX_PASSES      512
121 #define PERF_CTR_BO_PASS_OFFSET  16
122 #define PERF_CTR_BO_LOCK_OFFSET  0
123 #define PERF_CTR_BO_FENCE_OFFSET 8
124 
125 /* The maximum number of in-flight uploads (radv_shader_dma_submission) when asynchronous shader
126  * upload is used.
127  */
128 #define RADV_SHADER_UPLOAD_CS_COUNT 32
129 
130 /* Shader GDS counters:
131  *   offset  0| 4| 8|12  - reserved for NGG streamout counters
132  *   offset 16           - number of primitives generated by geometry shader invocations
133  *   offset 20           - number of geometry shader invocations
134  *   offset 24|28|32|36  - generated primitive counter for stream 0|1|2|3
135  *   offset 40|44|48|52  - written primitive counter for stream 0|1|2|3
136  *
137  * Mesh shader GDS counters:
138  *   offset 56 - number of mesh shader invocations
139  *   offset 60 - number of mesh shader generated primitives
140  *
141  * Task shader GDS counter:
142  *   offset 64 - number of task shader invocations
143  */
144 #define RADV_SHADER_QUERY_GS_PRIM_EMIT_OFFSET     16
145 #define RADV_SHADER_QUERY_GS_INVOCATION_OFFSET    20
146 #define RADV_SHADER_QUERY_PRIM_GEN_OFFSET(stream) (24 + stream * 4)
147 #define RADV_SHADER_QUERY_PRIM_XFB_OFFSET(stream) (40 + stream * 4)
148 #define RADV_SHADER_QUERY_MS_INVOCATION_OFFSET    56
149 #define RADV_SHADER_QUERY_MS_PRIM_GEN_OFFSET      60
150 #define RADV_SHADER_QUERY_TS_INVOCATION_OFFSET    64
151 
152 /* Number of samples for line smooth lowering (hw requirement). */
153 #define RADV_NUM_SMOOTH_AA_SAMPLES 4
154 
155 /* Size of the temporary buffer allocated for transfer queue copy command workarounds.
156  * The size is chosen so that it can fit two lines of (1 << 14) blocks at 16 bpp.
157  */
158 #define RADV_SDMA_TRANSFER_TEMP_BYTES (2 * (1 << 14) * 16)
159 
160 #define RADV_VERT_ATTRIB_MAX MAX2(VERT_ATTRIB_MAX, VERT_ATTRIB_GENERIC0 + MAX_VERTEX_ATTRIBS)
161 
162 #endif /* RADV_CONSTANTS_H */
163