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 #define SAMPLE_LOCATION_MIN 0.f 100 #define SAMPLE_LOCATION_MAX 0.9375f 101 102 #define TU_MAX_DRM_DEVICES 8 103 #define MAX_VIEWS 16 104 #define MAX_BIND_POINTS 2 /* compute + graphics */ 105 /* match the latest Qualcomm driver which is also a hw limit on later gens */ 106 #define MAX_STORAGE_BUFFER_RANGE (1u << 27) 107 /* We use ldc for uniform buffer loads, just like the Qualcomm driver, so 108 * expose the same maximum range. 109 * TODO: The SIZE bitfield is 15 bits, and in 4-dword units, so the actual 110 * range might be higher. 111 */ 112 #define MAX_UNIFORM_BUFFER_RANGE 0x10000 113 114 /* Use the minimum maximum to guarantee that it can always fit in the safe 115 * const file size, even with maximum push constant usage and driver params. 116 */ 117 #define MAX_INLINE_UBO_RANGE 256 118 #define MAX_INLINE_UBOS 4 119 120 #define A6XX_TEX_CONST_DWORDS 16 121 #define A6XX_TEX_SAMP_DWORDS 4 122 123 /* We sample the fragment density map on the CPU, so technically the 124 * minimum/maximum texel size is arbitrary. However sizes smaller than the 125 * minimum tile width alignment of 32 are likely pointless, so we use that as 126 * the minimum value. For the maximum just pick a value larger than anyone 127 * would reasonably need. 128 */ 129 #define MIN_FDM_TEXEL_SIZE_LOG2 5 130 #define MIN_FDM_TEXEL_SIZE (1u << MIN_FDM_TEXEL_SIZE_LOG2) 131 #define MAX_FDM_TEXEL_SIZE_LOG2 10 132 #define MAX_FDM_TEXEL_SIZE (1u << MAX_FDM_TEXEL_SIZE_LOG2) 133 134 #define TU_GENX(FUNC_NAME) FD_GENX(FUNC_NAME) 135 136 #define TU_CALLX(device, thing) FD_CALLX((device)->physical_device->info, thing) 137 138 /* vk object types */ 139 struct tu_buffer; 140 struct tu_buffer_view; 141 struct tu_cmd_buffer; 142 struct tu_cmd_pool; 143 struct tu_descriptor_pool; 144 struct tu_descriptor_set; 145 struct tu_descriptor_set_layout; 146 struct tu_descriptor_update_template; 147 struct tu_device; 148 struct tu_device_memory; 149 struct tu_event; 150 struct tu_framebuffer; 151 struct tu_image; 152 struct tu_image_view; 153 struct tu_instance; 154 struct tu_physical_device; 155 struct tu_pipeline_layout; 156 struct tu_query_pool; 157 struct tu_queue; 158 struct tu_render_pass; 159 struct tu_sampler; 160 161 struct breadcrumbs_context; 162 struct tu_bo; 163 struct tu_cs; 164 struct tu_cs_entry; 165 struct tu_suballoc_bo; 166 struct tu_suballocator; 167 struct tu_subpass; 168 struct tu_u_trace_submission_data; 169 170 #endif /* TU_COMMON_H */ 171