• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2016 Red Hat.
3  * Copyright © 2016 Bas Nieuwenhuizen
4  * SPDX-License-Identifier: MIT
5  *
6  * based in part on anv driver which is:
7  * Copyright © 2015 Intel Corporation
8  */
9 
10 #ifndef TU_COMMON_H
11 #define TU_COMMON_H
12 
13 #include <assert.h>
14 #include <pthread.h>
15 #include <stdbool.h>
16 #include <stdint.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <tuple>
21 #ifdef HAVE_VALGRIND
22 #include <memcheck.h>
23 #include <valgrind.h>
24 #define VG(x) x
25 #else
26 #define VG(x) ((void)0)
27 #endif
28 
29 #define MESA_LOG_TAG "TU"
30 
31 #include "c11/threads.h"
32 #include "util/rounding.h"
33 #include "util/bitscan.h"
34 #include "util/detect_os.h"
35 #include "util/list.h"
36 #include "util/log.h"
37 #include "util/macros.h"
38 #include "util/perf/cpu_trace.h"
39 #include "util/sparse_array.h"
40 #include "util/u_atomic.h"
41 #include "util/u_dynarray.h"
42 #include "util/xmlconfig.h"
43 #include "util/perf/u_trace.h"
44 #include "vk_alloc.h"
45 #include "vk_debug_report.h"
46 #include "vk_device.h"
47 #include "vk_dispatch_table.h"
48 #include "vk_extensions.h"
49 #include "vk_instance.h"
50 #include "vk_log.h"
51 #include "vk_physical_device.h"
52 #include "vk_pipeline_cache.h"
53 #include "wsi_common.h"
54 
55 #include "ir3/ir3_compiler.h"
56 #include "ir3/ir3_shader.h"
57 
58 #include "adreno_common.xml.h"
59 #include "adreno_pm4.xml.h"
60 #include "a6xx.xml.h"
61 #include "fdl/freedreno_layout.h"
62 #include "common/freedreno_dev_info.h"
63 #include "common/freedreno_common.h"
64 #include "perfcntrs/freedreno_perfcntr.h"
65 
66 #include <vulkan/vk_android_native_buffer.h>
67 #include <vulkan/vk_icd.h>
68 #include <vulkan/vulkan.h>
69 
70 #include "tu_entrypoints.h"
71 
72 #include "vk_format.h"
73 #include "vk_image.h"
74 #include "vk_command_buffer.h"
75 #include "vk_command_pool.h"
76 #include "vk_common_entrypoints.h"
77 #include "vk_queue.h"
78 #include "vk_object.h"
79 #include "vk_sync.h"
80 #include "vk_drm_syncobj.h"
81 #include "vk_sync_timeline.h"
82 
83 #define MAX_VBS 32
84 #define MAX_VERTEX_ATTRIBS 32
85 #define MAX_RTS 8
86 #define MAX_VSC_PIPES 32
87 #define MAX_VIEWPORTS 16
88 #define MAX_VIEWPORT_SIZE (1 << 14)
89 #define MAX_SCISSORS 16
90 #define MAX_DISCARD_RECTANGLES 4
91 #define MAX_PUSH_CONSTANTS_SIZE 256
92 #define MAX_PUSH_DESCRIPTORS 32
93 #define MAX_DYNAMIC_UNIFORM_BUFFERS 16
94 #define MAX_DYNAMIC_STORAGE_BUFFERS 8
95 #define MAX_DYNAMIC_BUFFERS_SIZE                                             \
96    (MAX_DYNAMIC_UNIFORM_BUFFERS + 2 * MAX_DYNAMIC_STORAGE_BUFFERS) *         \
97    A6XX_TEX_CONST_DWORDS
98 
99 /* With dynamic rendering, input attachment indices are shifted by 1 and
100  * attachment 0 is used for input attachments without an InputAttachmentIndex
101  * (which can only be depth/stencil).
102  */
103 #define TU_DYN_INPUT_ATT_OFFSET 1
104 
105 #define SAMPLE_LOCATION_MIN 0.f
106 #define SAMPLE_LOCATION_MAX 0.9375f
107 
108 #define TU_MAX_DRM_DEVICES 8
109 #define MAX_VIEWS 16
110 #define MAX_BIND_POINTS 2 /* compute + graphics */
111 /* match the latest Qualcomm driver which is also a hw limit on later gens */
112 #define MAX_STORAGE_BUFFER_RANGE (1u << 27)
113 /* We use ldc for uniform buffer loads, just like the Qualcomm driver, so
114  * expose the same maximum range.
115  * TODO: The SIZE bitfield is 15 bits, and in 4-dword units, so the actual
116  * range might be higher.
117  */
118 #define MAX_UNIFORM_BUFFER_RANGE 0x10000
119 
120 /* Use the minimum maximum to guarantee that it can always fit in the safe
121  * const file size, even with maximum push constant usage and driver params.
122  */
123 #define MAX_INLINE_UBO_RANGE 256
124 #define MAX_INLINE_UBOS 4
125 
126 #define A6XX_TEX_CONST_DWORDS 16
127 #define A6XX_TEX_SAMP_DWORDS 4
128 
129 /* We sample the fragment density map on the CPU, so technically the
130  * minimum/maximum texel size is arbitrary. However sizes smaller than the
131  * minimum tile width alignment of 32 are likely pointless, so we use that as
132  * the minimum value. For the maximum just pick a value larger than anyone
133  * would reasonably need.
134  */
135 #define MIN_FDM_TEXEL_SIZE_LOG2 5
136 #define MIN_FDM_TEXEL_SIZE (1u << MIN_FDM_TEXEL_SIZE_LOG2)
137 #define MAX_FDM_TEXEL_SIZE_LOG2 10
138 #define MAX_FDM_TEXEL_SIZE (1u << MAX_FDM_TEXEL_SIZE_LOG2)
139 
140 #define TU_GENX(FUNC_NAME) FD_GENX(FUNC_NAME)
141 
142 #define TU_CALLX(device, thing) FD_CALLX((device)->physical_device->info, thing)
143 
144 /* vk object types */
145 struct tu_buffer;
146 struct tu_buffer_view;
147 struct tu_cmd_buffer;
148 struct tu_cmd_pool;
149 struct tu_descriptor_pool;
150 struct tu_descriptor_set;
151 struct tu_descriptor_set_layout;
152 struct tu_descriptor_update_template;
153 struct tu_device;
154 struct tu_device_memory;
155 struct tu_event;
156 struct tu_framebuffer;
157 struct tu_image;
158 struct tu_image_view;
159 struct tu_instance;
160 struct tu_physical_device;
161 struct tu_pipeline_layout;
162 struct tu_query_pool;
163 struct tu_queue;
164 struct tu_render_pass;
165 struct tu_sampler;
166 
167 struct breadcrumbs_context;
168 struct tu_bo;
169 struct tu_cs;
170 struct tu_cs_entry;
171 struct tu_suballoc_bo;
172 struct tu_suballocator;
173 struct tu_subpass;
174 struct tu_u_trace_submission_data;
175 
176 #endif /* TU_COMMON_H */
177