1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2021 Collabora Ltd. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * derived from tu_private.h driver which is: 5bf215546Sopenharmony_ci * Copyright © 2016 Red Hat. 6bf215546Sopenharmony_ci * Copyright © 2016 Bas Nieuwenhuizen 7bf215546Sopenharmony_ci * Copyright © 2015 Intel Corporation 8bf215546Sopenharmony_ci * 9bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 10bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 11bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 12bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 13bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 14bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 17bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 18bf215546Sopenharmony_ci * Software. 19bf215546Sopenharmony_ci * 20bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 27bf215546Sopenharmony_ci */ 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#ifndef PANVK_PRIVATE_H 30bf215546Sopenharmony_ci#define PANVK_PRIVATE_H 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include <assert.h> 33bf215546Sopenharmony_ci#include <pthread.h> 34bf215546Sopenharmony_ci#include <stdbool.h> 35bf215546Sopenharmony_ci#include <stdint.h> 36bf215546Sopenharmony_ci#include <stdio.h> 37bf215546Sopenharmony_ci#include <stdlib.h> 38bf215546Sopenharmony_ci#include <string.h> 39bf215546Sopenharmony_ci#ifdef HAVE_VALGRIND 40bf215546Sopenharmony_ci#include <memcheck.h> 41bf215546Sopenharmony_ci#include <valgrind.h> 42bf215546Sopenharmony_ci#define VG(x) x 43bf215546Sopenharmony_ci#else 44bf215546Sopenharmony_ci#define VG(x) 45bf215546Sopenharmony_ci#endif 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_ci#include "c11/threads.h" 48bf215546Sopenharmony_ci#include "compiler/shader_enums.h" 49bf215546Sopenharmony_ci#include "util/list.h" 50bf215546Sopenharmony_ci#include "util/macros.h" 51bf215546Sopenharmony_ci#include "vk_alloc.h" 52bf215546Sopenharmony_ci#include "vk_buffer.h" 53bf215546Sopenharmony_ci#include "vk_command_buffer.h" 54bf215546Sopenharmony_ci#include "vk_command_pool.h" 55bf215546Sopenharmony_ci#include "vk_descriptor_set_layout.h" 56bf215546Sopenharmony_ci#include "vk_device.h" 57bf215546Sopenharmony_ci#include "vk_image.h" 58bf215546Sopenharmony_ci#include "vk_instance.h" 59bf215546Sopenharmony_ci#include "vk_log.h" 60bf215546Sopenharmony_ci#include "vk_object.h" 61bf215546Sopenharmony_ci#include "vk_physical_device.h" 62bf215546Sopenharmony_ci#include "vk_pipeline_layout.h" 63bf215546Sopenharmony_ci#include "vk_queue.h" 64bf215546Sopenharmony_ci#include "vk_sync.h" 65bf215546Sopenharmony_ci#include "wsi_common.h" 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_ci#include "drm-uapi/panfrost_drm.h" 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ci#include "pan_blend.h" 70bf215546Sopenharmony_ci#include "pan_cs.h" 71bf215546Sopenharmony_ci#include "pan_device.h" 72bf215546Sopenharmony_ci#include "panvk_mempool.h" 73bf215546Sopenharmony_ci#include "pan_texture.h" 74bf215546Sopenharmony_ci#include "pan_scoreboard.h" 75bf215546Sopenharmony_ci#include "vk_extensions.h" 76bf215546Sopenharmony_ci#include "panvk_varyings.h" 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ci/* Pre-declarations needed for WSI entrypoints */ 79bf215546Sopenharmony_cistruct wl_surface; 80bf215546Sopenharmony_cistruct wl_display; 81bf215546Sopenharmony_citypedef struct xcb_connection_t xcb_connection_t; 82bf215546Sopenharmony_citypedef uint32_t xcb_visualid_t; 83bf215546Sopenharmony_citypedef uint32_t xcb_window_t; 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ci#include <vulkan/vk_android_native_buffer.h> 86bf215546Sopenharmony_ci#include <vulkan/vk_icd.h> 87bf215546Sopenharmony_ci#include <vulkan/vulkan.h> 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci#include "panvk_entrypoints.h" 90bf215546Sopenharmony_ci 91bf215546Sopenharmony_ci#define MAX_BIND_POINTS 2 /* compute + graphics */ 92bf215546Sopenharmony_ci#define MAX_VBS 16 93bf215546Sopenharmony_ci#define MAX_VERTEX_ATTRIBS 16 94bf215546Sopenharmony_ci#define MAX_RTS 8 95bf215546Sopenharmony_ci#define MAX_VSC_PIPES 32 96bf215546Sopenharmony_ci#define MAX_VIEWPORTS 1 97bf215546Sopenharmony_ci#define MAX_SCISSORS 16 98bf215546Sopenharmony_ci#define MAX_DISCARD_RECTANGLES 4 99bf215546Sopenharmony_ci#define MAX_PUSH_CONSTANTS_SIZE 128 100bf215546Sopenharmony_ci#define MAX_PUSH_DESCRIPTORS 32 101bf215546Sopenharmony_ci#define MAX_DYNAMIC_UNIFORM_BUFFERS 16 102bf215546Sopenharmony_ci#define MAX_DYNAMIC_STORAGE_BUFFERS 8 103bf215546Sopenharmony_ci#define MAX_DYNAMIC_BUFFERS \ 104bf215546Sopenharmony_ci (MAX_DYNAMIC_UNIFORM_BUFFERS + MAX_DYNAMIC_STORAGE_BUFFERS) 105bf215546Sopenharmony_ci#define MAX_SAMPLES_LOG2 4 106bf215546Sopenharmony_ci#define NUM_META_FS_KEYS 13 107bf215546Sopenharmony_ci#define PANVK_MAX_DRM_DEVICES 1 108bf215546Sopenharmony_ci#define MAX_VIEWS 8 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_ci#define NUM_DEPTH_CLEAR_PIPELINES 3 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci#define PANVK_SYSVAL_UBO_INDEX 0 113bf215546Sopenharmony_ci#define PANVK_PUSH_CONST_UBO_INDEX 1 114bf215546Sopenharmony_ci#define PANVK_NUM_BUILTIN_UBOS 2 115bf215546Sopenharmony_ci 116bf215546Sopenharmony_ci#define panvk_printflike(a, b) __attribute__((__format__(__printf__, a, b))) 117bf215546Sopenharmony_ci 118bf215546Sopenharmony_civoid 119bf215546Sopenharmony_cipanvk_logi(const char *format, ...) panvk_printflike(1, 2); 120bf215546Sopenharmony_civoid 121bf215546Sopenharmony_cipanvk_logi_v(const char *format, va_list va); 122bf215546Sopenharmony_ci 123bf215546Sopenharmony_ci#define panvk_stub() assert(!"stub") 124bf215546Sopenharmony_ci 125bf215546Sopenharmony_ci#define PANVK_META_COPY_BUF2IMG_NUM_FORMATS 12 126bf215546Sopenharmony_ci#define PANVK_META_COPY_IMG2BUF_NUM_FORMATS 12 127bf215546Sopenharmony_ci#define PANVK_META_COPY_IMG2IMG_NUM_FORMATS 14 128bf215546Sopenharmony_ci#define PANVK_META_COPY_NUM_TEX_TYPES 5 129bf215546Sopenharmony_ci#define PANVK_META_COPY_BUF2BUF_NUM_BLKSIZES 5 130bf215546Sopenharmony_ci 131bf215546Sopenharmony_cistatic inline unsigned 132bf215546Sopenharmony_cipanvk_meta_copy_tex_type(unsigned dim, bool isarray) 133bf215546Sopenharmony_ci{ 134bf215546Sopenharmony_ci assert(dim > 0 && dim <= 3); 135bf215546Sopenharmony_ci assert(dim < 3 || !isarray); 136bf215546Sopenharmony_ci return (((dim - 1) << 1) | (isarray ? 1 : 0)); 137bf215546Sopenharmony_ci} 138bf215546Sopenharmony_ci 139bf215546Sopenharmony_cistruct panvk_meta { 140bf215546Sopenharmony_ci struct panvk_pool bin_pool; 141bf215546Sopenharmony_ci struct panvk_pool desc_pool; 142bf215546Sopenharmony_ci 143bf215546Sopenharmony_ci /* Access to the blitter pools are protected by the blitter 144bf215546Sopenharmony_ci * shader/rsd locks. They can't be merged with other binary/desc 145bf215546Sopenharmony_ci * pools unless we patch pan_blitter.c to external pool locks. 146bf215546Sopenharmony_ci */ 147bf215546Sopenharmony_ci struct { 148bf215546Sopenharmony_ci struct panvk_pool bin_pool; 149bf215546Sopenharmony_ci struct panvk_pool desc_pool; 150bf215546Sopenharmony_ci } blitter; 151bf215546Sopenharmony_ci 152bf215546Sopenharmony_ci struct { 153bf215546Sopenharmony_ci struct { 154bf215546Sopenharmony_ci mali_ptr shader; 155bf215546Sopenharmony_ci struct pan_shader_info shader_info; 156bf215546Sopenharmony_ci } color[3]; /* 3 base types */ 157bf215546Sopenharmony_ci } clear_attachment; 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_ci struct { 160bf215546Sopenharmony_ci struct { 161bf215546Sopenharmony_ci mali_ptr rsd; 162bf215546Sopenharmony_ci } buf2img[PANVK_META_COPY_BUF2IMG_NUM_FORMATS]; 163bf215546Sopenharmony_ci struct { 164bf215546Sopenharmony_ci mali_ptr rsd; 165bf215546Sopenharmony_ci } img2buf[PANVK_META_COPY_NUM_TEX_TYPES][PANVK_META_COPY_IMG2BUF_NUM_FORMATS]; 166bf215546Sopenharmony_ci struct { 167bf215546Sopenharmony_ci mali_ptr rsd; 168bf215546Sopenharmony_ci } img2img[2][PANVK_META_COPY_NUM_TEX_TYPES][PANVK_META_COPY_IMG2IMG_NUM_FORMATS]; 169bf215546Sopenharmony_ci struct { 170bf215546Sopenharmony_ci mali_ptr rsd; 171bf215546Sopenharmony_ci } buf2buf[PANVK_META_COPY_BUF2BUF_NUM_BLKSIZES]; 172bf215546Sopenharmony_ci struct { 173bf215546Sopenharmony_ci mali_ptr rsd; 174bf215546Sopenharmony_ci } fillbuf; 175bf215546Sopenharmony_ci } copy; 176bf215546Sopenharmony_ci}; 177bf215546Sopenharmony_ci 178bf215546Sopenharmony_cistruct panvk_physical_device { 179bf215546Sopenharmony_ci struct vk_physical_device vk; 180bf215546Sopenharmony_ci 181bf215546Sopenharmony_ci /* The API agnostic device object. */ 182bf215546Sopenharmony_ci struct panfrost_device pdev; 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci struct panvk_instance *instance; 185bf215546Sopenharmony_ci 186bf215546Sopenharmony_ci char path[20]; 187bf215546Sopenharmony_ci char name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]; 188bf215546Sopenharmony_ci uint8_t driver_uuid[VK_UUID_SIZE]; 189bf215546Sopenharmony_ci uint8_t device_uuid[VK_UUID_SIZE]; 190bf215546Sopenharmony_ci uint8_t cache_uuid[VK_UUID_SIZE]; 191bf215546Sopenharmony_ci 192bf215546Sopenharmony_ci struct vk_sync_type drm_syncobj_type; 193bf215546Sopenharmony_ci const struct vk_sync_type *sync_types[2]; 194bf215546Sopenharmony_ci 195bf215546Sopenharmony_ci struct wsi_device wsi_device; 196bf215546Sopenharmony_ci struct panvk_meta meta; 197bf215546Sopenharmony_ci 198bf215546Sopenharmony_ci int master_fd; 199bf215546Sopenharmony_ci}; 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_cienum panvk_debug_flags { 202bf215546Sopenharmony_ci PANVK_DEBUG_STARTUP = 1 << 0, 203bf215546Sopenharmony_ci PANVK_DEBUG_NIR = 1 << 1, 204bf215546Sopenharmony_ci PANVK_DEBUG_TRACE = 1 << 2, 205bf215546Sopenharmony_ci PANVK_DEBUG_SYNC = 1 << 3, 206bf215546Sopenharmony_ci PANVK_DEBUG_AFBC = 1 << 4, 207bf215546Sopenharmony_ci PANVK_DEBUG_LINEAR = 1 << 5, 208bf215546Sopenharmony_ci PANVK_DEBUG_DUMP = 1 << 6, 209bf215546Sopenharmony_ci}; 210bf215546Sopenharmony_ci 211bf215546Sopenharmony_cistruct panvk_instance { 212bf215546Sopenharmony_ci struct vk_instance vk; 213bf215546Sopenharmony_ci 214bf215546Sopenharmony_ci uint32_t api_version; 215bf215546Sopenharmony_ci int physical_device_count; 216bf215546Sopenharmony_ci struct panvk_physical_device physical_devices[PANVK_MAX_DRM_DEVICES]; 217bf215546Sopenharmony_ci 218bf215546Sopenharmony_ci enum panvk_debug_flags debug_flags; 219bf215546Sopenharmony_ci}; 220bf215546Sopenharmony_ci 221bf215546Sopenharmony_ciVkResult 222bf215546Sopenharmony_cipanvk_wsi_init(struct panvk_physical_device *physical_device); 223bf215546Sopenharmony_civoid 224bf215546Sopenharmony_cipanvk_wsi_finish(struct panvk_physical_device *physical_device); 225bf215546Sopenharmony_ci 226bf215546Sopenharmony_cibool 227bf215546Sopenharmony_cipanvk_instance_extension_supported(const char *name); 228bf215546Sopenharmony_ciuint32_t 229bf215546Sopenharmony_cipanvk_physical_device_api_version(struct panvk_physical_device *dev); 230bf215546Sopenharmony_cibool 231bf215546Sopenharmony_cipanvk_physical_device_extension_supported(struct panvk_physical_device *dev, 232bf215546Sopenharmony_ci const char *name); 233bf215546Sopenharmony_ci 234bf215546Sopenharmony_cistruct panvk_pipeline_cache { 235bf215546Sopenharmony_ci struct vk_object_base base; 236bf215546Sopenharmony_ci VkAllocationCallbacks alloc; 237bf215546Sopenharmony_ci}; 238bf215546Sopenharmony_ci 239bf215546Sopenharmony_ci/* queue types */ 240bf215546Sopenharmony_ci#define PANVK_QUEUE_GENERAL 0 241bf215546Sopenharmony_ci 242bf215546Sopenharmony_ci#define PANVK_MAX_QUEUE_FAMILIES 1 243bf215546Sopenharmony_ci 244bf215546Sopenharmony_cistruct panvk_queue { 245bf215546Sopenharmony_ci struct vk_queue vk; 246bf215546Sopenharmony_ci struct panvk_device *device; 247bf215546Sopenharmony_ci uint32_t sync; 248bf215546Sopenharmony_ci}; 249bf215546Sopenharmony_ci 250bf215546Sopenharmony_cistruct panvk_device { 251bf215546Sopenharmony_ci struct vk_device vk; 252bf215546Sopenharmony_ci 253bf215546Sopenharmony_ci struct vk_device_dispatch_table cmd_dispatch; 254bf215546Sopenharmony_ci 255bf215546Sopenharmony_ci struct panvk_instance *instance; 256bf215546Sopenharmony_ci 257bf215546Sopenharmony_ci struct panvk_queue *queues[PANVK_MAX_QUEUE_FAMILIES]; 258bf215546Sopenharmony_ci int queue_count[PANVK_MAX_QUEUE_FAMILIES]; 259bf215546Sopenharmony_ci 260bf215546Sopenharmony_ci struct panvk_physical_device *physical_device; 261bf215546Sopenharmony_ci int _lost; 262bf215546Sopenharmony_ci}; 263bf215546Sopenharmony_ci 264bf215546Sopenharmony_ciVkResult _panvk_device_set_lost(struct panvk_device *device, 265bf215546Sopenharmony_ci const char *file, int line, 266bf215546Sopenharmony_ci const char *msg, ...) PRINTFLIKE(4, 5); 267bf215546Sopenharmony_ci#define panvk_device_set_lost(dev, ...) \ 268bf215546Sopenharmony_ci _panvk_device_set_lost(dev, __FILE__, __LINE__, __VA_ARGS__) 269bf215546Sopenharmony_ci 270bf215546Sopenharmony_cistatic inline bool 271bf215546Sopenharmony_cipanvk_device_is_lost(struct panvk_device *device) 272bf215546Sopenharmony_ci{ 273bf215546Sopenharmony_ci return unlikely(p_atomic_read(&device->_lost)); 274bf215546Sopenharmony_ci} 275bf215546Sopenharmony_ci 276bf215546Sopenharmony_ci#define TILER_DESC_WORDS 56 277bf215546Sopenharmony_ci 278bf215546Sopenharmony_cistruct panvk_batch { 279bf215546Sopenharmony_ci struct list_head node; 280bf215546Sopenharmony_ci struct util_dynarray jobs; 281bf215546Sopenharmony_ci struct util_dynarray event_ops; 282bf215546Sopenharmony_ci struct pan_scoreboard scoreboard; 283bf215546Sopenharmony_ci struct { 284bf215546Sopenharmony_ci const struct panvk_framebuffer *info; 285bf215546Sopenharmony_ci struct panfrost_ptr desc; 286bf215546Sopenharmony_ci } fb; 287bf215546Sopenharmony_ci struct { 288bf215546Sopenharmony_ci struct panfrost_bo *src, *dst; 289bf215546Sopenharmony_ci } blit; 290bf215546Sopenharmony_ci struct panfrost_ptr tls; 291bf215546Sopenharmony_ci mali_ptr fragment_job; 292bf215546Sopenharmony_ci struct { 293bf215546Sopenharmony_ci struct pan_tiler_context ctx; 294bf215546Sopenharmony_ci struct panfrost_ptr descs; 295bf215546Sopenharmony_ci uint32_t templ[TILER_DESC_WORDS]; 296bf215546Sopenharmony_ci } tiler; 297bf215546Sopenharmony_ci struct pan_tls_info tlsinfo; 298bf215546Sopenharmony_ci unsigned wls_total_size; 299bf215546Sopenharmony_ci bool issued; 300bf215546Sopenharmony_ci}; 301bf215546Sopenharmony_ci 302bf215546Sopenharmony_cienum panvk_event_op_type { 303bf215546Sopenharmony_ci PANVK_EVENT_OP_SET, 304bf215546Sopenharmony_ci PANVK_EVENT_OP_RESET, 305bf215546Sopenharmony_ci PANVK_EVENT_OP_WAIT, 306bf215546Sopenharmony_ci}; 307bf215546Sopenharmony_ci 308bf215546Sopenharmony_cistruct panvk_event_op { 309bf215546Sopenharmony_ci enum panvk_event_op_type type; 310bf215546Sopenharmony_ci struct panvk_event *event; 311bf215546Sopenharmony_ci}; 312bf215546Sopenharmony_ci 313bf215546Sopenharmony_cistruct panvk_device_memory { 314bf215546Sopenharmony_ci struct vk_object_base base; 315bf215546Sopenharmony_ci struct panfrost_bo *bo; 316bf215546Sopenharmony_ci}; 317bf215546Sopenharmony_ci 318bf215546Sopenharmony_cistruct panvk_buffer_desc { 319bf215546Sopenharmony_ci struct panvk_buffer *buffer; 320bf215546Sopenharmony_ci VkDeviceSize offset; 321bf215546Sopenharmony_ci VkDeviceSize size; 322bf215546Sopenharmony_ci}; 323bf215546Sopenharmony_ci 324bf215546Sopenharmony_cistruct panvk_descriptor_set { 325bf215546Sopenharmony_ci struct vk_object_base base; 326bf215546Sopenharmony_ci struct panvk_descriptor_pool *pool; 327bf215546Sopenharmony_ci const struct panvk_descriptor_set_layout *layout; 328bf215546Sopenharmony_ci struct panvk_buffer_desc *dyn_ssbos; 329bf215546Sopenharmony_ci void *ubos; 330bf215546Sopenharmony_ci struct panvk_buffer_desc *dyn_ubos; 331bf215546Sopenharmony_ci void *samplers; 332bf215546Sopenharmony_ci void *textures; 333bf215546Sopenharmony_ci void *img_attrib_bufs; 334bf215546Sopenharmony_ci uint32_t *img_fmts; 335bf215546Sopenharmony_ci 336bf215546Sopenharmony_ci struct panfrost_bo *desc_bo; 337bf215546Sopenharmony_ci}; 338bf215546Sopenharmony_ci 339bf215546Sopenharmony_ci#define MAX_SETS 4 340bf215546Sopenharmony_ci 341bf215546Sopenharmony_cistruct panvk_descriptor_set_binding_layout { 342bf215546Sopenharmony_ci VkDescriptorType type; 343bf215546Sopenharmony_ci 344bf215546Sopenharmony_ci /* Number of array elements in this binding */ 345bf215546Sopenharmony_ci unsigned array_size; 346bf215546Sopenharmony_ci 347bf215546Sopenharmony_ci /* Indices in the desc arrays */ 348bf215546Sopenharmony_ci union { 349bf215546Sopenharmony_ci struct { 350bf215546Sopenharmony_ci union { 351bf215546Sopenharmony_ci unsigned sampler_idx; 352bf215546Sopenharmony_ci unsigned img_idx; 353bf215546Sopenharmony_ci }; 354bf215546Sopenharmony_ci unsigned tex_idx; 355bf215546Sopenharmony_ci }; 356bf215546Sopenharmony_ci unsigned dyn_ssbo_idx; 357bf215546Sopenharmony_ci unsigned ubo_idx; 358bf215546Sopenharmony_ci unsigned dyn_ubo_idx; 359bf215546Sopenharmony_ci }; 360bf215546Sopenharmony_ci 361bf215546Sopenharmony_ci /* Offset into the descriptor UBO where this binding starts */ 362bf215546Sopenharmony_ci uint32_t desc_ubo_offset; 363bf215546Sopenharmony_ci 364bf215546Sopenharmony_ci /* Stride between descriptors in this binding in the UBO */ 365bf215546Sopenharmony_ci uint16_t desc_ubo_stride; 366bf215546Sopenharmony_ci 367bf215546Sopenharmony_ci /* Shader stages affected by this set+binding */ 368bf215546Sopenharmony_ci uint16_t shader_stages; 369bf215546Sopenharmony_ci 370bf215546Sopenharmony_ci struct panvk_sampler **immutable_samplers; 371bf215546Sopenharmony_ci}; 372bf215546Sopenharmony_ci 373bf215546Sopenharmony_cistruct panvk_descriptor_set_layout { 374bf215546Sopenharmony_ci struct vk_descriptor_set_layout vk; 375bf215546Sopenharmony_ci 376bf215546Sopenharmony_ci /* Shader stages affected by this descriptor set */ 377bf215546Sopenharmony_ci uint16_t shader_stages; 378bf215546Sopenharmony_ci 379bf215546Sopenharmony_ci unsigned num_samplers; 380bf215546Sopenharmony_ci unsigned num_textures; 381bf215546Sopenharmony_ci unsigned num_ubos; 382bf215546Sopenharmony_ci unsigned num_dyn_ubos; 383bf215546Sopenharmony_ci unsigned num_dyn_ssbos; 384bf215546Sopenharmony_ci unsigned num_imgs; 385bf215546Sopenharmony_ci 386bf215546Sopenharmony_ci /* Size of the descriptor UBO */ 387bf215546Sopenharmony_ci uint32_t desc_ubo_size; 388bf215546Sopenharmony_ci 389bf215546Sopenharmony_ci /* Index of the descriptor UBO */ 390bf215546Sopenharmony_ci unsigned desc_ubo_index; 391bf215546Sopenharmony_ci 392bf215546Sopenharmony_ci /* Number of bindings in this descriptor set */ 393bf215546Sopenharmony_ci uint32_t binding_count; 394bf215546Sopenharmony_ci 395bf215546Sopenharmony_ci /* Bindings in this descriptor set */ 396bf215546Sopenharmony_ci struct panvk_descriptor_set_binding_layout bindings[0]; 397bf215546Sopenharmony_ci}; 398bf215546Sopenharmony_ci 399bf215546Sopenharmony_cistatic inline const struct panvk_descriptor_set_layout * 400bf215546Sopenharmony_civk_to_panvk_descriptor_set_layout(const struct vk_descriptor_set_layout *layout) 401bf215546Sopenharmony_ci{ 402bf215546Sopenharmony_ci return container_of(layout, const struct panvk_descriptor_set_layout, vk); 403bf215546Sopenharmony_ci} 404bf215546Sopenharmony_ci 405bf215546Sopenharmony_cistruct panvk_pipeline_layout { 406bf215546Sopenharmony_ci struct vk_pipeline_layout vk; 407bf215546Sopenharmony_ci 408bf215546Sopenharmony_ci unsigned char sha1[20]; 409bf215546Sopenharmony_ci 410bf215546Sopenharmony_ci unsigned num_samplers; 411bf215546Sopenharmony_ci unsigned num_textures; 412bf215546Sopenharmony_ci unsigned num_ubos; 413bf215546Sopenharmony_ci unsigned num_dyn_ubos; 414bf215546Sopenharmony_ci unsigned num_dyn_ssbos; 415bf215546Sopenharmony_ci uint32_t num_imgs; 416bf215546Sopenharmony_ci uint32_t num_sets; 417bf215546Sopenharmony_ci 418bf215546Sopenharmony_ci struct { 419bf215546Sopenharmony_ci uint32_t size; 420bf215546Sopenharmony_ci } push_constants; 421bf215546Sopenharmony_ci 422bf215546Sopenharmony_ci struct { 423bf215546Sopenharmony_ci unsigned sampler_offset; 424bf215546Sopenharmony_ci unsigned tex_offset; 425bf215546Sopenharmony_ci unsigned ubo_offset; 426bf215546Sopenharmony_ci unsigned dyn_ubo_offset; 427bf215546Sopenharmony_ci unsigned dyn_ssbo_offset; 428bf215546Sopenharmony_ci unsigned img_offset; 429bf215546Sopenharmony_ci } sets[MAX_SETS]; 430bf215546Sopenharmony_ci}; 431bf215546Sopenharmony_ci 432bf215546Sopenharmony_cistatic unsigned 433bf215546Sopenharmony_cipanvk_pipeline_layout_ubo_start(const struct panvk_pipeline_layout *layout, 434bf215546Sopenharmony_ci unsigned set, bool is_dynamic) 435bf215546Sopenharmony_ci{ 436bf215546Sopenharmony_ci const struct panvk_descriptor_set_layout *set_layout = 437bf215546Sopenharmony_ci vk_to_panvk_descriptor_set_layout(layout->vk.set_layouts[set]); 438bf215546Sopenharmony_ci 439bf215546Sopenharmony_ci unsigned offset = PANVK_NUM_BUILTIN_UBOS + 440bf215546Sopenharmony_ci layout->sets[set].ubo_offset + 441bf215546Sopenharmony_ci layout->sets[set].dyn_ubo_offset; 442bf215546Sopenharmony_ci 443bf215546Sopenharmony_ci if (is_dynamic) 444bf215546Sopenharmony_ci offset += set_layout->num_ubos; 445bf215546Sopenharmony_ci 446bf215546Sopenharmony_ci return offset; 447bf215546Sopenharmony_ci} 448bf215546Sopenharmony_ci 449bf215546Sopenharmony_cistatic unsigned 450bf215546Sopenharmony_cipanvk_pipeline_layout_ubo_index(const struct panvk_pipeline_layout *layout, 451bf215546Sopenharmony_ci unsigned set, unsigned binding, 452bf215546Sopenharmony_ci unsigned array_index) 453bf215546Sopenharmony_ci{ 454bf215546Sopenharmony_ci const struct panvk_descriptor_set_layout *set_layout = 455bf215546Sopenharmony_ci vk_to_panvk_descriptor_set_layout(layout->vk.set_layouts[set]); 456bf215546Sopenharmony_ci const struct panvk_descriptor_set_binding_layout *binding_layout = 457bf215546Sopenharmony_ci &set_layout->bindings[binding]; 458bf215546Sopenharmony_ci 459bf215546Sopenharmony_ci const bool is_dynamic = 460bf215546Sopenharmony_ci binding_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; 461bf215546Sopenharmony_ci const uint32_t ubo_idx = is_dynamic ? binding_layout->dyn_ubo_idx : 462bf215546Sopenharmony_ci binding_layout->ubo_idx; 463bf215546Sopenharmony_ci 464bf215546Sopenharmony_ci return panvk_pipeline_layout_ubo_start(layout, set, is_dynamic) + 465bf215546Sopenharmony_ci ubo_idx + array_index; 466bf215546Sopenharmony_ci} 467bf215546Sopenharmony_ci 468bf215546Sopenharmony_cistruct panvk_desc_pool_counters { 469bf215546Sopenharmony_ci unsigned samplers; 470bf215546Sopenharmony_ci unsigned combined_image_samplers; 471bf215546Sopenharmony_ci unsigned sampled_images; 472bf215546Sopenharmony_ci unsigned storage_images; 473bf215546Sopenharmony_ci unsigned uniform_texel_bufs; 474bf215546Sopenharmony_ci unsigned storage_texel_bufs; 475bf215546Sopenharmony_ci unsigned input_attachments; 476bf215546Sopenharmony_ci unsigned uniform_bufs; 477bf215546Sopenharmony_ci unsigned storage_bufs; 478bf215546Sopenharmony_ci unsigned uniform_dyn_bufs; 479bf215546Sopenharmony_ci unsigned storage_dyn_bufs; 480bf215546Sopenharmony_ci unsigned sets; 481bf215546Sopenharmony_ci}; 482bf215546Sopenharmony_ci 483bf215546Sopenharmony_cistruct panvk_descriptor_pool { 484bf215546Sopenharmony_ci struct vk_object_base base; 485bf215546Sopenharmony_ci struct panvk_desc_pool_counters max; 486bf215546Sopenharmony_ci struct panvk_desc_pool_counters cur; 487bf215546Sopenharmony_ci struct panvk_descriptor_set *sets; 488bf215546Sopenharmony_ci}; 489bf215546Sopenharmony_ci 490bf215546Sopenharmony_cistruct panvk_buffer { 491bf215546Sopenharmony_ci struct vk_buffer vk; 492bf215546Sopenharmony_ci 493bf215546Sopenharmony_ci struct panfrost_bo *bo; 494bf215546Sopenharmony_ci VkDeviceSize bo_offset; 495bf215546Sopenharmony_ci}; 496bf215546Sopenharmony_ci 497bf215546Sopenharmony_cistatic inline mali_ptr 498bf215546Sopenharmony_cipanvk_buffer_gpu_ptr(const struct panvk_buffer *buffer, uint64_t offset) 499bf215546Sopenharmony_ci{ 500bf215546Sopenharmony_ci if (buffer->bo == NULL) 501bf215546Sopenharmony_ci return 0; 502bf215546Sopenharmony_ci 503bf215546Sopenharmony_ci return buffer->bo->ptr.gpu + buffer->bo_offset + offset; 504bf215546Sopenharmony_ci} 505bf215546Sopenharmony_ci 506bf215546Sopenharmony_cistatic inline uint64_t 507bf215546Sopenharmony_cipanvk_buffer_range(const struct panvk_buffer *buffer, 508bf215546Sopenharmony_ci uint64_t offset, uint64_t range) 509bf215546Sopenharmony_ci{ 510bf215546Sopenharmony_ci if (buffer->bo == NULL) 511bf215546Sopenharmony_ci return 0; 512bf215546Sopenharmony_ci 513bf215546Sopenharmony_ci return vk_buffer_range(&buffer->vk, offset, range); 514bf215546Sopenharmony_ci} 515bf215546Sopenharmony_ci 516bf215546Sopenharmony_cienum panvk_dynamic_state_bits { 517bf215546Sopenharmony_ci PANVK_DYNAMIC_VIEWPORT = 1 << 0, 518bf215546Sopenharmony_ci PANVK_DYNAMIC_SCISSOR = 1 << 1, 519bf215546Sopenharmony_ci PANVK_DYNAMIC_LINE_WIDTH = 1 << 2, 520bf215546Sopenharmony_ci PANVK_DYNAMIC_DEPTH_BIAS = 1 << 3, 521bf215546Sopenharmony_ci PANVK_DYNAMIC_BLEND_CONSTANTS = 1 << 4, 522bf215546Sopenharmony_ci PANVK_DYNAMIC_DEPTH_BOUNDS = 1 << 5, 523bf215546Sopenharmony_ci PANVK_DYNAMIC_STENCIL_COMPARE_MASK = 1 << 6, 524bf215546Sopenharmony_ci PANVK_DYNAMIC_STENCIL_WRITE_MASK = 1 << 7, 525bf215546Sopenharmony_ci PANVK_DYNAMIC_STENCIL_REFERENCE = 1 << 8, 526bf215546Sopenharmony_ci PANVK_DYNAMIC_DISCARD_RECTANGLE = 1 << 9, 527bf215546Sopenharmony_ci PANVK_DYNAMIC_SSBO = 1 << 10, 528bf215546Sopenharmony_ci PANVK_DYNAMIC_VERTEX_INSTANCE_OFFSETS = 1 << 11, 529bf215546Sopenharmony_ci PANVK_DYNAMIC_ALL = (1 << 12) - 1, 530bf215546Sopenharmony_ci}; 531bf215546Sopenharmony_ci 532bf215546Sopenharmony_ci/* This has to match nir_address_format_64bit_bounded_global */ 533bf215546Sopenharmony_cistruct panvk_ssbo_addr { 534bf215546Sopenharmony_ci uint64_t base_addr; 535bf215546Sopenharmony_ci uint32_t size; 536bf215546Sopenharmony_ci uint32_t zero; /* Must be zero! */ 537bf215546Sopenharmony_ci}; 538bf215546Sopenharmony_ci 539bf215546Sopenharmony_ciunion panvk_sysval_vec4 { 540bf215546Sopenharmony_ci float f32[4]; 541bf215546Sopenharmony_ci uint32_t u32[4]; 542bf215546Sopenharmony_ci}; 543bf215546Sopenharmony_ci 544bf215546Sopenharmony_cistruct panvk_sysvals { 545bf215546Sopenharmony_ci union { 546bf215546Sopenharmony_ci struct { 547bf215546Sopenharmony_ci /* Only for graphics */ 548bf215546Sopenharmony_ci union panvk_sysval_vec4 viewport_scale; 549bf215546Sopenharmony_ci union panvk_sysval_vec4 viewport_offset; 550bf215546Sopenharmony_ci union { 551bf215546Sopenharmony_ci union panvk_sysval_vec4 vertex_instance_offsets; 552bf215546Sopenharmony_ci struct { 553bf215546Sopenharmony_ci uint32_t first_vertex; 554bf215546Sopenharmony_ci uint32_t base_vertex; 555bf215546Sopenharmony_ci uint32_t base_instance; 556bf215546Sopenharmony_ci }; 557bf215546Sopenharmony_ci }; 558bf215546Sopenharmony_ci union panvk_sysval_vec4 blend_constants; 559bf215546Sopenharmony_ci }; 560bf215546Sopenharmony_ci 561bf215546Sopenharmony_ci struct { 562bf215546Sopenharmony_ci /* Only for compute */ 563bf215546Sopenharmony_ci union panvk_sysval_vec4 num_work_groups; 564bf215546Sopenharmony_ci union panvk_sysval_vec4 local_group_size; 565bf215546Sopenharmony_ci }; 566bf215546Sopenharmony_ci }; 567bf215546Sopenharmony_ci 568bf215546Sopenharmony_ci /* The back-end compiler doesn't know about any sysvals after this point */ 569bf215546Sopenharmony_ci 570bf215546Sopenharmony_ci struct panvk_ssbo_addr dyn_ssbos[MAX_DYNAMIC_STORAGE_BUFFERS]; 571bf215546Sopenharmony_ci}; 572bf215546Sopenharmony_ci 573bf215546Sopenharmony_cistruct panvk_descriptor_state { 574bf215546Sopenharmony_ci uint32_t dirty; 575bf215546Sopenharmony_ci const struct panvk_descriptor_set *sets[MAX_SETS]; 576bf215546Sopenharmony_ci struct panvk_sysvals sysvals; 577bf215546Sopenharmony_ci struct { 578bf215546Sopenharmony_ci struct panvk_buffer_desc ubos[MAX_DYNAMIC_UNIFORM_BUFFERS]; 579bf215546Sopenharmony_ci struct panvk_buffer_desc ssbos[MAX_DYNAMIC_STORAGE_BUFFERS]; 580bf215546Sopenharmony_ci } dyn; 581bf215546Sopenharmony_ci mali_ptr sysvals_ptr; 582bf215546Sopenharmony_ci mali_ptr ubos; 583bf215546Sopenharmony_ci mali_ptr textures; 584bf215546Sopenharmony_ci mali_ptr samplers; 585bf215546Sopenharmony_ci mali_ptr push_constants; 586bf215546Sopenharmony_ci mali_ptr vs_attribs; 587bf215546Sopenharmony_ci mali_ptr vs_attrib_bufs; 588bf215546Sopenharmony_ci mali_ptr non_vs_attribs; 589bf215546Sopenharmony_ci mali_ptr non_vs_attrib_bufs; 590bf215546Sopenharmony_ci}; 591bf215546Sopenharmony_ci 592bf215546Sopenharmony_ci#define INVOCATION_DESC_WORDS 2 593bf215546Sopenharmony_ci 594bf215546Sopenharmony_cistruct panvk_draw_info { 595bf215546Sopenharmony_ci unsigned first_index; 596bf215546Sopenharmony_ci unsigned index_count; 597bf215546Sopenharmony_ci unsigned index_size; 598bf215546Sopenharmony_ci unsigned first_vertex; 599bf215546Sopenharmony_ci unsigned vertex_count; 600bf215546Sopenharmony_ci unsigned vertex_range; 601bf215546Sopenharmony_ci unsigned padded_vertex_count; 602bf215546Sopenharmony_ci unsigned first_instance; 603bf215546Sopenharmony_ci unsigned instance_count; 604bf215546Sopenharmony_ci int vertex_offset; 605bf215546Sopenharmony_ci unsigned offset_start; 606bf215546Sopenharmony_ci uint32_t invocation[INVOCATION_DESC_WORDS]; 607bf215546Sopenharmony_ci struct { 608bf215546Sopenharmony_ci mali_ptr varyings; 609bf215546Sopenharmony_ci mali_ptr attributes; 610bf215546Sopenharmony_ci mali_ptr attribute_bufs; 611bf215546Sopenharmony_ci mali_ptr push_constants; 612bf215546Sopenharmony_ci } stages[MESA_SHADER_STAGES]; 613bf215546Sopenharmony_ci mali_ptr varying_bufs; 614bf215546Sopenharmony_ci mali_ptr textures; 615bf215546Sopenharmony_ci mali_ptr samplers; 616bf215546Sopenharmony_ci mali_ptr ubos; 617bf215546Sopenharmony_ci mali_ptr position; 618bf215546Sopenharmony_ci mali_ptr indices; 619bf215546Sopenharmony_ci union { 620bf215546Sopenharmony_ci mali_ptr psiz; 621bf215546Sopenharmony_ci float line_width; 622bf215546Sopenharmony_ci }; 623bf215546Sopenharmony_ci mali_ptr tls; 624bf215546Sopenharmony_ci mali_ptr fb; 625bf215546Sopenharmony_ci const struct pan_tiler_context *tiler_ctx; 626bf215546Sopenharmony_ci mali_ptr fs_rsd; 627bf215546Sopenharmony_ci mali_ptr viewport; 628bf215546Sopenharmony_ci struct { 629bf215546Sopenharmony_ci struct panfrost_ptr vertex; 630bf215546Sopenharmony_ci struct panfrost_ptr tiler; 631bf215546Sopenharmony_ci } jobs; 632bf215546Sopenharmony_ci}; 633bf215546Sopenharmony_ci 634bf215546Sopenharmony_cistruct panvk_dispatch_info { 635bf215546Sopenharmony_ci struct pan_compute_dim wg_count; 636bf215546Sopenharmony_ci mali_ptr attributes; 637bf215546Sopenharmony_ci mali_ptr attribute_bufs; 638bf215546Sopenharmony_ci mali_ptr tsd; 639bf215546Sopenharmony_ci mali_ptr ubos; 640bf215546Sopenharmony_ci mali_ptr push_uniforms; 641bf215546Sopenharmony_ci mali_ptr textures; 642bf215546Sopenharmony_ci mali_ptr samplers; 643bf215546Sopenharmony_ci}; 644bf215546Sopenharmony_ci 645bf215546Sopenharmony_cistruct panvk_attrib_info { 646bf215546Sopenharmony_ci unsigned buf; 647bf215546Sopenharmony_ci unsigned offset; 648bf215546Sopenharmony_ci enum pipe_format format; 649bf215546Sopenharmony_ci}; 650bf215546Sopenharmony_ci 651bf215546Sopenharmony_cistruct panvk_attrib_buf_info { 652bf215546Sopenharmony_ci bool special; 653bf215546Sopenharmony_ci union { 654bf215546Sopenharmony_ci struct { 655bf215546Sopenharmony_ci unsigned stride; 656bf215546Sopenharmony_ci bool per_instance; 657bf215546Sopenharmony_ci uint32_t instance_divisor; 658bf215546Sopenharmony_ci }; 659bf215546Sopenharmony_ci unsigned special_id; 660bf215546Sopenharmony_ci }; 661bf215546Sopenharmony_ci}; 662bf215546Sopenharmony_ci 663bf215546Sopenharmony_cistruct panvk_attribs_info { 664bf215546Sopenharmony_ci struct panvk_attrib_info attrib[PAN_MAX_ATTRIBUTE]; 665bf215546Sopenharmony_ci unsigned attrib_count; 666bf215546Sopenharmony_ci struct panvk_attrib_buf_info buf[PAN_MAX_ATTRIBUTE]; 667bf215546Sopenharmony_ci unsigned buf_count; 668bf215546Sopenharmony_ci}; 669bf215546Sopenharmony_ci 670bf215546Sopenharmony_cistruct panvk_attrib_buf { 671bf215546Sopenharmony_ci mali_ptr address; 672bf215546Sopenharmony_ci unsigned size; 673bf215546Sopenharmony_ci}; 674bf215546Sopenharmony_ci 675bf215546Sopenharmony_cistruct panvk_cmd_state { 676bf215546Sopenharmony_ci uint32_t dirty; 677bf215546Sopenharmony_ci 678bf215546Sopenharmony_ci struct panvk_varyings_info varyings; 679bf215546Sopenharmony_ci mali_ptr fs_rsd; 680bf215546Sopenharmony_ci 681bf215546Sopenharmony_ci struct { 682bf215546Sopenharmony_ci float constants[4]; 683bf215546Sopenharmony_ci } blend; 684bf215546Sopenharmony_ci 685bf215546Sopenharmony_ci struct { 686bf215546Sopenharmony_ci struct { 687bf215546Sopenharmony_ci float constant_factor; 688bf215546Sopenharmony_ci float clamp; 689bf215546Sopenharmony_ci float slope_factor; 690bf215546Sopenharmony_ci } depth_bias; 691bf215546Sopenharmony_ci float line_width; 692bf215546Sopenharmony_ci } rast; 693bf215546Sopenharmony_ci 694bf215546Sopenharmony_ci struct { 695bf215546Sopenharmony_ci struct panvk_attrib_buf bufs[MAX_VBS]; 696bf215546Sopenharmony_ci unsigned count; 697bf215546Sopenharmony_ci } vb; 698bf215546Sopenharmony_ci 699bf215546Sopenharmony_ci /* Index buffer */ 700bf215546Sopenharmony_ci struct { 701bf215546Sopenharmony_ci struct panvk_buffer *buffer; 702bf215546Sopenharmony_ci uint64_t offset; 703bf215546Sopenharmony_ci uint8_t index_size; 704bf215546Sopenharmony_ci uint32_t first_vertex, base_vertex, base_instance; 705bf215546Sopenharmony_ci } ib; 706bf215546Sopenharmony_ci 707bf215546Sopenharmony_ci struct { 708bf215546Sopenharmony_ci struct { 709bf215546Sopenharmony_ci uint8_t compare_mask; 710bf215546Sopenharmony_ci uint8_t write_mask; 711bf215546Sopenharmony_ci uint8_t ref; 712bf215546Sopenharmony_ci } s_front, s_back; 713bf215546Sopenharmony_ci } zs; 714bf215546Sopenharmony_ci 715bf215546Sopenharmony_ci struct { 716bf215546Sopenharmony_ci struct pan_fb_info info; 717bf215546Sopenharmony_ci bool crc_valid[MAX_RTS]; 718bf215546Sopenharmony_ci } fb; 719bf215546Sopenharmony_ci 720bf215546Sopenharmony_ci const struct panvk_render_pass *pass; 721bf215546Sopenharmony_ci const struct panvk_subpass *subpass; 722bf215546Sopenharmony_ci const struct panvk_framebuffer *framebuffer; 723bf215546Sopenharmony_ci VkRect2D render_area; 724bf215546Sopenharmony_ci 725bf215546Sopenharmony_ci struct panvk_clear_value *clear; 726bf215546Sopenharmony_ci 727bf215546Sopenharmony_ci mali_ptr vpd; 728bf215546Sopenharmony_ci VkViewport viewport; 729bf215546Sopenharmony_ci VkRect2D scissor; 730bf215546Sopenharmony_ci 731bf215546Sopenharmony_ci struct panvk_batch *batch; 732bf215546Sopenharmony_ci}; 733bf215546Sopenharmony_ci 734bf215546Sopenharmony_cistruct panvk_cmd_pool { 735bf215546Sopenharmony_ci struct vk_command_pool vk; 736bf215546Sopenharmony_ci struct list_head active_cmd_buffers; 737bf215546Sopenharmony_ci struct list_head free_cmd_buffers; 738bf215546Sopenharmony_ci struct panvk_bo_pool desc_bo_pool; 739bf215546Sopenharmony_ci struct panvk_bo_pool varying_bo_pool; 740bf215546Sopenharmony_ci struct panvk_bo_pool tls_bo_pool; 741bf215546Sopenharmony_ci}; 742bf215546Sopenharmony_ci 743bf215546Sopenharmony_cienum panvk_cmd_buffer_status { 744bf215546Sopenharmony_ci PANVK_CMD_BUFFER_STATUS_INVALID, 745bf215546Sopenharmony_ci PANVK_CMD_BUFFER_STATUS_INITIAL, 746bf215546Sopenharmony_ci PANVK_CMD_BUFFER_STATUS_RECORDING, 747bf215546Sopenharmony_ci PANVK_CMD_BUFFER_STATUS_EXECUTABLE, 748bf215546Sopenharmony_ci PANVK_CMD_BUFFER_STATUS_PENDING, 749bf215546Sopenharmony_ci}; 750bf215546Sopenharmony_ci 751bf215546Sopenharmony_cistruct panvk_cmd_bind_point_state { 752bf215546Sopenharmony_ci struct panvk_descriptor_state desc_state; 753bf215546Sopenharmony_ci const struct panvk_pipeline *pipeline; 754bf215546Sopenharmony_ci}; 755bf215546Sopenharmony_ci 756bf215546Sopenharmony_cistruct panvk_cmd_buffer { 757bf215546Sopenharmony_ci struct vk_command_buffer vk; 758bf215546Sopenharmony_ci 759bf215546Sopenharmony_ci struct panvk_device *device; 760bf215546Sopenharmony_ci 761bf215546Sopenharmony_ci struct panvk_cmd_pool *pool; 762bf215546Sopenharmony_ci struct list_head pool_link; 763bf215546Sopenharmony_ci struct panvk_pool desc_pool; 764bf215546Sopenharmony_ci struct panvk_pool varying_pool; 765bf215546Sopenharmony_ci struct panvk_pool tls_pool; 766bf215546Sopenharmony_ci struct list_head batches; 767bf215546Sopenharmony_ci 768bf215546Sopenharmony_ci VkCommandBufferUsageFlags usage_flags; 769bf215546Sopenharmony_ci enum panvk_cmd_buffer_status status; 770bf215546Sopenharmony_ci 771bf215546Sopenharmony_ci struct panvk_cmd_state state; 772bf215546Sopenharmony_ci uint32_t queue_family_index; 773bf215546Sopenharmony_ci 774bf215546Sopenharmony_ci uint8_t push_constants[MAX_PUSH_CONSTANTS_SIZE]; 775bf215546Sopenharmony_ci VkShaderStageFlags push_constant_stages; 776bf215546Sopenharmony_ci struct panvk_descriptor_set meta_push_descriptors; 777bf215546Sopenharmony_ci 778bf215546Sopenharmony_ci struct panvk_cmd_bind_point_state bind_points[MAX_BIND_POINTS]; 779bf215546Sopenharmony_ci 780bf215546Sopenharmony_ci VkResult record_result; 781bf215546Sopenharmony_ci}; 782bf215546Sopenharmony_ci 783bf215546Sopenharmony_ci#define panvk_cmd_get_bind_point_state(cmdbuf, bindpoint) \ 784bf215546Sopenharmony_ci &(cmdbuf)->bind_points[VK_PIPELINE_BIND_POINT_ ## bindpoint] 785bf215546Sopenharmony_ci 786bf215546Sopenharmony_ci#define panvk_cmd_get_pipeline(cmdbuf, bindpoint) \ 787bf215546Sopenharmony_ci (cmdbuf)->bind_points[VK_PIPELINE_BIND_POINT_ ## bindpoint].pipeline 788bf215546Sopenharmony_ci 789bf215546Sopenharmony_ci#define panvk_cmd_get_desc_state(cmdbuf, bindpoint) \ 790bf215546Sopenharmony_ci &(cmdbuf)->bind_points[VK_PIPELINE_BIND_POINT_ ## bindpoint].desc_state 791bf215546Sopenharmony_ci 792bf215546Sopenharmony_cistruct panvk_batch * 793bf215546Sopenharmony_cipanvk_cmd_open_batch(struct panvk_cmd_buffer *cmdbuf); 794bf215546Sopenharmony_ci 795bf215546Sopenharmony_civoid 796bf215546Sopenharmony_cipanvk_cmd_fb_info_set_subpass(struct panvk_cmd_buffer *cmdbuf); 797bf215546Sopenharmony_ci 798bf215546Sopenharmony_civoid 799bf215546Sopenharmony_cipanvk_cmd_fb_info_init(struct panvk_cmd_buffer *cmdbuf); 800bf215546Sopenharmony_ci 801bf215546Sopenharmony_civoid 802bf215546Sopenharmony_cipanvk_cmd_preload_fb_after_batch_split(struct panvk_cmd_buffer *cmdbuf); 803bf215546Sopenharmony_ci 804bf215546Sopenharmony_civoid 805bf215546Sopenharmony_cipanvk_pack_color(struct panvk_clear_value *out, 806bf215546Sopenharmony_ci const VkClearColorValue *in, 807bf215546Sopenharmony_ci enum pipe_format format); 808bf215546Sopenharmony_ci 809bf215546Sopenharmony_cistruct panvk_event { 810bf215546Sopenharmony_ci struct vk_object_base base; 811bf215546Sopenharmony_ci uint32_t syncobj; 812bf215546Sopenharmony_ci}; 813bf215546Sopenharmony_ci 814bf215546Sopenharmony_cistruct panvk_shader { 815bf215546Sopenharmony_ci struct pan_shader_info info; 816bf215546Sopenharmony_ci struct util_dynarray binary; 817bf215546Sopenharmony_ci unsigned sysval_ubo; 818bf215546Sopenharmony_ci struct pan_compute_dim local_size; 819bf215546Sopenharmony_ci bool has_img_access; 820bf215546Sopenharmony_ci}; 821bf215546Sopenharmony_ci 822bf215546Sopenharmony_cistruct panvk_shader * 823bf215546Sopenharmony_cipanvk_shader_create(struct panvk_device *dev, 824bf215546Sopenharmony_ci gl_shader_stage stage, 825bf215546Sopenharmony_ci const VkPipelineShaderStageCreateInfo *stage_info, 826bf215546Sopenharmony_ci const struct panvk_pipeline_layout *layout, 827bf215546Sopenharmony_ci unsigned sysval_ubo, 828bf215546Sopenharmony_ci struct pan_blend_state *blend_state, 829bf215546Sopenharmony_ci bool static_blend_constants, 830bf215546Sopenharmony_ci const VkAllocationCallbacks *alloc); 831bf215546Sopenharmony_ci 832bf215546Sopenharmony_civoid 833bf215546Sopenharmony_cipanvk_shader_destroy(struct panvk_device *dev, 834bf215546Sopenharmony_ci struct panvk_shader *shader, 835bf215546Sopenharmony_ci const VkAllocationCallbacks *alloc); 836bf215546Sopenharmony_ci 837bf215546Sopenharmony_ci#define RSD_WORDS 16 838bf215546Sopenharmony_ci#define BLEND_DESC_WORDS 4 839bf215546Sopenharmony_ci 840bf215546Sopenharmony_cistruct panvk_pipeline { 841bf215546Sopenharmony_ci struct vk_object_base base; 842bf215546Sopenharmony_ci 843bf215546Sopenharmony_ci struct panvk_varyings_info varyings; 844bf215546Sopenharmony_ci struct panvk_attribs_info attribs; 845bf215546Sopenharmony_ci 846bf215546Sopenharmony_ci const struct panvk_pipeline_layout *layout; 847bf215546Sopenharmony_ci 848bf215546Sopenharmony_ci unsigned active_stages; 849bf215546Sopenharmony_ci 850bf215546Sopenharmony_ci uint32_t dynamic_state_mask; 851bf215546Sopenharmony_ci 852bf215546Sopenharmony_ci struct panfrost_bo *binary_bo; 853bf215546Sopenharmony_ci struct panfrost_bo *state_bo; 854bf215546Sopenharmony_ci 855bf215546Sopenharmony_ci mali_ptr vpd; 856bf215546Sopenharmony_ci mali_ptr rsds[MESA_SHADER_STAGES]; 857bf215546Sopenharmony_ci 858bf215546Sopenharmony_ci /* shader stage bit is set of the stage accesses storage images */ 859bf215546Sopenharmony_ci uint32_t img_access_mask; 860bf215546Sopenharmony_ci 861bf215546Sopenharmony_ci unsigned num_ubos; 862bf215546Sopenharmony_ci 863bf215546Sopenharmony_ci struct { 864bf215546Sopenharmony_ci unsigned ubo_idx; 865bf215546Sopenharmony_ci struct panfrost_sysvals ids; 866bf215546Sopenharmony_ci } sysvals[MESA_SHADER_STAGES]; 867bf215546Sopenharmony_ci 868bf215546Sopenharmony_ci unsigned tls_size; 869bf215546Sopenharmony_ci unsigned wls_size; 870bf215546Sopenharmony_ci 871bf215546Sopenharmony_ci struct { 872bf215546Sopenharmony_ci mali_ptr address; 873bf215546Sopenharmony_ci struct pan_shader_info info; 874bf215546Sopenharmony_ci uint32_t rsd_template[RSD_WORDS]; 875bf215546Sopenharmony_ci bool required; 876bf215546Sopenharmony_ci bool dynamic_rsd; 877bf215546Sopenharmony_ci uint8_t rt_mask; 878bf215546Sopenharmony_ci } fs; 879bf215546Sopenharmony_ci 880bf215546Sopenharmony_ci struct { 881bf215546Sopenharmony_ci struct pan_compute_dim local_size; 882bf215546Sopenharmony_ci } cs; 883bf215546Sopenharmony_ci 884bf215546Sopenharmony_ci struct { 885bf215546Sopenharmony_ci unsigned topology; 886bf215546Sopenharmony_ci bool writes_point_size; 887bf215546Sopenharmony_ci bool primitive_restart; 888bf215546Sopenharmony_ci } ia; 889bf215546Sopenharmony_ci 890bf215546Sopenharmony_ci struct { 891bf215546Sopenharmony_ci bool clamp_depth; 892bf215546Sopenharmony_ci float line_width; 893bf215546Sopenharmony_ci struct { 894bf215546Sopenharmony_ci bool enable; 895bf215546Sopenharmony_ci float constant_factor; 896bf215546Sopenharmony_ci float clamp; 897bf215546Sopenharmony_ci float slope_factor; 898bf215546Sopenharmony_ci } depth_bias; 899bf215546Sopenharmony_ci bool front_ccw; 900bf215546Sopenharmony_ci bool cull_front_face; 901bf215546Sopenharmony_ci bool cull_back_face; 902bf215546Sopenharmony_ci bool enable; 903bf215546Sopenharmony_ci } rast; 904bf215546Sopenharmony_ci 905bf215546Sopenharmony_ci struct { 906bf215546Sopenharmony_ci bool z_test; 907bf215546Sopenharmony_ci bool z_write; 908bf215546Sopenharmony_ci unsigned z_compare_func; 909bf215546Sopenharmony_ci bool s_test; 910bf215546Sopenharmony_ci struct { 911bf215546Sopenharmony_ci unsigned fail_op; 912bf215546Sopenharmony_ci unsigned pass_op; 913bf215546Sopenharmony_ci unsigned z_fail_op; 914bf215546Sopenharmony_ci unsigned compare_func; 915bf215546Sopenharmony_ci uint8_t compare_mask; 916bf215546Sopenharmony_ci uint8_t write_mask; 917bf215546Sopenharmony_ci uint8_t ref; 918bf215546Sopenharmony_ci } s_front, s_back; 919bf215546Sopenharmony_ci } zs; 920bf215546Sopenharmony_ci 921bf215546Sopenharmony_ci struct { 922bf215546Sopenharmony_ci uint8_t rast_samples; 923bf215546Sopenharmony_ci uint8_t min_samples; 924bf215546Sopenharmony_ci uint16_t sample_mask; 925bf215546Sopenharmony_ci bool alpha_to_coverage; 926bf215546Sopenharmony_ci bool alpha_to_one; 927bf215546Sopenharmony_ci } ms; 928bf215546Sopenharmony_ci 929bf215546Sopenharmony_ci struct { 930bf215546Sopenharmony_ci struct pan_blend_state state; 931bf215546Sopenharmony_ci uint32_t bd_template[8][BLEND_DESC_WORDS]; 932bf215546Sopenharmony_ci struct { 933bf215546Sopenharmony_ci uint8_t index; 934bf215546Sopenharmony_ci uint16_t bifrost_factor; 935bf215546Sopenharmony_ci } constant[8]; 936bf215546Sopenharmony_ci bool reads_dest; 937bf215546Sopenharmony_ci } blend; 938bf215546Sopenharmony_ci 939bf215546Sopenharmony_ci VkViewport viewport; 940bf215546Sopenharmony_ci VkRect2D scissor; 941bf215546Sopenharmony_ci}; 942bf215546Sopenharmony_ci 943bf215546Sopenharmony_ci#define PANVK_MAX_PLANES 1 944bf215546Sopenharmony_ci 945bf215546Sopenharmony_cistruct panvk_image { 946bf215546Sopenharmony_ci struct vk_image vk; 947bf215546Sopenharmony_ci 948bf215546Sopenharmony_ci struct pan_image pimage; 949bf215546Sopenharmony_ci}; 950bf215546Sopenharmony_ci 951bf215546Sopenharmony_ciunsigned 952bf215546Sopenharmony_cipanvk_image_get_plane_size(const struct panvk_image *image, unsigned plane); 953bf215546Sopenharmony_ci 954bf215546Sopenharmony_ciunsigned 955bf215546Sopenharmony_cipanvk_image_get_total_size(const struct panvk_image *image); 956bf215546Sopenharmony_ci 957bf215546Sopenharmony_ci#define TEXTURE_DESC_WORDS 8 958bf215546Sopenharmony_ci#define ATTRIB_BUF_DESC_WORDS 4 959bf215546Sopenharmony_ci 960bf215546Sopenharmony_cistruct panvk_image_view { 961bf215546Sopenharmony_ci struct vk_image_view vk; 962bf215546Sopenharmony_ci 963bf215546Sopenharmony_ci struct pan_image_view pview; 964bf215546Sopenharmony_ci 965bf215546Sopenharmony_ci struct panfrost_bo *bo; 966bf215546Sopenharmony_ci struct { 967bf215546Sopenharmony_ci uint32_t tex[TEXTURE_DESC_WORDS]; 968bf215546Sopenharmony_ci uint32_t img_attrib_buf[ATTRIB_BUF_DESC_WORDS * 2]; 969bf215546Sopenharmony_ci } descs; 970bf215546Sopenharmony_ci}; 971bf215546Sopenharmony_ci 972bf215546Sopenharmony_ci#define SAMPLER_DESC_WORDS 8 973bf215546Sopenharmony_ci 974bf215546Sopenharmony_cistruct panvk_sampler { 975bf215546Sopenharmony_ci struct vk_object_base base; 976bf215546Sopenharmony_ci uint32_t desc[SAMPLER_DESC_WORDS]; 977bf215546Sopenharmony_ci}; 978bf215546Sopenharmony_ci 979bf215546Sopenharmony_cistruct panvk_buffer_view { 980bf215546Sopenharmony_ci struct vk_object_base base; 981bf215546Sopenharmony_ci struct panfrost_bo *bo; 982bf215546Sopenharmony_ci struct { 983bf215546Sopenharmony_ci uint32_t tex[TEXTURE_DESC_WORDS]; 984bf215546Sopenharmony_ci uint32_t img_attrib_buf[ATTRIB_BUF_DESC_WORDS * 2]; 985bf215546Sopenharmony_ci } descs; 986bf215546Sopenharmony_ci enum pipe_format fmt; 987bf215546Sopenharmony_ci uint32_t elems; 988bf215546Sopenharmony_ci}; 989bf215546Sopenharmony_ci 990bf215546Sopenharmony_cistruct panvk_attachment_info { 991bf215546Sopenharmony_ci struct panvk_image_view *iview; 992bf215546Sopenharmony_ci}; 993bf215546Sopenharmony_ci 994bf215546Sopenharmony_cistruct panvk_framebuffer { 995bf215546Sopenharmony_ci struct vk_object_base base; 996bf215546Sopenharmony_ci 997bf215546Sopenharmony_ci uint32_t width; 998bf215546Sopenharmony_ci uint32_t height; 999bf215546Sopenharmony_ci uint32_t layers; 1000bf215546Sopenharmony_ci 1001bf215546Sopenharmony_ci uint32_t attachment_count; 1002bf215546Sopenharmony_ci struct panvk_attachment_info attachments[0]; 1003bf215546Sopenharmony_ci}; 1004bf215546Sopenharmony_ci 1005bf215546Sopenharmony_cistruct panvk_clear_value { 1006bf215546Sopenharmony_ci union { 1007bf215546Sopenharmony_ci uint32_t color[4]; 1008bf215546Sopenharmony_ci struct { 1009bf215546Sopenharmony_ci float depth; 1010bf215546Sopenharmony_ci uint8_t stencil; 1011bf215546Sopenharmony_ci }; 1012bf215546Sopenharmony_ci }; 1013bf215546Sopenharmony_ci}; 1014bf215546Sopenharmony_ci 1015bf215546Sopenharmony_cistruct panvk_subpass_attachment { 1016bf215546Sopenharmony_ci uint32_t idx; 1017bf215546Sopenharmony_ci VkImageLayout layout; 1018bf215546Sopenharmony_ci bool clear; 1019bf215546Sopenharmony_ci bool preload; 1020bf215546Sopenharmony_ci}; 1021bf215546Sopenharmony_ci 1022bf215546Sopenharmony_cistruct panvk_subpass { 1023bf215546Sopenharmony_ci uint32_t input_count; 1024bf215546Sopenharmony_ci uint32_t color_count; 1025bf215546Sopenharmony_ci struct panvk_subpass_attachment *input_attachments; 1026bf215546Sopenharmony_ci uint8_t active_color_attachments; 1027bf215546Sopenharmony_ci struct panvk_subpass_attachment *color_attachments; 1028bf215546Sopenharmony_ci struct panvk_subpass_attachment *resolve_attachments; 1029bf215546Sopenharmony_ci struct panvk_subpass_attachment zs_attachment; 1030bf215546Sopenharmony_ci 1031bf215546Sopenharmony_ci uint32_t view_mask; 1032bf215546Sopenharmony_ci}; 1033bf215546Sopenharmony_ci 1034bf215546Sopenharmony_cistruct panvk_render_pass_attachment { 1035bf215546Sopenharmony_ci VkAttachmentDescriptionFlags flags; 1036bf215546Sopenharmony_ci enum pipe_format format; 1037bf215546Sopenharmony_ci unsigned samples; 1038bf215546Sopenharmony_ci VkAttachmentLoadOp load_op; 1039bf215546Sopenharmony_ci VkAttachmentStoreOp store_op; 1040bf215546Sopenharmony_ci VkAttachmentLoadOp stencil_load_op; 1041bf215546Sopenharmony_ci VkAttachmentStoreOp stencil_store_op; 1042bf215546Sopenharmony_ci VkImageLayout initial_layout; 1043bf215546Sopenharmony_ci VkImageLayout final_layout; 1044bf215546Sopenharmony_ci unsigned view_mask; 1045bf215546Sopenharmony_ci unsigned first_used_in_subpass; 1046bf215546Sopenharmony_ci}; 1047bf215546Sopenharmony_ci 1048bf215546Sopenharmony_cistruct panvk_render_pass { 1049bf215546Sopenharmony_ci struct vk_object_base base; 1050bf215546Sopenharmony_ci 1051bf215546Sopenharmony_ci uint32_t attachment_count; 1052bf215546Sopenharmony_ci uint32_t subpass_count; 1053bf215546Sopenharmony_ci struct panvk_subpass_attachment *subpass_attachments; 1054bf215546Sopenharmony_ci struct panvk_render_pass_attachment *attachments; 1055bf215546Sopenharmony_ci struct panvk_subpass subpasses[0]; 1056bf215546Sopenharmony_ci}; 1057bf215546Sopenharmony_ci 1058bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(panvk_cmd_buffer, vk.base, VkCommandBuffer, VK_OBJECT_TYPE_COMMAND_BUFFER) 1059bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(panvk_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE) 1060bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(panvk_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE) 1061bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(panvk_physical_device, vk.base, VkPhysicalDevice, VK_OBJECT_TYPE_PHYSICAL_DEVICE) 1062bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(panvk_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE) 1063bf215546Sopenharmony_ci 1064bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_cmd_pool, vk.base, VkCommandPool, VK_OBJECT_TYPE_COMMAND_POOL) 1065bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_buffer, vk.base, VkBuffer, VK_OBJECT_TYPE_BUFFER) 1066bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_buffer_view, base, VkBufferView, VK_OBJECT_TYPE_BUFFER_VIEW) 1067bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_pool, base, VkDescriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL) 1068bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_set, base, VkDescriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET) 1069bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_set_layout, vk.base, 1070bf215546Sopenharmony_ci VkDescriptorSetLayout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT) 1071bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_device_memory, base, VkDeviceMemory, VK_OBJECT_TYPE_DEVICE_MEMORY) 1072bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_event, base, VkEvent, VK_OBJECT_TYPE_EVENT) 1073bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_framebuffer, base, VkFramebuffer, VK_OBJECT_TYPE_FRAMEBUFFER) 1074bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE) 1075bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image_view, vk.base, VkImageView, VK_OBJECT_TYPE_IMAGE_VIEW); 1076bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_cache, base, VkPipelineCache, VK_OBJECT_TYPE_PIPELINE_CACHE) 1077bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline, base, VkPipeline, VK_OBJECT_TYPE_PIPELINE) 1078bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_layout, vk.base, VkPipelineLayout, VK_OBJECT_TYPE_PIPELINE_LAYOUT) 1079bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_render_pass, base, VkRenderPass, VK_OBJECT_TYPE_RENDER_PASS) 1080bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(panvk_sampler, base, VkSampler, VK_OBJECT_TYPE_SAMPLER) 1081bf215546Sopenharmony_ci 1082bf215546Sopenharmony_ci#define panvk_arch_name(name, version) panvk_## version ## _ ## name 1083bf215546Sopenharmony_ci 1084bf215546Sopenharmony_ci#define panvk_arch_dispatch(arch, name, ...) \ 1085bf215546Sopenharmony_cido { \ 1086bf215546Sopenharmony_ci switch (arch) { \ 1087bf215546Sopenharmony_ci case 6: panvk_arch_name(name, v6)(__VA_ARGS__); break; \ 1088bf215546Sopenharmony_ci case 7: panvk_arch_name(name, v7)(__VA_ARGS__); break; \ 1089bf215546Sopenharmony_ci default: unreachable("Invalid arch"); \ 1090bf215546Sopenharmony_ci } \ 1091bf215546Sopenharmony_ci} while (0) 1092bf215546Sopenharmony_ci 1093bf215546Sopenharmony_ci#ifdef PAN_ARCH 1094bf215546Sopenharmony_ci#if PAN_ARCH == 6 1095bf215546Sopenharmony_ci#define panvk_per_arch(name) panvk_arch_name(name, v6) 1096bf215546Sopenharmony_ci#elif PAN_ARCH == 7 1097bf215546Sopenharmony_ci#define panvk_per_arch(name) panvk_arch_name(name, v7) 1098bf215546Sopenharmony_ci#endif 1099bf215546Sopenharmony_ci#include "panvk_vX_cmd_buffer.h" 1100bf215546Sopenharmony_ci#include "panvk_vX_cs.h" 1101bf215546Sopenharmony_ci#include "panvk_vX_device.h" 1102bf215546Sopenharmony_ci#include "panvk_vX_meta.h" 1103bf215546Sopenharmony_ci#else 1104bf215546Sopenharmony_ci#define PAN_ARCH 6 1105bf215546Sopenharmony_ci#define panvk_per_arch(name) panvk_arch_name(name, v6) 1106bf215546Sopenharmony_ci#include "panvk_vX_cmd_buffer.h" 1107bf215546Sopenharmony_ci#include "panvk_vX_cs.h" 1108bf215546Sopenharmony_ci#include "panvk_vX_device.h" 1109bf215546Sopenharmony_ci#include "panvk_vX_meta.h" 1110bf215546Sopenharmony_ci#undef PAN_ARCH 1111bf215546Sopenharmony_ci#undef panvk_per_arch 1112bf215546Sopenharmony_ci#define PAN_ARCH 7 1113bf215546Sopenharmony_ci#define panvk_per_arch(name) panvk_arch_name(name, v7) 1114bf215546Sopenharmony_ci#include "panvk_vX_cmd_buffer.h" 1115bf215546Sopenharmony_ci#include "panvk_vX_cs.h" 1116bf215546Sopenharmony_ci#include "panvk_vX_device.h" 1117bf215546Sopenharmony_ci#include "panvk_vX_meta.h" 1118bf215546Sopenharmony_ci#undef PAN_ARCH 1119bf215546Sopenharmony_ci#undef panvk_per_arch 1120bf215546Sopenharmony_ci#endif 1121bf215546Sopenharmony_ci 1122bf215546Sopenharmony_ci#ifdef PAN_ARCH 1123bf215546Sopenharmony_cibool 1124bf215546Sopenharmony_cipanvk_per_arch(blend_needs_lowering)(const struct panfrost_device *dev, 1125bf215546Sopenharmony_ci const struct pan_blend_state *state, 1126bf215546Sopenharmony_ci unsigned rt); 1127bf215546Sopenharmony_ci 1128bf215546Sopenharmony_cistruct panvk_shader * 1129bf215546Sopenharmony_cipanvk_per_arch(shader_create)(struct panvk_device *dev, 1130bf215546Sopenharmony_ci gl_shader_stage stage, 1131bf215546Sopenharmony_ci const VkPipelineShaderStageCreateInfo *stage_info, 1132bf215546Sopenharmony_ci const struct panvk_pipeline_layout *layout, 1133bf215546Sopenharmony_ci unsigned sysval_ubo, 1134bf215546Sopenharmony_ci struct pan_blend_state *blend_state, 1135bf215546Sopenharmony_ci bool static_blend_constants, 1136bf215546Sopenharmony_ci const VkAllocationCallbacks *alloc); 1137bf215546Sopenharmony_cistruct nir_shader; 1138bf215546Sopenharmony_ci 1139bf215546Sopenharmony_cibool 1140bf215546Sopenharmony_cipanvk_per_arch(nir_lower_descriptors)(struct nir_shader *nir, 1141bf215546Sopenharmony_ci struct panvk_device *dev, 1142bf215546Sopenharmony_ci const struct panvk_pipeline_layout *layout, 1143bf215546Sopenharmony_ci bool *has_img_access_out); 1144bf215546Sopenharmony_ci#endif 1145bf215546Sopenharmony_ci 1146bf215546Sopenharmony_ci#endif /* PANVK_PRIVATE_H */ 1147