| 1 |
/* |
| 2 |
* Copyright © 2022 Imagination Technologies Ltd. |
| 3 |
* |
| 4 |
* based in part on anv driver which is: |
| 5 |
* Copyright © 2015 Intel Corporation |
| 6 |
* |
| 7 |
* based in part on radv driver which is: |
| 8 |
* Copyright © 2016 Red Hat. |
| 9 |
* Copyright © 2016 Bas Nieuwenhuizen |
| 10 |
* |
| 11 |
* SPDX-License-Identifier: MIT |
| 12 |
*/ |
| 13 |
|
| 14 |
#ifndef PVR_DEVICE_H |
| 15 |
#define PVR_DEVICE_H |
| 16 |
|
| 17 |
#include <xf86drm.h> |
| 18 |
|
| 19 |
#include "vk_device.h" |
| 20 |
#include "vk_device_memory.h" |
| 21 |
#include "vk_physical_device.h" |
| 22 |
|
| 23 |
#include "wsi_common.h" |
| 24 |
|
| 25 |
#include "util/mesa-blake3.h" |
| 26 |
|
| 27 |
#include "pvr_bo.h" |
| 28 |
#include "pvr_common.h" |
| 29 |
#include "pvr_macros.h" |
| 30 |
#include "pvr_pds.h" |
| 31 |
#include "pvr_spm.h" |
| 32 |
#include "pvr_usc.h" |
| 33 |
#include "pvr_winsys.h" |
| 34 |
|
| 35 |
typedef struct _pco_ctx pco_ctx; |
| 36 |
|
| 37 |
struct pvr_border_color_table; |
| 38 |
struct pvr_device_static_clear_state; |
| 39 |
struct pvr_instance; |
| 40 |
struct pvr_queue; |
| 41 |
struct pvr_render_target; |
| 42 |
|
| 43 |
struct pvr_compute_query_shader { |
| 44 |
struct pvr_suballoc_bo *usc_bo; |
| 45 |
|
| 46 |
struct pvr_pds_upload pds_prim_code; |
| 47 |
uint32_t primary_data_size_dw; |
| 48 |
uint32_t primary_num_temps; |
| 49 |
|
| 50 |
struct pvr_pds_info info; |
| 51 |
struct pvr_pds_upload pds_sec_code; |
| 52 |
}; |
| 53 |
|
| 54 |
struct pvr_device { |
| 55 |
struct vk_device vk; |
| 56 |
struct pvr_instance *instance; |
| 57 |
struct pvr_physical_device *pdevice; |
| 58 |
|
| 59 |
struct pvr_winsys *ws; |
| 60 |
struct pvr_winsys_heaps heaps; |
| 61 |
|
| 62 |
struct pvr_free_list *global_free_list; |
| 63 |
|
| 64 |
struct pvr_queue *queues; |
| 65 |
uint32_t queue_count; |
| 66 |
|
| 67 |
/* Running count of the number of job submissions across all queue. */ |
| 68 |
uint32_t global_cmd_buffer_submit_count; |
| 69 |
|
| 70 |
/* Running count of the number of presentations across all queues. */ |
| 71 |
uint32_t global_queue_present_count; |
| 72 |
|
| 73 |
uint32_t pixel_event_data_size_in_dwords; |
| 74 |
|
| 75 |
uint64_t input_attachment_sampler; |
| 76 |
|
| 77 |
struct pvr_pds_upload pds_compute_fence_program; |
| 78 |
struct pvr_pds_upload pds_compute_empty_program; |
| 79 |
|
| 80 |
/* Compute shaders for queries. */ |
| 81 |
struct pvr_compute_query_shader availability_shader; |
| 82 |
struct pvr_compute_query_shader reset_queries_shader; |
| 83 |
struct pvr_compute_query_shader copy_results_shader; |
| 84 |
|
| 85 |
struct pvr_suballocator suballoc_general; |
| 86 |
struct pvr_suballocator suballoc_pds; |
| 87 |
struct pvr_suballocator suballoc_transfer; |
| 88 |
struct pvr_suballocator suballoc_usc; |
| 89 |
struct pvr_suballocator suballoc_vis_test; |
| 90 |
|
| 91 |
struct { |
| 92 |
struct pvr_pds_upload pds; |
| 93 |
struct pvr_suballoc_bo *usc; |
| 94 |
} nop_program; |
| 95 |
|
| 96 |
struct pvr_pds_view_index_init_program |
| 97 |
view_index_init_info[PVR_MAX_MULTIVIEW]; |
| 98 |
struct pvr_pds_upload view_index_init_programs[PVR_MAX_MULTIVIEW]; |
| 99 |
|
| 100 |
/* Issue Data Fence, Wait for Data Fence state. */ |
| 101 |
struct { |
| 102 |
uint32_t usc_shareds; |
| 103 |
struct pvr_suballoc_bo *usc; |
| 104 |
|
| 105 |
/* Buffer in which the IDF/WDF program performs store ops. */ |
| 106 |
struct pvr_bo *store_bo; |
| 107 |
/* Contains the initialization values for the shared registers. */ |
| 108 |
struct pvr_bo *shareds_bo; |
| 109 |
|
| 110 |
struct pvr_pds_upload pds; |
| 111 |
struct pvr_pds_upload sw_compute_barrier_pds; |
| 112 |
} idfwdf_state; |
| 113 |
|
| 114 |
struct pvr_device_static_clear_state *static_clear_state; |
| 115 |
|
| 116 |
struct { |
| 117 |
struct pvr_suballoc_bo *usc_programs; |
| 118 |
struct pvr_suballoc_bo *pds_programs; |
| 119 |
|
| 120 |
struct pvr_spm_per_load_program_state { |
| 121 |
pvr_dev_addr_t pds_pixel_program_offset; |
| 122 |
pvr_dev_addr_t pds_uniform_program_offset; |
| 123 |
|
| 124 |
uint32_t pds_texture_program_data_size; |
| 125 |
uint32_t pds_texture_program_temps_count; |
| 126 |
} load_program[PVR_NUM_SPM_LOAD_SHADERS]; |
| 127 |
} spm_load_state; |
| 128 |
|
| 129 |
struct pvr_device_tile_buffer_state { |
| 130 |
simple_mtx_t mtx; |
| 131 |
|
| 132 |
#define PVR_MAX_TILE_BUFFER_COUNT 7U |
| 133 |
struct pvr_bo *buffers[PVR_MAX_TILE_BUFFER_COUNT]; |
| 134 |
uint32_t buffer_count; |
| 135 |
} tile_buffer_state; |
| 136 |
|
| 137 |
struct pvr_spm_scratch_buffer_store spm_scratch_buffer_store; |
| 138 |
|
| 139 |
struct pvr_bo_store *bo_store; |
| 140 |
|
| 141 |
struct pvr_bo *robustness_buffer; |
| 142 |
|
| 143 |
struct vk_sync *presignaled_sync; |
| 144 |
|
| 145 |
struct pvr_border_color_table *border_color_table; |
| 146 |
|
| 147 |
simple_mtx_t rs_mtx; |
| 148 |
struct list_head render_states; |
| 149 |
}; |
| 150 |
|
| 151 |
struct pvr_device_memory { |
| 152 |
struct vk_device_memory vk; |
| 153 |
struct pvr_winsys_bo *bo; |
| 154 |
}; |
| 155 |
|
| 156 |
VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_device_memory, |
| 157 |
vk.base, |
| 158 |
VkDeviceMemory, |
| 159 |
VK_OBJECT_TYPE_DEVICE_MEMORY) |
| 160 |
|
| 161 |
VK_DEFINE_HANDLE_CASTS(pvr_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE) |
| 162 |
|
| 163 |
static inline struct pvr_device *vk_to_pvr_device(struct vk_device *device) |
| 164 |
{ |
| 165 |
return container_of(device, struct pvr_device, vk); |
| 166 |
} |
| 167 |
|
| 168 |
VkResult pvr_device_tile_buffer_ensure_cap(struct pvr_device *device, |
| 169 |
uint32_t capacity); |
| 170 |
|
| 171 |
static inline void pvr_device_free_tile_buffer_state(struct pvr_device *device) |
| 172 |
{ |
| 173 |
for (uint32_t i = 0; i < device->tile_buffer_state.buffer_count; i++) |
| 174 |
pvr_bo_free(device, device->tile_buffer_state.buffers[i]); |
| 175 |
} |
| 176 |
|
| 177 |
VkResult pvr_bind_memory(struct pvr_device *device, |
| 178 |
struct pvr_device_memory *mem, |
| 179 |
VkDeviceSize offset, |
| 180 |
VkDeviceSize size, |
| 181 |
VkDeviceSize alignment, |
| 182 |
struct pvr_winsys_vma **const vma_out, |
| 183 |
pvr_dev_addr_t *const dev_addr_out); |
| 184 |
void pvr_unbind_memory(struct pvr_device *device, struct pvr_winsys_vma *vma); |
| 185 |
|
| 186 |
VkResult pvr_gpu_upload(struct pvr_device *device, |
| 187 |
struct pvr_winsys_heap *heap, |
| 188 |
const void *data, |
| 189 |
size_t size, |
| 190 |
uint64_t alignment, |
| 191 |
struct pvr_suballoc_bo **const pvr_bo_out); |
| 192 |
VkResult pvr_gpu_upload_pds(struct pvr_device *device, |
| 193 |
const uint32_t *data, |
| 194 |
uint32_t data_size_dwords, |
| 195 |
uint32_t data_alignment, |
| 196 |
const uint32_t *code, |
| 197 |
uint32_t code_size_dwords, |
| 198 |
uint32_t code_alignment, |
| 199 |
uint64_t min_alignment, |
| 200 |
struct pvr_pds_upload *const pds_upload_out); |
| 201 |
VkResult pvr_gpu_upload_usc(struct pvr_device *device, |
| 202 |
const void *code, |
| 203 |
size_t code_size, |
| 204 |
uint64_t code_alignment, |
| 205 |
struct pvr_suballoc_bo **const pvr_bo_out); |
| 206 |
|
| 207 |
void pvr_rstate_entry_add(struct pvr_device *device, |
| 208 |
struct pvr_render_state *rstate); |
| 209 |
|
| 210 |
void pvr_rstate_entry_remove(struct pvr_device *device, |
| 211 |
const struct pvr_render_state *rstate); |
| 212 |
|
| 213 |
void pvr_render_targets_fini(struct pvr_render_target *render_targets, |
| 214 |
uint32_t render_targets_count); |
| 215 |
|
| 216 |
#ifdef PVR_PER_ARCH |
| 217 |
|
| 218 |
VkResult PVR_PER_ARCH(create_device)(struct pvr_physical_device *pdevice, |
| 219 |
const VkDeviceCreateInfo *pCreateInfo, |
| 220 |
const VkAllocationCallbacks *pAllocator, |
| 221 |
VkDevice *pDevice); |
| 222 |
|
| 223 |
void PVR_PER_ARCH(destroy_device)(struct pvr_device *device, |
| 224 |
const VkAllocationCallbacks *pAllocator); |
| 225 |
|
| 226 |
uint32_t PVR_PER_ARCH(calc_fscommon_size_and_tiles_in_flight)( |
| 227 |
const struct pvr_device_info *dev_info, |
| 228 |
const struct pvr_device_runtime_info *dev_runtime_info, |
| 229 |
uint32_t fs_common_size, |
| 230 |
uint32_t min_tiles_in_flight); |
| 231 |
|
| 232 |
# define pvr_arch_calc_fscommon_size_and_tiles_in_flight \ |
| 233 |
PVR_PER_ARCH(calc_fscommon_size_and_tiles_in_flight) |
| 234 |
|
| 235 |
VkResult PVR_PER_ARCH(pds_compute_shader_create_and_upload)( |
| 236 |
struct pvr_device *device, |
| 237 |
struct pvr_pds_compute_shader_program *program, |
| 238 |
struct pvr_pds_upload *const pds_upload_out); |
| 239 |
|
| 240 |
# define pvr_arch_pds_compute_shader_create_and_upload \ |
| 241 |
PVR_PER_ARCH(pds_compute_shader_create_and_upload) |
| 242 |
|
| 243 |
#endif /* PVR_PER_ARCH */ |
| 244 |
|
| 245 |
#endif /* PVR_DEVICE_H */ |