1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2022 Imagination Technologies Ltd. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * based in part on anv driver which is: 5bf215546Sopenharmony_ci * Copyright © 2015 Intel Corporation 6bf215546Sopenharmony_ci * 7bf215546Sopenharmony_ci * based in part on radv driver which is: 8bf215546Sopenharmony_ci * Copyright © 2016 Red Hat. 9bf215546Sopenharmony_ci * Copyright © 2016 Bas Nieuwenhuizen 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 12bf215546Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal 13bf215546Sopenharmony_ci * in the Software without restriction, including without limitation the rights 14bf215546Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15bf215546Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is 16bf215546Sopenharmony_ci * furnished to do so, subject to the following conditions: 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 19bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 20bf215546Sopenharmony_ci * Software. 21bf215546Sopenharmony_ci * 22bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25bf215546Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28bf215546Sopenharmony_ci * SOFTWARE. 29bf215546Sopenharmony_ci */ 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#ifndef PVR_PRIVATE_H 32bf215546Sopenharmony_ci#define PVR_PRIVATE_H 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#include <assert.h> 35bf215546Sopenharmony_ci#include <stdbool.h> 36bf215546Sopenharmony_ci#include <stdint.h> 37bf215546Sopenharmony_ci#include <vulkan/vulkan.h> 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci#include "compiler/shader_enums.h" 40bf215546Sopenharmony_ci#include "hwdef/rogue_hw_defs.h" 41bf215546Sopenharmony_ci#include "pvr_csb.h" 42bf215546Sopenharmony_ci#include "pvr_device_info.h" 43bf215546Sopenharmony_ci#include "pvr_entrypoints.h" 44bf215546Sopenharmony_ci#include "pvr_hw_pass.h" 45bf215546Sopenharmony_ci#include "pvr_job_render.h" 46bf215546Sopenharmony_ci#include "pvr_limits.h" 47bf215546Sopenharmony_ci#include "pvr_pds.h" 48bf215546Sopenharmony_ci#include "pvr_types.h" 49bf215546Sopenharmony_ci#include "pvr_winsys.h" 50bf215546Sopenharmony_ci#include "rogue/rogue.h" 51bf215546Sopenharmony_ci#include "util/bitscan.h" 52bf215546Sopenharmony_ci#include "util/format/u_format.h" 53bf215546Sopenharmony_ci#include "util/log.h" 54bf215546Sopenharmony_ci#include "util/macros.h" 55bf215546Sopenharmony_ci#include "util/u_dynarray.h" 56bf215546Sopenharmony_ci#include "vk_buffer.h" 57bf215546Sopenharmony_ci#include "vk_command_buffer.h" 58bf215546Sopenharmony_ci#include "vk_device.h" 59bf215546Sopenharmony_ci#include "vk_image.h" 60bf215546Sopenharmony_ci#include "vk_instance.h" 61bf215546Sopenharmony_ci#include "vk_log.h" 62bf215546Sopenharmony_ci#include "vk_physical_device.h" 63bf215546Sopenharmony_ci#include "vk_queue.h" 64bf215546Sopenharmony_ci#include "vk_sync.h" 65bf215546Sopenharmony_ci#include "wsi_common.h" 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_ci#ifdef HAVE_VALGRIND 68bf215546Sopenharmony_ci# include <valgrind/valgrind.h> 69bf215546Sopenharmony_ci# include <valgrind/memcheck.h> 70bf215546Sopenharmony_ci# define VG(x) x 71bf215546Sopenharmony_ci#else 72bf215546Sopenharmony_ci# define VG(x) ((void)0) 73bf215546Sopenharmony_ci#endif 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_ci#define VK_VENDOR_ID_IMAGINATION 0x1010 76bf215546Sopenharmony_ci 77bf215546Sopenharmony_ci#define PVR_WORKGROUP_DIMENSIONS 3U 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_ci#define PVR_SAMPLER_DESCRIPTOR_SIZE 4U 80bf215546Sopenharmony_ci#define PVR_IMAGE_DESCRIPTOR_SIZE 4U 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ci#define PVR_STATE_PBE_DWORDS 2U 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ci#define PVR_PIPELINE_LAYOUT_SUPPORTED_DESCRIPTOR_TYPE_COUNT \ 85bf215546Sopenharmony_ci (uint32_t)(VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT + 1U) 86bf215546Sopenharmony_ci 87bf215546Sopenharmony_ci/* TODO: move into a common surface library? */ 88bf215546Sopenharmony_cienum pvr_memlayout { 89bf215546Sopenharmony_ci PVR_MEMLAYOUT_UNDEFINED = 0, /* explicitly treat 0 as undefined */ 90bf215546Sopenharmony_ci PVR_MEMLAYOUT_LINEAR, 91bf215546Sopenharmony_ci PVR_MEMLAYOUT_TWIDDLED, 92bf215546Sopenharmony_ci PVR_MEMLAYOUT_3DTWIDDLED, 93bf215546Sopenharmony_ci}; 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_cienum pvr_cmd_buffer_status { 96bf215546Sopenharmony_ci PVR_CMD_BUFFER_STATUS_INVALID = 0, /* explicitly treat 0 as invalid */ 97bf215546Sopenharmony_ci PVR_CMD_BUFFER_STATUS_INITIAL, 98bf215546Sopenharmony_ci PVR_CMD_BUFFER_STATUS_RECORDING, 99bf215546Sopenharmony_ci PVR_CMD_BUFFER_STATUS_EXECUTABLE, 100bf215546Sopenharmony_ci}; 101bf215546Sopenharmony_ci 102bf215546Sopenharmony_cienum pvr_texture_state { 103bf215546Sopenharmony_ci PVR_TEXTURE_STATE_SAMPLE, 104bf215546Sopenharmony_ci PVR_TEXTURE_STATE_STORAGE, 105bf215546Sopenharmony_ci PVR_TEXTURE_STATE_ATTACHMENT, 106bf215546Sopenharmony_ci PVR_TEXTURE_STATE_MAX_ENUM, 107bf215546Sopenharmony_ci}; 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_cienum pvr_sub_cmd_type { 110bf215546Sopenharmony_ci PVR_SUB_CMD_TYPE_INVALID = 0, /* explicitly treat 0 as invalid */ 111bf215546Sopenharmony_ci PVR_SUB_CMD_TYPE_GRAPHICS, 112bf215546Sopenharmony_ci PVR_SUB_CMD_TYPE_COMPUTE, 113bf215546Sopenharmony_ci PVR_SUB_CMD_TYPE_TRANSFER, 114bf215546Sopenharmony_ci}; 115bf215546Sopenharmony_ci 116bf215546Sopenharmony_cienum pvr_depth_stencil_usage { 117bf215546Sopenharmony_ci PVR_DEPTH_STENCIL_USAGE_UNDEFINED = 0, /* explicitly treat 0 as undefined */ 118bf215546Sopenharmony_ci PVR_DEPTH_STENCIL_USAGE_NEEDED, 119bf215546Sopenharmony_ci PVR_DEPTH_STENCIL_USAGE_NEVER, 120bf215546Sopenharmony_ci}; 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_cienum pvr_job_type { 123bf215546Sopenharmony_ci PVR_JOB_TYPE_GEOM, 124bf215546Sopenharmony_ci PVR_JOB_TYPE_FRAG, 125bf215546Sopenharmony_ci PVR_JOB_TYPE_COMPUTE, 126bf215546Sopenharmony_ci PVR_JOB_TYPE_TRANSFER, 127bf215546Sopenharmony_ci PVR_JOB_TYPE_MAX 128bf215546Sopenharmony_ci}; 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_cienum pvr_pipeline_type { 131bf215546Sopenharmony_ci PVR_PIPELINE_TYPE_INVALID = 0, /* explicitly treat 0 as undefined */ 132bf215546Sopenharmony_ci PVR_PIPELINE_TYPE_GRAPHICS, 133bf215546Sopenharmony_ci PVR_PIPELINE_TYPE_COMPUTE, 134bf215546Sopenharmony_ci}; 135bf215546Sopenharmony_ci 136bf215546Sopenharmony_cienum pvr_pipeline_stage_bits { 137bf215546Sopenharmony_ci PVR_PIPELINE_STAGE_GEOM_BIT = BITFIELD_BIT(PVR_JOB_TYPE_GEOM), 138bf215546Sopenharmony_ci PVR_PIPELINE_STAGE_FRAG_BIT = BITFIELD_BIT(PVR_JOB_TYPE_FRAG), 139bf215546Sopenharmony_ci PVR_PIPELINE_STAGE_COMPUTE_BIT = BITFIELD_BIT(PVR_JOB_TYPE_COMPUTE), 140bf215546Sopenharmony_ci PVR_PIPELINE_STAGE_TRANSFER_BIT = BITFIELD_BIT(PVR_JOB_TYPE_TRANSFER), 141bf215546Sopenharmony_ci}; 142bf215546Sopenharmony_ci 143bf215546Sopenharmony_ci#define PVR_PIPELINE_STAGE_ALL_GRAPHICS_BITS \ 144bf215546Sopenharmony_ci (PVR_PIPELINE_STAGE_GEOM_BIT | PVR_PIPELINE_STAGE_FRAG_BIT) 145bf215546Sopenharmony_ci 146bf215546Sopenharmony_ci#define PVR_PIPELINE_STAGE_ALL_BITS \ 147bf215546Sopenharmony_ci (PVR_PIPELINE_STAGE_ALL_GRAPHICS_BITS | PVR_PIPELINE_STAGE_COMPUTE_BIT | \ 148bf215546Sopenharmony_ci PVR_PIPELINE_STAGE_TRANSFER_BIT) 149bf215546Sopenharmony_ci 150bf215546Sopenharmony_ci#define PVR_NUM_SYNC_PIPELINE_STAGES 4U 151bf215546Sopenharmony_ci 152bf215546Sopenharmony_ci/* Warning: Do not define an invalid stage as 0 since other code relies on 0 153bf215546Sopenharmony_ci * being the first shader stage. This allows for stages to be split or added 154bf215546Sopenharmony_ci * in the future. Defining 0 as invalid will very likely cause problems. 155bf215546Sopenharmony_ci */ 156bf215546Sopenharmony_cienum pvr_stage_allocation { 157bf215546Sopenharmony_ci PVR_STAGE_ALLOCATION_VERTEX_GEOMETRY, 158bf215546Sopenharmony_ci PVR_STAGE_ALLOCATION_FRAGMENT, 159bf215546Sopenharmony_ci PVR_STAGE_ALLOCATION_COMPUTE, 160bf215546Sopenharmony_ci PVR_STAGE_ALLOCATION_COUNT 161bf215546Sopenharmony_ci}; 162bf215546Sopenharmony_ci 163bf215546Sopenharmony_ci/* Scissor accumulation state defines 164bf215546Sopenharmony_ci * - Disabled means that a clear has been detected, and scissor accumulation 165bf215546Sopenharmony_ci * should stop. 166bf215546Sopenharmony_ci * - Check for clear is when there's no clear loadops, but there could be 167bf215546Sopenharmony_ci * another clear call that would be broken via scissoring 168bf215546Sopenharmony_ci * - Enabled means that a scissor has been set in the pipeline, and 169bf215546Sopenharmony_ci * accumulation can continue 170bf215546Sopenharmony_ci */ 171bf215546Sopenharmony_cienum pvr_scissor_accum_state { 172bf215546Sopenharmony_ci PVR_SCISSOR_ACCUM_INVALID = 0, /* Explicitly treat 0 as invalid */ 173bf215546Sopenharmony_ci PVR_SCISSOR_ACCUM_DISABLED, 174bf215546Sopenharmony_ci PVR_SCISSOR_ACCUM_CHECK_FOR_CLEAR, 175bf215546Sopenharmony_ci PVR_SCISSOR_ACCUM_ENABLED, 176bf215546Sopenharmony_ci}; 177bf215546Sopenharmony_ci 178bf215546Sopenharmony_cistruct pvr_bo; 179bf215546Sopenharmony_cistruct pvr_compute_ctx; 180bf215546Sopenharmony_cistruct pvr_compute_pipeline; 181bf215546Sopenharmony_cistruct pvr_free_list; 182bf215546Sopenharmony_cistruct pvr_graphics_pipeline; 183bf215546Sopenharmony_cistruct pvr_instance; 184bf215546Sopenharmony_cistruct pvr_render_ctx; 185bf215546Sopenharmony_cistruct rogue_compiler; 186bf215546Sopenharmony_ci 187bf215546Sopenharmony_cistruct pvr_physical_device { 188bf215546Sopenharmony_ci struct vk_physical_device vk; 189bf215546Sopenharmony_ci 190bf215546Sopenharmony_ci /* Back-pointer to instance */ 191bf215546Sopenharmony_ci struct pvr_instance *instance; 192bf215546Sopenharmony_ci 193bf215546Sopenharmony_ci char *name; 194bf215546Sopenharmony_ci int master_fd; 195bf215546Sopenharmony_ci int render_fd; 196bf215546Sopenharmony_ci char *master_path; 197bf215546Sopenharmony_ci char *render_path; 198bf215546Sopenharmony_ci 199bf215546Sopenharmony_ci struct pvr_winsys *ws; 200bf215546Sopenharmony_ci struct pvr_device_info dev_info; 201bf215546Sopenharmony_ci 202bf215546Sopenharmony_ci struct pvr_device_runtime_info dev_runtime_info; 203bf215546Sopenharmony_ci 204bf215546Sopenharmony_ci VkPhysicalDeviceMemoryProperties memory; 205bf215546Sopenharmony_ci 206bf215546Sopenharmony_ci uint8_t pipeline_cache_uuid[VK_UUID_SIZE]; 207bf215546Sopenharmony_ci 208bf215546Sopenharmony_ci struct wsi_device wsi_device; 209bf215546Sopenharmony_ci 210bf215546Sopenharmony_ci struct rogue_compiler *compiler; 211bf215546Sopenharmony_ci}; 212bf215546Sopenharmony_ci 213bf215546Sopenharmony_cistruct pvr_instance { 214bf215546Sopenharmony_ci struct vk_instance vk; 215bf215546Sopenharmony_ci 216bf215546Sopenharmony_ci int physical_devices_count; 217bf215546Sopenharmony_ci struct pvr_physical_device physical_device; 218bf215546Sopenharmony_ci}; 219bf215546Sopenharmony_ci 220bf215546Sopenharmony_cistruct pvr_queue { 221bf215546Sopenharmony_ci struct vk_queue vk; 222bf215546Sopenharmony_ci 223bf215546Sopenharmony_ci struct pvr_device *device; 224bf215546Sopenharmony_ci 225bf215546Sopenharmony_ci struct pvr_render_ctx *gfx_ctx; 226bf215546Sopenharmony_ci struct pvr_compute_ctx *compute_ctx; 227bf215546Sopenharmony_ci struct pvr_transfer_ctx *transfer_ctx; 228bf215546Sopenharmony_ci 229bf215546Sopenharmony_ci struct vk_sync *completion[PVR_JOB_TYPE_MAX]; 230bf215546Sopenharmony_ci}; 231bf215546Sopenharmony_ci 232bf215546Sopenharmony_cistruct pvr_vertex_binding { 233bf215546Sopenharmony_ci struct pvr_buffer *buffer; 234bf215546Sopenharmony_ci VkDeviceSize offset; 235bf215546Sopenharmony_ci}; 236bf215546Sopenharmony_ci 237bf215546Sopenharmony_cistruct pvr_pds_upload { 238bf215546Sopenharmony_ci struct pvr_bo *pvr_bo; 239bf215546Sopenharmony_ci /* Offset from the pds heap base address. */ 240bf215546Sopenharmony_ci uint32_t data_offset; 241bf215546Sopenharmony_ci /* Offset from the pds heap base address. */ 242bf215546Sopenharmony_ci uint32_t code_offset; 243bf215546Sopenharmony_ci 244bf215546Sopenharmony_ci /* data_size + code_size = program_size. */ 245bf215546Sopenharmony_ci uint32_t data_size; 246bf215546Sopenharmony_ci uint32_t code_size; 247bf215546Sopenharmony_ci}; 248bf215546Sopenharmony_ci 249bf215546Sopenharmony_cistruct pvr_device { 250bf215546Sopenharmony_ci struct vk_device vk; 251bf215546Sopenharmony_ci struct pvr_instance *instance; 252bf215546Sopenharmony_ci struct pvr_physical_device *pdevice; 253bf215546Sopenharmony_ci 254bf215546Sopenharmony_ci int master_fd; 255bf215546Sopenharmony_ci int render_fd; 256bf215546Sopenharmony_ci 257bf215546Sopenharmony_ci struct pvr_winsys *ws; 258bf215546Sopenharmony_ci struct pvr_winsys_heaps heaps; 259bf215546Sopenharmony_ci 260bf215546Sopenharmony_ci struct pvr_free_list *global_free_list; 261bf215546Sopenharmony_ci 262bf215546Sopenharmony_ci struct pvr_queue *queues; 263bf215546Sopenharmony_ci uint32_t queue_count; 264bf215546Sopenharmony_ci 265bf215546Sopenharmony_ci /* Running count of the number of job submissions across all queue. */ 266bf215546Sopenharmony_ci uint32_t global_queue_job_count; 267bf215546Sopenharmony_ci 268bf215546Sopenharmony_ci /* Running count of the number of presentations across all queues. */ 269bf215546Sopenharmony_ci uint32_t global_queue_present_count; 270bf215546Sopenharmony_ci 271bf215546Sopenharmony_ci uint32_t pixel_event_data_size_in_dwords; 272bf215546Sopenharmony_ci 273bf215546Sopenharmony_ci uint64_t input_attachment_sampler; 274bf215546Sopenharmony_ci 275bf215546Sopenharmony_ci struct pvr_pds_upload pds_compute_fence_program; 276bf215546Sopenharmony_ci 277bf215546Sopenharmony_ci struct { 278bf215546Sopenharmony_ci struct pvr_pds_upload pds; 279bf215546Sopenharmony_ci struct pvr_bo *usc; 280bf215546Sopenharmony_ci } nop_program; 281bf215546Sopenharmony_ci 282bf215546Sopenharmony_ci /* Issue Data Fence, Wait for Data Fence state. */ 283bf215546Sopenharmony_ci struct { 284bf215546Sopenharmony_ci uint32_t usc_shareds; 285bf215546Sopenharmony_ci struct pvr_bo *usc; 286bf215546Sopenharmony_ci 287bf215546Sopenharmony_ci /* Buffer in which the IDF/WDF program performs store ops. */ 288bf215546Sopenharmony_ci struct pvr_bo *store_bo; 289bf215546Sopenharmony_ci /* Contains the initialization values for the shared registers. */ 290bf215546Sopenharmony_ci struct pvr_bo *shareds_bo; 291bf215546Sopenharmony_ci 292bf215546Sopenharmony_ci struct pvr_pds_upload pds; 293bf215546Sopenharmony_ci struct pvr_pds_upload sw_compute_barrier_pds; 294bf215546Sopenharmony_ci } idfwdf_state; 295bf215546Sopenharmony_ci 296bf215546Sopenharmony_ci VkPhysicalDeviceFeatures features; 297bf215546Sopenharmony_ci}; 298bf215546Sopenharmony_ci 299bf215546Sopenharmony_cistruct pvr_device_memory { 300bf215546Sopenharmony_ci struct vk_object_base base; 301bf215546Sopenharmony_ci struct pvr_winsys_bo *bo; 302bf215546Sopenharmony_ci}; 303bf215546Sopenharmony_ci 304bf215546Sopenharmony_cistruct pvr_mip_level { 305bf215546Sopenharmony_ci /* Offset of the mip level in bytes */ 306bf215546Sopenharmony_ci uint32_t offset; 307bf215546Sopenharmony_ci 308bf215546Sopenharmony_ci /* Aligned mip level size in bytes */ 309bf215546Sopenharmony_ci uint32_t size; 310bf215546Sopenharmony_ci 311bf215546Sopenharmony_ci /* Aligned row length in bytes */ 312bf215546Sopenharmony_ci uint32_t pitch; 313bf215546Sopenharmony_ci 314bf215546Sopenharmony_ci /* Aligned height in bytes */ 315bf215546Sopenharmony_ci uint32_t height_pitch; 316bf215546Sopenharmony_ci}; 317bf215546Sopenharmony_ci 318bf215546Sopenharmony_cistruct pvr_image { 319bf215546Sopenharmony_ci struct vk_image vk; 320bf215546Sopenharmony_ci 321bf215546Sopenharmony_ci /* vma this image is bound to */ 322bf215546Sopenharmony_ci struct pvr_winsys_vma *vma; 323bf215546Sopenharmony_ci 324bf215546Sopenharmony_ci /* Device address the image is mapped to in device virtual address space */ 325bf215546Sopenharmony_ci pvr_dev_addr_t dev_addr; 326bf215546Sopenharmony_ci 327bf215546Sopenharmony_ci /* Derived and other state */ 328bf215546Sopenharmony_ci VkExtent3D physical_extent; 329bf215546Sopenharmony_ci enum pvr_memlayout memlayout; 330bf215546Sopenharmony_ci VkDeviceSize layer_size; 331bf215546Sopenharmony_ci VkDeviceSize size; 332bf215546Sopenharmony_ci 333bf215546Sopenharmony_ci VkDeviceSize alignment; 334bf215546Sopenharmony_ci 335bf215546Sopenharmony_ci struct pvr_mip_level mip_levels[14]; 336bf215546Sopenharmony_ci}; 337bf215546Sopenharmony_ci 338bf215546Sopenharmony_cistruct pvr_buffer { 339bf215546Sopenharmony_ci struct vk_buffer vk; 340bf215546Sopenharmony_ci 341bf215546Sopenharmony_ci /* Derived and other state */ 342bf215546Sopenharmony_ci uint32_t alignment; 343bf215546Sopenharmony_ci /* vma this buffer is bound to */ 344bf215546Sopenharmony_ci struct pvr_winsys_vma *vma; 345bf215546Sopenharmony_ci /* Device address the buffer is mapped to in device virtual address space */ 346bf215546Sopenharmony_ci pvr_dev_addr_t dev_addr; 347bf215546Sopenharmony_ci}; 348bf215546Sopenharmony_ci 349bf215546Sopenharmony_cistruct pvr_image_view { 350bf215546Sopenharmony_ci struct vk_image_view vk; 351bf215546Sopenharmony_ci 352bf215546Sopenharmony_ci /* Saved information from pCreateInfo. */ 353bf215546Sopenharmony_ci const struct pvr_image *image; 354bf215546Sopenharmony_ci 355bf215546Sopenharmony_ci /* Prepacked Texture Image dword 0 and 1. It will be copied to the 356bf215546Sopenharmony_ci * descriptor info during pvr_UpdateDescriptorSets(). 357bf215546Sopenharmony_ci * 358bf215546Sopenharmony_ci * We create separate texture states for sampling, storage and input 359bf215546Sopenharmony_ci * attachment cases. 360bf215546Sopenharmony_ci */ 361bf215546Sopenharmony_ci uint64_t texture_state[PVR_TEXTURE_STATE_MAX_ENUM][2]; 362bf215546Sopenharmony_ci}; 363bf215546Sopenharmony_ci 364bf215546Sopenharmony_cistruct pvr_buffer_view { 365bf215546Sopenharmony_ci struct vk_object_base base; 366bf215546Sopenharmony_ci 367bf215546Sopenharmony_ci uint64_t range; 368bf215546Sopenharmony_ci VkFormat format; 369bf215546Sopenharmony_ci 370bf215546Sopenharmony_ci /* Prepacked Texture dword 0 and 1. It will be copied to the descriptor 371bf215546Sopenharmony_ci * during pvr_UpdateDescriptorSets(). 372bf215546Sopenharmony_ci */ 373bf215546Sopenharmony_ci uint64_t texture_state[2]; 374bf215546Sopenharmony_ci}; 375bf215546Sopenharmony_ci 376bf215546Sopenharmony_ciunion pvr_sampler_descriptor { 377bf215546Sopenharmony_ci uint32_t words[PVR_SAMPLER_DESCRIPTOR_SIZE]; 378bf215546Sopenharmony_ci 379bf215546Sopenharmony_ci struct { 380bf215546Sopenharmony_ci /* Packed PVRX(TEXSTATE_SAMPLER). */ 381bf215546Sopenharmony_ci uint64_t sampler_word; 382bf215546Sopenharmony_ci uint32_t compare_op; 383bf215546Sopenharmony_ci /* TODO: Figure out what this word is for and rename. 384bf215546Sopenharmony_ci * Sampler state word 1? 385bf215546Sopenharmony_ci */ 386bf215546Sopenharmony_ci uint32_t word3; 387bf215546Sopenharmony_ci } data; 388bf215546Sopenharmony_ci}; 389bf215546Sopenharmony_ci 390bf215546Sopenharmony_cistruct pvr_sampler { 391bf215546Sopenharmony_ci struct vk_object_base base; 392bf215546Sopenharmony_ci 393bf215546Sopenharmony_ci union pvr_sampler_descriptor descriptor; 394bf215546Sopenharmony_ci}; 395bf215546Sopenharmony_ci 396bf215546Sopenharmony_cistruct pvr_descriptor_size_info { 397bf215546Sopenharmony_ci /* Non-spillable size for storage in the common store. */ 398bf215546Sopenharmony_ci uint32_t primary; 399bf215546Sopenharmony_ci 400bf215546Sopenharmony_ci /* Spillable size to accommodate limitation of the common store. */ 401bf215546Sopenharmony_ci uint32_t secondary; 402bf215546Sopenharmony_ci 403bf215546Sopenharmony_ci uint32_t alignment; 404bf215546Sopenharmony_ci}; 405bf215546Sopenharmony_ci 406bf215546Sopenharmony_cistruct pvr_descriptor_set_layout_binding { 407bf215546Sopenharmony_ci VkDescriptorType type; 408bf215546Sopenharmony_ci 409bf215546Sopenharmony_ci /* "M" in layout(set = N, binding = M) 410bf215546Sopenharmony_ci * Can be used to index bindings in the descriptor_set_layout. Not the 411bf215546Sopenharmony_ci * original user specified binding number as those might be non-contiguous. 412bf215546Sopenharmony_ci */ 413bf215546Sopenharmony_ci uint32_t binding_number; 414bf215546Sopenharmony_ci 415bf215546Sopenharmony_ci uint32_t descriptor_count; 416bf215546Sopenharmony_ci 417bf215546Sopenharmony_ci /* Index into the flattened descriptor set */ 418bf215546Sopenharmony_ci uint16_t descriptor_index; 419bf215546Sopenharmony_ci 420bf215546Sopenharmony_ci VkShaderStageFlags shader_stages; 421bf215546Sopenharmony_ci /* Mask composed by shifted PVR_STAGE_ALLOCATION_... 422bf215546Sopenharmony_ci * Makes it easier to check active shader stages by just shifting and 423bf215546Sopenharmony_ci * ANDing instead of using VkShaderStageFlags and match the PVR_STAGE_... 424bf215546Sopenharmony_ci */ 425bf215546Sopenharmony_ci uint32_t shader_stage_mask; 426bf215546Sopenharmony_ci 427bf215546Sopenharmony_ci struct { 428bf215546Sopenharmony_ci uint32_t primary; 429bf215546Sopenharmony_ci uint32_t secondary; 430bf215546Sopenharmony_ci } per_stage_offset_in_dwords[PVR_STAGE_ALLOCATION_COUNT]; 431bf215546Sopenharmony_ci 432bf215546Sopenharmony_ci bool has_immutable_samplers; 433bf215546Sopenharmony_ci /* Index at which the samplers can be found in the descriptor_set_layout. 434bf215546Sopenharmony_ci * 0 when the samplers are at index 0 or no samplers are present. 435bf215546Sopenharmony_ci */ 436bf215546Sopenharmony_ci uint32_t immutable_samplers_index; 437bf215546Sopenharmony_ci}; 438bf215546Sopenharmony_ci 439bf215546Sopenharmony_ci/* All sizes are in dwords. */ 440bf215546Sopenharmony_cistruct pvr_descriptor_set_layout_mem_layout { 441bf215546Sopenharmony_ci uint32_t primary_offset; 442bf215546Sopenharmony_ci uint32_t primary_size; 443bf215546Sopenharmony_ci 444bf215546Sopenharmony_ci uint32_t secondary_offset; 445bf215546Sopenharmony_ci uint32_t secondary_size; 446bf215546Sopenharmony_ci 447bf215546Sopenharmony_ci uint32_t primary_dynamic_size; 448bf215546Sopenharmony_ci uint32_t secondary_dynamic_size; 449bf215546Sopenharmony_ci}; 450bf215546Sopenharmony_ci 451bf215546Sopenharmony_cistruct pvr_descriptor_set_layout { 452bf215546Sopenharmony_ci struct vk_object_base base; 453bf215546Sopenharmony_ci 454bf215546Sopenharmony_ci /* Total amount of descriptors contained in this set. */ 455bf215546Sopenharmony_ci uint32_t descriptor_count; 456bf215546Sopenharmony_ci 457bf215546Sopenharmony_ci /* Count of dynamic buffers. */ 458bf215546Sopenharmony_ci uint32_t dynamic_buffer_count; 459bf215546Sopenharmony_ci 460bf215546Sopenharmony_ci uint32_t binding_count; 461bf215546Sopenharmony_ci struct pvr_descriptor_set_layout_binding *bindings; 462bf215546Sopenharmony_ci 463bf215546Sopenharmony_ci uint32_t immutable_sampler_count; 464bf215546Sopenharmony_ci const struct pvr_sampler **immutable_samplers; 465bf215546Sopenharmony_ci 466bf215546Sopenharmony_ci /* Shader stages requiring access to descriptors in this set. */ 467bf215546Sopenharmony_ci VkShaderStageFlags shader_stages; 468bf215546Sopenharmony_ci 469bf215546Sopenharmony_ci /* Count of each VkDescriptorType per shader stage. Dynamically allocated 470bf215546Sopenharmony_ci * arrays per stage as to not hard code the max descriptor type here. 471bf215546Sopenharmony_ci * 472bf215546Sopenharmony_ci * Note: when adding a new type, it might not numerically follow the 473bf215546Sopenharmony_ci * previous type so a sparse array will be created. You might want to 474bf215546Sopenharmony_ci * readjust how these arrays are created and accessed. 475bf215546Sopenharmony_ci */ 476bf215546Sopenharmony_ci uint32_t *per_stage_descriptor_count[PVR_STAGE_ALLOCATION_COUNT]; 477bf215546Sopenharmony_ci 478bf215546Sopenharmony_ci uint32_t total_size_in_dwords; 479bf215546Sopenharmony_ci struct pvr_descriptor_set_layout_mem_layout 480bf215546Sopenharmony_ci memory_layout_in_dwords_per_stage[PVR_STAGE_ALLOCATION_COUNT]; 481bf215546Sopenharmony_ci}; 482bf215546Sopenharmony_ci 483bf215546Sopenharmony_cistruct pvr_descriptor_pool { 484bf215546Sopenharmony_ci struct vk_object_base base; 485bf215546Sopenharmony_ci 486bf215546Sopenharmony_ci VkAllocationCallbacks alloc; 487bf215546Sopenharmony_ci 488bf215546Sopenharmony_ci /* Saved information from pCreateInfo. */ 489bf215546Sopenharmony_ci uint32_t max_sets; 490bf215546Sopenharmony_ci 491bf215546Sopenharmony_ci uint32_t total_size_in_dwords; 492bf215546Sopenharmony_ci uint32_t current_size_in_dwords; 493bf215546Sopenharmony_ci 494bf215546Sopenharmony_ci /* Derived and other state. */ 495bf215546Sopenharmony_ci /* List of the descriptor sets created using this pool. */ 496bf215546Sopenharmony_ci struct list_head descriptor_sets; 497bf215546Sopenharmony_ci}; 498bf215546Sopenharmony_ci 499bf215546Sopenharmony_cistruct pvr_descriptor { 500bf215546Sopenharmony_ci VkDescriptorType type; 501bf215546Sopenharmony_ci 502bf215546Sopenharmony_ci union { 503bf215546Sopenharmony_ci struct { 504bf215546Sopenharmony_ci struct pvr_buffer_view *bview; 505bf215546Sopenharmony_ci pvr_dev_addr_t buffer_dev_addr; 506bf215546Sopenharmony_ci VkDeviceSize buffer_desc_range; 507bf215546Sopenharmony_ci VkDeviceSize buffer_create_info_size; 508bf215546Sopenharmony_ci }; 509bf215546Sopenharmony_ci 510bf215546Sopenharmony_ci struct { 511bf215546Sopenharmony_ci VkImageLayout layout; 512bf215546Sopenharmony_ci const struct pvr_image_view *iview; 513bf215546Sopenharmony_ci const struct pvr_sampler *sampler; 514bf215546Sopenharmony_ci }; 515bf215546Sopenharmony_ci }; 516bf215546Sopenharmony_ci}; 517bf215546Sopenharmony_ci 518bf215546Sopenharmony_cistruct pvr_descriptor_set { 519bf215546Sopenharmony_ci struct vk_object_base base; 520bf215546Sopenharmony_ci 521bf215546Sopenharmony_ci const struct pvr_descriptor_set_layout *layout; 522bf215546Sopenharmony_ci const struct pvr_descriptor_pool *pool; 523bf215546Sopenharmony_ci 524bf215546Sopenharmony_ci struct pvr_bo *pvr_bo; 525bf215546Sopenharmony_ci 526bf215546Sopenharmony_ci /* Links this descriptor set into pvr_descriptor_pool::descriptor_sets list. 527bf215546Sopenharmony_ci */ 528bf215546Sopenharmony_ci struct list_head link; 529bf215546Sopenharmony_ci 530bf215546Sopenharmony_ci /* Array of size layout::descriptor_count. */ 531bf215546Sopenharmony_ci struct pvr_descriptor descriptors[0]; 532bf215546Sopenharmony_ci}; 533bf215546Sopenharmony_ci 534bf215546Sopenharmony_cistruct pvr_descriptor_state { 535bf215546Sopenharmony_ci struct pvr_descriptor_set *descriptor_sets[PVR_MAX_DESCRIPTOR_SETS]; 536bf215546Sopenharmony_ci uint32_t valid_mask; 537bf215546Sopenharmony_ci}; 538bf215546Sopenharmony_ci 539bf215546Sopenharmony_cistruct pvr_transfer_cmd { 540bf215546Sopenharmony_ci /* Node to link this cmd into the transfer_cmds list in 541bf215546Sopenharmony_ci * pvr_sub_cmd::transfer structure. 542bf215546Sopenharmony_ci */ 543bf215546Sopenharmony_ci struct list_head link; 544bf215546Sopenharmony_ci 545bf215546Sopenharmony_ci struct pvr_buffer *src; 546bf215546Sopenharmony_ci struct pvr_buffer *dst; 547bf215546Sopenharmony_ci uint32_t region_count; 548bf215546Sopenharmony_ci VkBufferCopy2 regions[0]; 549bf215546Sopenharmony_ci}; 550bf215546Sopenharmony_ci 551bf215546Sopenharmony_cistruct pvr_sub_cmd_gfx { 552bf215546Sopenharmony_ci const struct pvr_framebuffer *framebuffer; 553bf215546Sopenharmony_ci 554bf215546Sopenharmony_ci struct pvr_render_job job; 555bf215546Sopenharmony_ci 556bf215546Sopenharmony_ci struct pvr_bo *depth_bias_bo; 557bf215546Sopenharmony_ci struct pvr_bo *scissor_bo; 558bf215546Sopenharmony_ci 559bf215546Sopenharmony_ci /* Tracking how the loaded depth/stencil values are being used. */ 560bf215546Sopenharmony_ci enum pvr_depth_stencil_usage depth_usage; 561bf215546Sopenharmony_ci enum pvr_depth_stencil_usage stencil_usage; 562bf215546Sopenharmony_ci 563bf215546Sopenharmony_ci /* Tracking whether the subcommand modifies depth/stencil. */ 564bf215546Sopenharmony_ci bool modifies_depth; 565bf215546Sopenharmony_ci bool modifies_stencil; 566bf215546Sopenharmony_ci 567bf215546Sopenharmony_ci /* Control stream builder object */ 568bf215546Sopenharmony_ci struct pvr_csb control_stream; 569bf215546Sopenharmony_ci 570bf215546Sopenharmony_ci uint32_t hw_render_idx; 571bf215546Sopenharmony_ci 572bf215546Sopenharmony_ci uint32_t max_tiles_in_flight; 573bf215546Sopenharmony_ci 574bf215546Sopenharmony_ci bool empty_cmd; 575bf215546Sopenharmony_ci 576bf215546Sopenharmony_ci /* True if any fragment shader used in this sub command uses atomic 577bf215546Sopenharmony_ci * operations. 578bf215546Sopenharmony_ci */ 579bf215546Sopenharmony_ci bool frag_uses_atomic_ops; 580bf215546Sopenharmony_ci 581bf215546Sopenharmony_ci bool disable_compute_overlap; 582bf215546Sopenharmony_ci 583bf215546Sopenharmony_ci /* True if any fragment shader used in this sub command has side 584bf215546Sopenharmony_ci * effects. 585bf215546Sopenharmony_ci */ 586bf215546Sopenharmony_ci bool frag_has_side_effects; 587bf215546Sopenharmony_ci 588bf215546Sopenharmony_ci /* True if any vertex shader used in this sub command contains both 589bf215546Sopenharmony_ci * texture reads and texture writes. 590bf215546Sopenharmony_ci */ 591bf215546Sopenharmony_ci bool vertex_uses_texture_rw; 592bf215546Sopenharmony_ci 593bf215546Sopenharmony_ci /* True if any fragment shader used in this sub command contains 594bf215546Sopenharmony_ci * both texture reads and texture writes. 595bf215546Sopenharmony_ci */ 596bf215546Sopenharmony_ci bool frag_uses_texture_rw; 597bf215546Sopenharmony_ci}; 598bf215546Sopenharmony_ci 599bf215546Sopenharmony_cistruct pvr_sub_cmd_compute { 600bf215546Sopenharmony_ci /* Control stream builder object. */ 601bf215546Sopenharmony_ci struct pvr_csb control_stream; 602bf215546Sopenharmony_ci 603bf215546Sopenharmony_ci struct pvr_winsys_compute_submit_info submit_info; 604bf215546Sopenharmony_ci 605bf215546Sopenharmony_ci uint32_t num_shared_regs; 606bf215546Sopenharmony_ci 607bf215546Sopenharmony_ci /* True if any shader used in this sub command uses atomic 608bf215546Sopenharmony_ci * operations. 609bf215546Sopenharmony_ci */ 610bf215546Sopenharmony_ci bool uses_atomic_ops; 611bf215546Sopenharmony_ci 612bf215546Sopenharmony_ci bool uses_barrier; 613bf215546Sopenharmony_ci 614bf215546Sopenharmony_ci bool pds_sw_barrier_requires_clearing; 615bf215546Sopenharmony_ci}; 616bf215546Sopenharmony_ci 617bf215546Sopenharmony_cistruct pvr_sub_cmd_transfer { 618bf215546Sopenharmony_ci /* List of pvr_transfer_cmd type structures. */ 619bf215546Sopenharmony_ci struct list_head transfer_cmds; 620bf215546Sopenharmony_ci}; 621bf215546Sopenharmony_ci 622bf215546Sopenharmony_cistruct pvr_sub_cmd { 623bf215546Sopenharmony_ci /* This links the subcommand in pvr_cmd_buffer:sub_cmds list. */ 624bf215546Sopenharmony_ci struct list_head link; 625bf215546Sopenharmony_ci 626bf215546Sopenharmony_ci enum pvr_sub_cmd_type type; 627bf215546Sopenharmony_ci 628bf215546Sopenharmony_ci union { 629bf215546Sopenharmony_ci struct pvr_sub_cmd_gfx gfx; 630bf215546Sopenharmony_ci struct pvr_sub_cmd_compute compute; 631bf215546Sopenharmony_ci struct pvr_sub_cmd_transfer transfer; 632bf215546Sopenharmony_ci }; 633bf215546Sopenharmony_ci}; 634bf215546Sopenharmony_ci 635bf215546Sopenharmony_cistruct pvr_render_pass_info { 636bf215546Sopenharmony_ci const struct pvr_render_pass *pass; 637bf215546Sopenharmony_ci struct pvr_framebuffer *framebuffer; 638bf215546Sopenharmony_ci 639bf215546Sopenharmony_ci struct pvr_image_view **attachments; 640bf215546Sopenharmony_ci 641bf215546Sopenharmony_ci uint32_t subpass_idx; 642bf215546Sopenharmony_ci uint32_t current_hw_subpass; 643bf215546Sopenharmony_ci 644bf215546Sopenharmony_ci VkRect2D render_area; 645bf215546Sopenharmony_ci 646bf215546Sopenharmony_ci uint32_t clear_value_count; 647bf215546Sopenharmony_ci VkClearValue *clear_values; 648bf215546Sopenharmony_ci 649bf215546Sopenharmony_ci VkPipelineBindPoint pipeline_bind_point; 650bf215546Sopenharmony_ci 651bf215546Sopenharmony_ci bool process_empty_tiles; 652bf215546Sopenharmony_ci bool enable_bg_tag; 653bf215546Sopenharmony_ci uint32_t userpass_spawn; 654bf215546Sopenharmony_ci 655bf215546Sopenharmony_ci /* Have we had to scissor a depth/stencil clear because render area was not 656bf215546Sopenharmony_ci * tile aligned? 657bf215546Sopenharmony_ci */ 658bf215546Sopenharmony_ci bool scissor_ds_clear; 659bf215546Sopenharmony_ci}; 660bf215546Sopenharmony_ci 661bf215546Sopenharmony_cistruct pvr_emit_state { 662bf215546Sopenharmony_ci bool ppp_control : 1; 663bf215546Sopenharmony_ci bool isp : 1; 664bf215546Sopenharmony_ci bool isp_fb : 1; 665bf215546Sopenharmony_ci bool isp_ba : 1; 666bf215546Sopenharmony_ci bool isp_bb : 1; 667bf215546Sopenharmony_ci bool isp_dbsc : 1; 668bf215546Sopenharmony_ci bool pds_fragment_stateptr0 : 1; 669bf215546Sopenharmony_ci bool pds_fragment_stateptr1 : 1; 670bf215546Sopenharmony_ci bool pds_fragment_stateptr2 : 1; 671bf215546Sopenharmony_ci bool pds_fragment_stateptr3 : 1; 672bf215546Sopenharmony_ci bool region_clip : 1; 673bf215546Sopenharmony_ci bool viewport : 1; 674bf215546Sopenharmony_ci bool wclamp : 1; 675bf215546Sopenharmony_ci bool output_selects : 1; 676bf215546Sopenharmony_ci bool varying_word0 : 1; 677bf215546Sopenharmony_ci bool varying_word1 : 1; 678bf215546Sopenharmony_ci bool varying_word2 : 1; 679bf215546Sopenharmony_ci bool stream_out : 1; 680bf215546Sopenharmony_ci}; 681bf215546Sopenharmony_ci 682bf215546Sopenharmony_cistruct pvr_ppp_state { 683bf215546Sopenharmony_ci uint32_t header; 684bf215546Sopenharmony_ci 685bf215546Sopenharmony_ci struct { 686bf215546Sopenharmony_ci /* TODO: Can we get rid of the "control" field? */ 687bf215546Sopenharmony_ci struct PVRX(TA_STATE_ISPCTL) control_struct; 688bf215546Sopenharmony_ci uint32_t control; 689bf215546Sopenharmony_ci 690bf215546Sopenharmony_ci uint32_t front_a; 691bf215546Sopenharmony_ci uint32_t front_b; 692bf215546Sopenharmony_ci uint32_t back_a; 693bf215546Sopenharmony_ci uint32_t back_b; 694bf215546Sopenharmony_ci } isp; 695bf215546Sopenharmony_ci 696bf215546Sopenharmony_ci struct { 697bf215546Sopenharmony_ci uint16_t scissor_index; 698bf215546Sopenharmony_ci uint16_t depthbias_index; 699bf215546Sopenharmony_ci } depthbias_scissor_indices; 700bf215546Sopenharmony_ci 701bf215546Sopenharmony_ci struct { 702bf215546Sopenharmony_ci uint32_t pixel_shader_base; 703bf215546Sopenharmony_ci uint32_t texture_uniform_code_base; 704bf215546Sopenharmony_ci uint32_t size_info1; 705bf215546Sopenharmony_ci uint32_t size_info2; 706bf215546Sopenharmony_ci uint32_t varying_base; 707bf215546Sopenharmony_ci uint32_t texture_state_data_base; 708bf215546Sopenharmony_ci uint32_t uniform_state_data_base; 709bf215546Sopenharmony_ci } pds; 710bf215546Sopenharmony_ci 711bf215546Sopenharmony_ci struct { 712bf215546Sopenharmony_ci uint32_t word0; 713bf215546Sopenharmony_ci uint32_t word1; 714bf215546Sopenharmony_ci } region_clipping; 715bf215546Sopenharmony_ci 716bf215546Sopenharmony_ci struct { 717bf215546Sopenharmony_ci uint32_t a0; 718bf215546Sopenharmony_ci uint32_t m0; 719bf215546Sopenharmony_ci uint32_t a1; 720bf215546Sopenharmony_ci uint32_t m1; 721bf215546Sopenharmony_ci uint32_t a2; 722bf215546Sopenharmony_ci uint32_t m2; 723bf215546Sopenharmony_ci } viewports[PVR_MAX_VIEWPORTS]; 724bf215546Sopenharmony_ci 725bf215546Sopenharmony_ci uint32_t viewport_count; 726bf215546Sopenharmony_ci 727bf215546Sopenharmony_ci uint32_t output_selects; 728bf215546Sopenharmony_ci 729bf215546Sopenharmony_ci uint32_t varying_word[2]; 730bf215546Sopenharmony_ci 731bf215546Sopenharmony_ci uint32_t ppp_control; 732bf215546Sopenharmony_ci}; 733bf215546Sopenharmony_ci 734bf215546Sopenharmony_ci#define PVR_DYNAMIC_STATE_BIT_VIEWPORT BITFIELD_BIT(0U) 735bf215546Sopenharmony_ci#define PVR_DYNAMIC_STATE_BIT_SCISSOR BITFIELD_BIT(1U) 736bf215546Sopenharmony_ci#define PVR_DYNAMIC_STATE_BIT_LINE_WIDTH BITFIELD_BIT(2U) 737bf215546Sopenharmony_ci#define PVR_DYNAMIC_STATE_BIT_DEPTH_BIAS BITFIELD_BIT(3U) 738bf215546Sopenharmony_ci#define PVR_DYNAMIC_STATE_BIT_STENCIL_COMPARE_MASK BITFIELD_BIT(4U) 739bf215546Sopenharmony_ci#define PVR_DYNAMIC_STATE_BIT_STENCIL_WRITE_MASK BITFIELD_BIT(5U) 740bf215546Sopenharmony_ci#define PVR_DYNAMIC_STATE_BIT_STENCIL_REFERENCE BITFIELD_BIT(6U) 741bf215546Sopenharmony_ci#define PVR_DYNAMIC_STATE_BIT_BLEND_CONSTANTS BITFIELD_BIT(7U) 742bf215546Sopenharmony_ci 743bf215546Sopenharmony_ci#define PVR_DYNAMIC_STATE_ALL_BITS \ 744bf215546Sopenharmony_ci ((PVR_DYNAMIC_STATE_BIT_BLEND_CONSTANTS << 1U) - 1U) 745bf215546Sopenharmony_ci 746bf215546Sopenharmony_cistruct pvr_dynamic_state { 747bf215546Sopenharmony_ci /* Identifies which pipeline state is static or dynamic. 748bf215546Sopenharmony_ci * To test for dynamic: & PVR_STATE_BITS_... 749bf215546Sopenharmony_ci */ 750bf215546Sopenharmony_ci uint32_t mask; 751bf215546Sopenharmony_ci 752bf215546Sopenharmony_ci struct { 753bf215546Sopenharmony_ci /* TODO: fixme in the original code - figure out what. */ 754bf215546Sopenharmony_ci uint32_t count; 755bf215546Sopenharmony_ci VkViewport viewports[PVR_MAX_VIEWPORTS]; 756bf215546Sopenharmony_ci } viewport; 757bf215546Sopenharmony_ci 758bf215546Sopenharmony_ci struct { 759bf215546Sopenharmony_ci /* TODO: fixme in the original code - figure out what. */ 760bf215546Sopenharmony_ci uint32_t count; 761bf215546Sopenharmony_ci VkRect2D scissors[PVR_MAX_VIEWPORTS]; 762bf215546Sopenharmony_ci } scissor; 763bf215546Sopenharmony_ci 764bf215546Sopenharmony_ci /* Saved information from pCreateInfo. */ 765bf215546Sopenharmony_ci float line_width; 766bf215546Sopenharmony_ci 767bf215546Sopenharmony_ci struct { 768bf215546Sopenharmony_ci /* Saved information from pCreateInfo. */ 769bf215546Sopenharmony_ci float constant_factor; 770bf215546Sopenharmony_ci float clamp; 771bf215546Sopenharmony_ci float slope_factor; 772bf215546Sopenharmony_ci } depth_bias; 773bf215546Sopenharmony_ci float blend_constants[4]; 774bf215546Sopenharmony_ci struct { 775bf215546Sopenharmony_ci uint32_t front; 776bf215546Sopenharmony_ci uint32_t back; 777bf215546Sopenharmony_ci } compare_mask; 778bf215546Sopenharmony_ci struct { 779bf215546Sopenharmony_ci uint32_t front; 780bf215546Sopenharmony_ci uint32_t back; 781bf215546Sopenharmony_ci } write_mask; 782bf215546Sopenharmony_ci struct { 783bf215546Sopenharmony_ci uint32_t front; 784bf215546Sopenharmony_ci uint32_t back; 785bf215546Sopenharmony_ci } reference; 786bf215546Sopenharmony_ci}; 787bf215546Sopenharmony_ci 788bf215546Sopenharmony_cistruct pvr_cmd_buffer_draw_state { 789bf215546Sopenharmony_ci uint32_t base_instance; 790bf215546Sopenharmony_ci uint32_t base_vertex; 791bf215546Sopenharmony_ci bool draw_indirect; 792bf215546Sopenharmony_ci bool draw_indexed; 793bf215546Sopenharmony_ci}; 794bf215546Sopenharmony_ci 795bf215546Sopenharmony_cistruct pvr_cmd_buffer_state { 796bf215546Sopenharmony_ci VkResult status; 797bf215546Sopenharmony_ci 798bf215546Sopenharmony_ci /* Pipeline binding. */ 799bf215546Sopenharmony_ci const struct pvr_graphics_pipeline *gfx_pipeline; 800bf215546Sopenharmony_ci 801bf215546Sopenharmony_ci const struct pvr_compute_pipeline *compute_pipeline; 802bf215546Sopenharmony_ci 803bf215546Sopenharmony_ci struct pvr_render_pass_info render_pass_info; 804bf215546Sopenharmony_ci 805bf215546Sopenharmony_ci struct pvr_sub_cmd *current_sub_cmd; 806bf215546Sopenharmony_ci 807bf215546Sopenharmony_ci struct pvr_ppp_state ppp_state; 808bf215546Sopenharmony_ci 809bf215546Sopenharmony_ci union { 810bf215546Sopenharmony_ci struct pvr_emit_state emit_state; 811bf215546Sopenharmony_ci /* This is intended to allow setting and clearing of all bits. This 812bf215546Sopenharmony_ci * shouldn't be used to access specific bits of ppp_state. 813bf215546Sopenharmony_ci */ 814bf215546Sopenharmony_ci uint32_t emit_state_bits; 815bf215546Sopenharmony_ci }; 816bf215546Sopenharmony_ci 817bf215546Sopenharmony_ci struct { 818bf215546Sopenharmony_ci /* FIXME: Check if we need a dirty state flag for the given scissor 819bf215546Sopenharmony_ci * accumulation state. 820bf215546Sopenharmony_ci * Check whether these members should be moved in the top level struct 821bf215546Sopenharmony_ci * and this struct replaces with just pvr_dynamic_state "dynamic". 822bf215546Sopenharmony_ci */ 823bf215546Sopenharmony_ci enum pvr_scissor_accum_state scissor_accum_state; 824bf215546Sopenharmony_ci VkRect2D scissor_accum_bounds; 825bf215546Sopenharmony_ci 826bf215546Sopenharmony_ci struct pvr_dynamic_state common; 827bf215546Sopenharmony_ci } dynamic; 828bf215546Sopenharmony_ci 829bf215546Sopenharmony_ci struct pvr_vertex_binding vertex_bindings[PVR_MAX_VERTEX_INPUT_BINDINGS]; 830bf215546Sopenharmony_ci 831bf215546Sopenharmony_ci struct { 832bf215546Sopenharmony_ci struct pvr_buffer *buffer; 833bf215546Sopenharmony_ci VkDeviceSize offset; 834bf215546Sopenharmony_ci VkIndexType type; 835bf215546Sopenharmony_ci } index_buffer_binding; 836bf215546Sopenharmony_ci 837bf215546Sopenharmony_ci struct { 838bf215546Sopenharmony_ci uint8_t data[PVR_MAX_PUSH_CONSTANTS_SIZE]; 839bf215546Sopenharmony_ci VkShaderStageFlags dirty_stages; 840bf215546Sopenharmony_ci } push_constants; 841bf215546Sopenharmony_ci 842bf215546Sopenharmony_ci /* Array size of barriers_needed is based on number of sync pipeline 843bf215546Sopenharmony_ci * stages. 844bf215546Sopenharmony_ci */ 845bf215546Sopenharmony_ci uint32_t barriers_needed[4]; 846bf215546Sopenharmony_ci 847bf215546Sopenharmony_ci struct pvr_descriptor_state gfx_desc_state; 848bf215546Sopenharmony_ci struct pvr_descriptor_state compute_desc_state; 849bf215546Sopenharmony_ci 850bf215546Sopenharmony_ci VkFormat depth_format; 851bf215546Sopenharmony_ci 852bf215546Sopenharmony_ci struct { 853bf215546Sopenharmony_ci bool viewport : 1; 854bf215546Sopenharmony_ci bool scissor : 1; 855bf215546Sopenharmony_ci 856bf215546Sopenharmony_ci bool compute_pipeline_binding : 1; 857bf215546Sopenharmony_ci bool compute_desc_dirty : 1; 858bf215546Sopenharmony_ci 859bf215546Sopenharmony_ci bool gfx_pipeline_binding : 1; 860bf215546Sopenharmony_ci bool gfx_desc_dirty : 1; 861bf215546Sopenharmony_ci 862bf215546Sopenharmony_ci bool vertex_bindings : 1; 863bf215546Sopenharmony_ci bool index_buffer_binding : 1; 864bf215546Sopenharmony_ci bool vertex_descriptors : 1; 865bf215546Sopenharmony_ci bool fragment_descriptors : 1; 866bf215546Sopenharmony_ci 867bf215546Sopenharmony_ci bool line_width : 1; 868bf215546Sopenharmony_ci 869bf215546Sopenharmony_ci bool depth_bias : 1; 870bf215546Sopenharmony_ci 871bf215546Sopenharmony_ci bool blend_constants : 1; 872bf215546Sopenharmony_ci 873bf215546Sopenharmony_ci bool compare_mask : 1; 874bf215546Sopenharmony_ci bool write_mask : 1; 875bf215546Sopenharmony_ci bool reference : 1; 876bf215546Sopenharmony_ci 877bf215546Sopenharmony_ci bool userpass_spawn : 1; 878bf215546Sopenharmony_ci 879bf215546Sopenharmony_ci /* Some draw state needs to be tracked for changes between draw calls 880bf215546Sopenharmony_ci * i.e. if we get a draw with baseInstance=0, followed by a call with 881bf215546Sopenharmony_ci * baseInstance=1 that needs to cause us to select a different PDS 882bf215546Sopenharmony_ci * attrib program and update the BASE_INSTANCE PDS const. If only 883bf215546Sopenharmony_ci * baseInstance changes then we just have to update the data section. 884bf215546Sopenharmony_ci */ 885bf215546Sopenharmony_ci bool draw_base_instance : 1; 886bf215546Sopenharmony_ci bool draw_variant : 1; 887bf215546Sopenharmony_ci } dirty; 888bf215546Sopenharmony_ci 889bf215546Sopenharmony_ci struct pvr_cmd_buffer_draw_state draw_state; 890bf215546Sopenharmony_ci 891bf215546Sopenharmony_ci struct { 892bf215546Sopenharmony_ci uint32_t code_offset; 893bf215546Sopenharmony_ci const struct pvr_pds_info *info; 894bf215546Sopenharmony_ci } pds_shader; 895bf215546Sopenharmony_ci 896bf215546Sopenharmony_ci uint32_t max_shared_regs; 897bf215546Sopenharmony_ci 898bf215546Sopenharmony_ci /* Address of data segment for vertex attrib upload program. */ 899bf215546Sopenharmony_ci uint32_t pds_vertex_attrib_offset; 900bf215546Sopenharmony_ci 901bf215546Sopenharmony_ci uint32_t pds_fragment_descriptor_data_offset; 902bf215546Sopenharmony_ci uint32_t pds_compute_descriptor_data_offset; 903bf215546Sopenharmony_ci}; 904bf215546Sopenharmony_ci 905bf215546Sopenharmony_cistatic_assert( 906bf215546Sopenharmony_ci sizeof(((struct pvr_cmd_buffer_state *)(0))->emit_state) <= 907bf215546Sopenharmony_ci sizeof(((struct pvr_cmd_buffer_state *)(0))->emit_state_bits), 908bf215546Sopenharmony_ci "Size of emit_state_bits must be greater that or equal to emit_state."); 909bf215546Sopenharmony_ci 910bf215546Sopenharmony_cistruct pvr_cmd_buffer { 911bf215546Sopenharmony_ci struct vk_command_buffer vk; 912bf215546Sopenharmony_ci 913bf215546Sopenharmony_ci struct pvr_device *device; 914bf215546Sopenharmony_ci 915bf215546Sopenharmony_ci /* Buffer status, invalid/initial/recording/executable */ 916bf215546Sopenharmony_ci enum pvr_cmd_buffer_status status; 917bf215546Sopenharmony_ci 918bf215546Sopenharmony_ci /* Buffer usage flags */ 919bf215546Sopenharmony_ci VkCommandBufferUsageFlags usage_flags; 920bf215546Sopenharmony_ci 921bf215546Sopenharmony_ci struct util_dynarray depth_bias_array; 922bf215546Sopenharmony_ci 923bf215546Sopenharmony_ci struct util_dynarray scissor_array; 924bf215546Sopenharmony_ci uint32_t scissor_words[2]; 925bf215546Sopenharmony_ci 926bf215546Sopenharmony_ci struct pvr_cmd_buffer_state state; 927bf215546Sopenharmony_ci 928bf215546Sopenharmony_ci /* List of pvr_bo structs associated with this cmd buffer. */ 929bf215546Sopenharmony_ci struct list_head bo_list; 930bf215546Sopenharmony_ci 931bf215546Sopenharmony_ci struct list_head sub_cmds; 932bf215546Sopenharmony_ci}; 933bf215546Sopenharmony_ci 934bf215546Sopenharmony_cistruct pvr_pipeline_layout { 935bf215546Sopenharmony_ci struct vk_object_base base; 936bf215546Sopenharmony_ci 937bf215546Sopenharmony_ci uint32_t set_count; 938bf215546Sopenharmony_ci /* Contains set_count amount of descriptor set layouts. */ 939bf215546Sopenharmony_ci struct pvr_descriptor_set_layout *set_layout[PVR_MAX_DESCRIPTOR_SETS]; 940bf215546Sopenharmony_ci 941bf215546Sopenharmony_ci VkShaderStageFlags push_constants_shader_stages; 942bf215546Sopenharmony_ci 943bf215546Sopenharmony_ci VkShaderStageFlags shader_stages; 944bf215546Sopenharmony_ci 945bf215546Sopenharmony_ci /* Per stage masks indicating which set in the layout contains any 946bf215546Sopenharmony_ci * descriptor of the appropriate types: VK..._{SAMPLER, SAMPLED_IMAGE, 947bf215546Sopenharmony_ci * UNIFORM_TEXEL_BUFFER, UNIFORM_BUFFER, STORAGE_BUFFER}. 948bf215546Sopenharmony_ci * Shift by the set's number to check the mask (1U << set_num). 949bf215546Sopenharmony_ci */ 950bf215546Sopenharmony_ci uint32_t per_stage_descriptor_masks[PVR_STAGE_ALLOCATION_COUNT]; 951bf215546Sopenharmony_ci 952bf215546Sopenharmony_ci /* Array of descriptor offsets at which the set's descriptors' start, per 953bf215546Sopenharmony_ci * stage, within all the sets in the pipeline layout per descriptor type. 954bf215546Sopenharmony_ci * Note that we only store into for specific descriptor types 955bf215546Sopenharmony_ci * VK_DESCRIPTOR_TYPE_{SAMPLER, SAMPLED_IMAGE, UNIFORM_TEXEL_BUFFER, 956bf215546Sopenharmony_ci * UNIFORM_BUFFER, STORAGE_BUFFER}, the rest will be 0. 957bf215546Sopenharmony_ci */ 958bf215546Sopenharmony_ci uint32_t 959bf215546Sopenharmony_ci descriptor_offsets[PVR_MAX_DESCRIPTOR_SETS][PVR_STAGE_ALLOCATION_COUNT] 960bf215546Sopenharmony_ci [PVR_PIPELINE_LAYOUT_SUPPORTED_DESCRIPTOR_TYPE_COUNT]; 961bf215546Sopenharmony_ci 962bf215546Sopenharmony_ci /* There is no accounting for dynamics in here. They will be garbage values. 963bf215546Sopenharmony_ci */ 964bf215546Sopenharmony_ci struct pvr_descriptor_set_layout_mem_layout 965bf215546Sopenharmony_ci register_layout_in_dwords_per_stage[PVR_STAGE_ALLOCATION_COUNT] 966bf215546Sopenharmony_ci [PVR_MAX_DESCRIPTOR_SETS]; 967bf215546Sopenharmony_ci 968bf215546Sopenharmony_ci /* All sizes in dwords. */ 969bf215546Sopenharmony_ci struct pvr_pipeline_layout_reg_info { 970bf215546Sopenharmony_ci uint32_t primary_dynamic_size_in_dwords; 971bf215546Sopenharmony_ci uint32_t secondary_dynamic_size_in_dwords; 972bf215546Sopenharmony_ci } per_stage_reg_info[PVR_STAGE_ALLOCATION_COUNT]; 973bf215546Sopenharmony_ci}; 974bf215546Sopenharmony_ci 975bf215546Sopenharmony_cistruct pvr_pipeline_cache { 976bf215546Sopenharmony_ci struct vk_object_base base; 977bf215546Sopenharmony_ci 978bf215546Sopenharmony_ci struct pvr_device *device; 979bf215546Sopenharmony_ci}; 980bf215546Sopenharmony_ci 981bf215546Sopenharmony_cistruct pvr_stage_allocation_descriptor_state { 982bf215546Sopenharmony_ci struct pvr_pds_upload pds_code; 983bf215546Sopenharmony_ci /* Since we upload the code segment separately from the data segment 984bf215546Sopenharmony_ci * pds_code->data_size might be 0 whilst 985bf215546Sopenharmony_ci * pds_info->data_size_in_dwords might be >0 in the case of this struct 986bf215546Sopenharmony_ci * referring to the code upload. 987bf215546Sopenharmony_ci */ 988bf215546Sopenharmony_ci struct pvr_pds_info pds_info; 989bf215546Sopenharmony_ci 990bf215546Sopenharmony_ci /* Already setup compile time static consts. */ 991bf215546Sopenharmony_ci struct pvr_bo *static_consts; 992bf215546Sopenharmony_ci}; 993bf215546Sopenharmony_ci 994bf215546Sopenharmony_cistruct pvr_pds_attrib_program { 995bf215546Sopenharmony_ci struct pvr_pds_info info; 996bf215546Sopenharmony_ci /* The uploaded PDS program stored here only contains the code segment, 997bf215546Sopenharmony_ci * meaning the data size will be 0, unlike the data size stored in the 998bf215546Sopenharmony_ci * 'info' member above. 999bf215546Sopenharmony_ci */ 1000bf215546Sopenharmony_ci struct pvr_pds_upload program; 1001bf215546Sopenharmony_ci}; 1002bf215546Sopenharmony_ci 1003bf215546Sopenharmony_cistruct pvr_pipeline_stage_state { 1004bf215546Sopenharmony_ci uint32_t const_shared_reg_count; 1005bf215546Sopenharmony_ci uint32_t const_shared_reg_offset; 1006bf215546Sopenharmony_ci uint32_t temps_count; 1007bf215546Sopenharmony_ci 1008bf215546Sopenharmony_ci uint32_t coefficient_size; 1009bf215546Sopenharmony_ci 1010bf215546Sopenharmony_ci /* True if this shader uses any atomic operations. */ 1011bf215546Sopenharmony_ci bool uses_atomic_ops; 1012bf215546Sopenharmony_ci 1013bf215546Sopenharmony_ci /* True if this shader uses both texture reads and texture writes. */ 1014bf215546Sopenharmony_ci bool uses_texture_rw; 1015bf215546Sopenharmony_ci 1016bf215546Sopenharmony_ci /* Only used for compute stage. */ 1017bf215546Sopenharmony_ci bool uses_barrier; 1018bf215546Sopenharmony_ci 1019bf215546Sopenharmony_ci /* True if this shader has side effects */ 1020bf215546Sopenharmony_ci bool has_side_effects; 1021bf215546Sopenharmony_ci 1022bf215546Sopenharmony_ci /* True if this shader is simply a nop.end. */ 1023bf215546Sopenharmony_ci bool empty_program; 1024bf215546Sopenharmony_ci}; 1025bf215546Sopenharmony_ci 1026bf215546Sopenharmony_cistruct pvr_vertex_shader_state { 1027bf215546Sopenharmony_ci /* Pointer to a buffer object that contains the shader binary. */ 1028bf215546Sopenharmony_ci struct pvr_bo *bo; 1029bf215546Sopenharmony_ci uint32_t entry_offset; 1030bf215546Sopenharmony_ci 1031bf215546Sopenharmony_ci /* 2 since we only need STATE_VARYING{0,1} state words. */ 1032bf215546Sopenharmony_ci uint32_t varying[2]; 1033bf215546Sopenharmony_ci 1034bf215546Sopenharmony_ci struct pvr_pds_attrib_program 1035bf215546Sopenharmony_ci pds_attrib_programs[PVR_PDS_VERTEX_ATTRIB_PROGRAM_COUNT]; 1036bf215546Sopenharmony_ci 1037bf215546Sopenharmony_ci struct pvr_pipeline_stage_state stage_state; 1038bf215546Sopenharmony_ci /* FIXME: Move this into stage_state? */ 1039bf215546Sopenharmony_ci struct pvr_stage_allocation_descriptor_state descriptor_state; 1040bf215546Sopenharmony_ci uint32_t vertex_input_size; 1041bf215546Sopenharmony_ci uint32_t vertex_output_size; 1042bf215546Sopenharmony_ci uint32_t user_clip_planes_mask; 1043bf215546Sopenharmony_ci}; 1044bf215546Sopenharmony_ci 1045bf215546Sopenharmony_cistruct pvr_fragment_shader_state { 1046bf215546Sopenharmony_ci /* Pointer to a buffer object that contains the shader binary. */ 1047bf215546Sopenharmony_ci struct pvr_bo *bo; 1048bf215546Sopenharmony_ci uint32_t entry_offset; 1049bf215546Sopenharmony_ci 1050bf215546Sopenharmony_ci struct pvr_pipeline_stage_state stage_state; 1051bf215546Sopenharmony_ci /* FIXME: Move this into stage_state? */ 1052bf215546Sopenharmony_ci struct pvr_stage_allocation_descriptor_state descriptor_state; 1053bf215546Sopenharmony_ci uint32_t pass_type; 1054bf215546Sopenharmony_ci 1055bf215546Sopenharmony_ci struct pvr_pds_upload pds_coeff_program; 1056bf215546Sopenharmony_ci struct pvr_pds_upload pds_fragment_program; 1057bf215546Sopenharmony_ci}; 1058bf215546Sopenharmony_ci 1059bf215546Sopenharmony_cistruct pvr_pipeline { 1060bf215546Sopenharmony_ci struct vk_object_base base; 1061bf215546Sopenharmony_ci 1062bf215546Sopenharmony_ci enum pvr_pipeline_type type; 1063bf215546Sopenharmony_ci 1064bf215546Sopenharmony_ci /* Saved information from pCreateInfo. */ 1065bf215546Sopenharmony_ci struct pvr_pipeline_layout *layout; 1066bf215546Sopenharmony_ci}; 1067bf215546Sopenharmony_ci 1068bf215546Sopenharmony_cistruct pvr_compute_pipeline { 1069bf215546Sopenharmony_ci struct pvr_pipeline base; 1070bf215546Sopenharmony_ci 1071bf215546Sopenharmony_ci struct { 1072bf215546Sopenharmony_ci /* TODO: Change this to be an anonymous struct once the shader hardcoding 1073bf215546Sopenharmony_ci * is removed. 1074bf215546Sopenharmony_ci */ 1075bf215546Sopenharmony_ci struct pvr_compute_pipeline_shader_state { 1076bf215546Sopenharmony_ci /* Pointer to a buffer object that contains the shader binary. */ 1077bf215546Sopenharmony_ci struct pvr_bo *bo; 1078bf215546Sopenharmony_ci 1079bf215546Sopenharmony_ci bool uses_atomic_ops; 1080bf215546Sopenharmony_ci bool uses_barrier; 1081bf215546Sopenharmony_ci /* E.g. GLSL shader uses gl_NumWorkGroups. */ 1082bf215546Sopenharmony_ci bool uses_num_workgroups; 1083bf215546Sopenharmony_ci 1084bf215546Sopenharmony_ci uint32_t const_shared_reg_count; 1085bf215546Sopenharmony_ci uint32_t input_register_count; 1086bf215546Sopenharmony_ci uint32_t work_size; 1087bf215546Sopenharmony_ci uint32_t coefficient_register_count; 1088bf215546Sopenharmony_ci } shader; 1089bf215546Sopenharmony_ci 1090bf215546Sopenharmony_ci struct { 1091bf215546Sopenharmony_ci uint32_t base_workgroup : 1; 1092bf215546Sopenharmony_ci } flags; 1093bf215546Sopenharmony_ci 1094bf215546Sopenharmony_ci struct pvr_stage_allocation_descriptor_state descriptor; 1095bf215546Sopenharmony_ci 1096bf215546Sopenharmony_ci struct pvr_pds_upload primary_program; 1097bf215546Sopenharmony_ci struct pvr_pds_info primary_program_info; 1098bf215546Sopenharmony_ci 1099bf215546Sopenharmony_ci struct pvr_pds_base_workgroup_program { 1100bf215546Sopenharmony_ci struct pvr_pds_upload code_upload; 1101bf215546Sopenharmony_ci 1102bf215546Sopenharmony_ci uint32_t *data_section; 1103bf215546Sopenharmony_ci /* Offset within the PDS data section at which the base workgroup id 1104bf215546Sopenharmony_ci * resides. 1105bf215546Sopenharmony_ci */ 1106bf215546Sopenharmony_ci uint32_t base_workgroup_data_patching_offset; 1107bf215546Sopenharmony_ci 1108bf215546Sopenharmony_ci struct pvr_pds_info info; 1109bf215546Sopenharmony_ci } primary_base_workgroup_variant_program; 1110bf215546Sopenharmony_ci } state; 1111bf215546Sopenharmony_ci}; 1112bf215546Sopenharmony_ci 1113bf215546Sopenharmony_cistruct pvr_graphics_pipeline { 1114bf215546Sopenharmony_ci struct pvr_pipeline base; 1115bf215546Sopenharmony_ci 1116bf215546Sopenharmony_ci VkSampleCountFlagBits rasterization_samples; 1117bf215546Sopenharmony_ci struct pvr_raster_state { 1118bf215546Sopenharmony_ci /* Derived and other state. */ 1119bf215546Sopenharmony_ci /* Indicates whether primitives are discarded immediately before the 1120bf215546Sopenharmony_ci * rasterization stage. 1121bf215546Sopenharmony_ci */ 1122bf215546Sopenharmony_ci bool discard_enable; 1123bf215546Sopenharmony_ci VkCullModeFlags cull_mode; 1124bf215546Sopenharmony_ci VkFrontFace front_face; 1125bf215546Sopenharmony_ci bool depth_bias_enable; 1126bf215546Sopenharmony_ci bool depth_clamp_enable; 1127bf215546Sopenharmony_ci } raster_state; 1128bf215546Sopenharmony_ci struct { 1129bf215546Sopenharmony_ci VkPrimitiveTopology topology; 1130bf215546Sopenharmony_ci bool primitive_restart; 1131bf215546Sopenharmony_ci } input_asm_state; 1132bf215546Sopenharmony_ci uint32_t sample_mask; 1133bf215546Sopenharmony_ci 1134bf215546Sopenharmony_ci struct pvr_dynamic_state dynamic_state; 1135bf215546Sopenharmony_ci 1136bf215546Sopenharmony_ci VkCompareOp depth_compare_op; 1137bf215546Sopenharmony_ci bool depth_write_disable; 1138bf215546Sopenharmony_ci 1139bf215546Sopenharmony_ci struct { 1140bf215546Sopenharmony_ci VkCompareOp compare_op; 1141bf215546Sopenharmony_ci /* SOP1 */ 1142bf215546Sopenharmony_ci VkStencilOp fail_op; 1143bf215546Sopenharmony_ci /* SOP2 */ 1144bf215546Sopenharmony_ci VkStencilOp depth_fail_op; 1145bf215546Sopenharmony_ci /* SOP3 */ 1146bf215546Sopenharmony_ci VkStencilOp pass_op; 1147bf215546Sopenharmony_ci } stencil_front, stencil_back; 1148bf215546Sopenharmony_ci 1149bf215546Sopenharmony_ci /* Derived and other state */ 1150bf215546Sopenharmony_ci size_t stage_indices[MESA_SHADER_FRAGMENT + 1]; 1151bf215546Sopenharmony_ci 1152bf215546Sopenharmony_ci struct pvr_vertex_shader_state vertex_shader_state; 1153bf215546Sopenharmony_ci struct pvr_fragment_shader_state fragment_shader_state; 1154bf215546Sopenharmony_ci}; 1155bf215546Sopenharmony_ci 1156bf215546Sopenharmony_cistruct pvr_query_pool { 1157bf215546Sopenharmony_ci struct vk_object_base base; 1158bf215546Sopenharmony_ci 1159bf215546Sopenharmony_ci /* Stride of result_buffer to get to the start of the results for the next 1160bf215546Sopenharmony_ci * Phantom. 1161bf215546Sopenharmony_ci */ 1162bf215546Sopenharmony_ci uint32_t result_stride; 1163bf215546Sopenharmony_ci 1164bf215546Sopenharmony_ci struct pvr_bo *result_buffer; 1165bf215546Sopenharmony_ci struct pvr_bo *availability_buffer; 1166bf215546Sopenharmony_ci}; 1167bf215546Sopenharmony_ci 1168bf215546Sopenharmony_cistruct pvr_render_target { 1169bf215546Sopenharmony_ci struct pvr_rt_dataset *rt_dataset; 1170bf215546Sopenharmony_ci 1171bf215546Sopenharmony_ci pthread_mutex_t mutex; 1172bf215546Sopenharmony_ci 1173bf215546Sopenharmony_ci bool valid; 1174bf215546Sopenharmony_ci}; 1175bf215546Sopenharmony_ci 1176bf215546Sopenharmony_cistruct pvr_framebuffer { 1177bf215546Sopenharmony_ci struct vk_object_base base; 1178bf215546Sopenharmony_ci 1179bf215546Sopenharmony_ci /* Saved information from pCreateInfo. */ 1180bf215546Sopenharmony_ci uint32_t width; 1181bf215546Sopenharmony_ci uint32_t height; 1182bf215546Sopenharmony_ci uint32_t layers; 1183bf215546Sopenharmony_ci 1184bf215546Sopenharmony_ci uint32_t attachment_count; 1185bf215546Sopenharmony_ci struct pvr_image_view **attachments; 1186bf215546Sopenharmony_ci 1187bf215546Sopenharmony_ci /* Derived and other state. */ 1188bf215546Sopenharmony_ci struct pvr_bo *ppp_state_bo; 1189bf215546Sopenharmony_ci /* PPP state size in dwords. */ 1190bf215546Sopenharmony_ci size_t ppp_state_size; 1191bf215546Sopenharmony_ci 1192bf215546Sopenharmony_ci uint32_t render_targets_count; 1193bf215546Sopenharmony_ci struct pvr_render_target *render_targets; 1194bf215546Sopenharmony_ci}; 1195bf215546Sopenharmony_ci 1196bf215546Sopenharmony_cistruct pvr_render_pass_attachment { 1197bf215546Sopenharmony_ci /* Saved information from pCreateInfo. */ 1198bf215546Sopenharmony_ci VkAttachmentLoadOp load_op; 1199bf215546Sopenharmony_ci 1200bf215546Sopenharmony_ci VkAttachmentStoreOp store_op; 1201bf215546Sopenharmony_ci 1202bf215546Sopenharmony_ci VkAttachmentLoadOp stencil_load_op; 1203bf215546Sopenharmony_ci 1204bf215546Sopenharmony_ci VkAttachmentStoreOp stencil_store_op; 1205bf215546Sopenharmony_ci 1206bf215546Sopenharmony_ci VkFormat vk_format; 1207bf215546Sopenharmony_ci uint32_t sample_count; 1208bf215546Sopenharmony_ci VkImageLayout initial_layout; 1209bf215546Sopenharmony_ci 1210bf215546Sopenharmony_ci /* Derived and other state. */ 1211bf215546Sopenharmony_ci /* True if the attachment format includes a stencil component. */ 1212bf215546Sopenharmony_ci bool has_stencil; 1213bf215546Sopenharmony_ci 1214bf215546Sopenharmony_ci /* Can this surface be resolved by the PBE. */ 1215bf215546Sopenharmony_ci bool is_pbe_downscalable; 1216bf215546Sopenharmony_ci 1217bf215546Sopenharmony_ci uint32_t index; 1218bf215546Sopenharmony_ci}; 1219bf215546Sopenharmony_ci 1220bf215546Sopenharmony_cistruct pvr_render_subpass { 1221bf215546Sopenharmony_ci /* Saved information from pCreateInfo. */ 1222bf215546Sopenharmony_ci /* The number of samples per color attachment (or depth attachment if 1223bf215546Sopenharmony_ci * z-only). 1224bf215546Sopenharmony_ci */ 1225bf215546Sopenharmony_ci /* FIXME: rename to 'samples' to match struct pvr_image */ 1226bf215546Sopenharmony_ci uint32_t sample_count; 1227bf215546Sopenharmony_ci 1228bf215546Sopenharmony_ci uint32_t color_count; 1229bf215546Sopenharmony_ci uint32_t *color_attachments; 1230bf215546Sopenharmony_ci uint32_t *resolve_attachments; 1231bf215546Sopenharmony_ci 1232bf215546Sopenharmony_ci uint32_t input_count; 1233bf215546Sopenharmony_ci uint32_t *input_attachments; 1234bf215546Sopenharmony_ci 1235bf215546Sopenharmony_ci uint32_t *depth_stencil_attachment; 1236bf215546Sopenharmony_ci 1237bf215546Sopenharmony_ci /* Derived and other state. */ 1238bf215546Sopenharmony_ci uint32_t dep_count; 1239bf215546Sopenharmony_ci uint32_t *dep_list; 1240bf215546Sopenharmony_ci 1241bf215546Sopenharmony_ci /* Array with dep_count elements. flush_on_dep[x] is true if this subpass 1242bf215546Sopenharmony_ci * and the subpass dep_list[x] can't be in the same hardware render. 1243bf215546Sopenharmony_ci */ 1244bf215546Sopenharmony_ci bool *flush_on_dep; 1245bf215546Sopenharmony_ci 1246bf215546Sopenharmony_ci uint32_t index; 1247bf215546Sopenharmony_ci 1248bf215546Sopenharmony_ci uint32_t userpass_spawn; 1249bf215546Sopenharmony_ci 1250bf215546Sopenharmony_ci VkPipelineBindPoint pipeline_bind_point; 1251bf215546Sopenharmony_ci}; 1252bf215546Sopenharmony_ci 1253bf215546Sopenharmony_cistruct pvr_render_pass { 1254bf215546Sopenharmony_ci struct vk_object_base base; 1255bf215546Sopenharmony_ci 1256bf215546Sopenharmony_ci /* Saved information from pCreateInfo. */ 1257bf215546Sopenharmony_ci uint32_t attachment_count; 1258bf215546Sopenharmony_ci 1259bf215546Sopenharmony_ci struct pvr_render_pass_attachment *attachments; 1260bf215546Sopenharmony_ci 1261bf215546Sopenharmony_ci uint32_t subpass_count; 1262bf215546Sopenharmony_ci 1263bf215546Sopenharmony_ci struct pvr_render_subpass *subpasses; 1264bf215546Sopenharmony_ci 1265bf215546Sopenharmony_ci struct pvr_renderpass_hwsetup *hw_setup; 1266bf215546Sopenharmony_ci 1267bf215546Sopenharmony_ci /* Derived and other state. */ 1268bf215546Sopenharmony_ci /* FIXME: rename to 'max_samples' as we use 'samples' elsewhere */ 1269bf215546Sopenharmony_ci uint32_t max_sample_count; 1270bf215546Sopenharmony_ci 1271bf215546Sopenharmony_ci /* The maximum number of tile buffers to use in any subpass. */ 1272bf215546Sopenharmony_ci uint32_t max_tilebuffer_count; 1273bf215546Sopenharmony_ci}; 1274bf215546Sopenharmony_ci 1275bf215546Sopenharmony_cistruct pvr_load_op { 1276bf215546Sopenharmony_ci bool is_hw_object; 1277bf215546Sopenharmony_ci 1278bf215546Sopenharmony_ci uint32_t clear_mask; 1279bf215546Sopenharmony_ci 1280bf215546Sopenharmony_ci struct pvr_bo *usc_frag_prog_bo; 1281bf215546Sopenharmony_ci uint32_t const_shareds_count; 1282bf215546Sopenharmony_ci uint32_t shareds_dest_offset; 1283bf215546Sopenharmony_ci uint32_t shareds_count; 1284bf215546Sopenharmony_ci 1285bf215546Sopenharmony_ci struct pvr_pds_upload pds_frag_prog; 1286bf215546Sopenharmony_ci 1287bf215546Sopenharmony_ci struct pvr_pds_upload pds_tex_state_prog; 1288bf215546Sopenharmony_ci uint32_t temps_count; 1289bf215546Sopenharmony_ci}; 1290bf215546Sopenharmony_ci 1291bf215546Sopenharmony_ciuint32_t pvr_calc_fscommon_size_and_tiles_in_flight( 1292bf215546Sopenharmony_ci const struct pvr_physical_device *pdevice, 1293bf215546Sopenharmony_ci uint32_t fs_common_size, 1294bf215546Sopenharmony_ci uint32_t min_tiles_in_flight); 1295bf215546Sopenharmony_ci 1296bf215546Sopenharmony_ciVkResult pvr_wsi_init(struct pvr_physical_device *pdevice); 1297bf215546Sopenharmony_civoid pvr_wsi_finish(struct pvr_physical_device *pdevice); 1298bf215546Sopenharmony_ci 1299bf215546Sopenharmony_ciVkResult pvr_queues_create(struct pvr_device *device, 1300bf215546Sopenharmony_ci const VkDeviceCreateInfo *pCreateInfo); 1301bf215546Sopenharmony_civoid pvr_queues_destroy(struct pvr_device *device); 1302bf215546Sopenharmony_ci 1303bf215546Sopenharmony_ciVkResult pvr_bind_memory(struct pvr_device *device, 1304bf215546Sopenharmony_ci struct pvr_device_memory *mem, 1305bf215546Sopenharmony_ci VkDeviceSize offset, 1306bf215546Sopenharmony_ci VkDeviceSize size, 1307bf215546Sopenharmony_ci VkDeviceSize alignment, 1308bf215546Sopenharmony_ci struct pvr_winsys_vma **const vma_out, 1309bf215546Sopenharmony_ci pvr_dev_addr_t *const dev_addr_out); 1310bf215546Sopenharmony_civoid pvr_unbind_memory(struct pvr_device *device, struct pvr_winsys_vma *vma); 1311bf215546Sopenharmony_ci 1312bf215546Sopenharmony_ciVkResult pvr_gpu_upload(struct pvr_device *device, 1313bf215546Sopenharmony_ci struct pvr_winsys_heap *heap, 1314bf215546Sopenharmony_ci const void *data, 1315bf215546Sopenharmony_ci size_t size, 1316bf215546Sopenharmony_ci uint64_t alignment, 1317bf215546Sopenharmony_ci struct pvr_bo **const pvr_bo_out); 1318bf215546Sopenharmony_ciVkResult pvr_gpu_upload_pds(struct pvr_device *device, 1319bf215546Sopenharmony_ci const uint32_t *data, 1320bf215546Sopenharmony_ci uint32_t data_size_dwords, 1321bf215546Sopenharmony_ci uint32_t data_alignment, 1322bf215546Sopenharmony_ci const uint32_t *code, 1323bf215546Sopenharmony_ci uint32_t code_size_dwords, 1324bf215546Sopenharmony_ci uint32_t code_alignment, 1325bf215546Sopenharmony_ci uint64_t min_alignment, 1326bf215546Sopenharmony_ci struct pvr_pds_upload *const pds_upload_out); 1327bf215546Sopenharmony_ci 1328bf215546Sopenharmony_ciVkResult pvr_gpu_upload_usc(struct pvr_device *device, 1329bf215546Sopenharmony_ci const void *code, 1330bf215546Sopenharmony_ci size_t code_size, 1331bf215546Sopenharmony_ci uint64_t code_alignment, 1332bf215546Sopenharmony_ci struct pvr_bo **const pvr_bo_out); 1333bf215546Sopenharmony_ci 1334bf215546Sopenharmony_ciVkResult pvr_cmd_buffer_add_transfer_cmd(struct pvr_cmd_buffer *cmd_buffer, 1335bf215546Sopenharmony_ci struct pvr_transfer_cmd *transfer_cmd); 1336bf215546Sopenharmony_ci 1337bf215546Sopenharmony_ciVkResult pvr_cmd_buffer_alloc_mem(struct pvr_cmd_buffer *cmd_buffer, 1338bf215546Sopenharmony_ci struct pvr_winsys_heap *heap, 1339bf215546Sopenharmony_ci uint64_t size, 1340bf215546Sopenharmony_ci uint32_t flags, 1341bf215546Sopenharmony_ci struct pvr_bo **const pvr_bo_out); 1342bf215546Sopenharmony_ci 1343bf215546Sopenharmony_cistatic inline struct pvr_compute_pipeline * 1344bf215546Sopenharmony_cito_pvr_compute_pipeline(struct pvr_pipeline *pipeline) 1345bf215546Sopenharmony_ci{ 1346bf215546Sopenharmony_ci assert(pipeline->type == PVR_PIPELINE_TYPE_COMPUTE); 1347bf215546Sopenharmony_ci return container_of(pipeline, struct pvr_compute_pipeline, base); 1348bf215546Sopenharmony_ci} 1349bf215546Sopenharmony_ci 1350bf215546Sopenharmony_cistatic inline struct pvr_graphics_pipeline * 1351bf215546Sopenharmony_cito_pvr_graphics_pipeline(struct pvr_pipeline *pipeline) 1352bf215546Sopenharmony_ci{ 1353bf215546Sopenharmony_ci assert(pipeline->type == PVR_PIPELINE_TYPE_GRAPHICS); 1354bf215546Sopenharmony_ci return container_of(pipeline, struct pvr_graphics_pipeline, base); 1355bf215546Sopenharmony_ci} 1356bf215546Sopenharmony_ci 1357bf215546Sopenharmony_cistatic enum pvr_pipeline_stage_bits 1358bf215546Sopenharmony_cipvr_stage_mask(VkPipelineStageFlags2 stage_mask) 1359bf215546Sopenharmony_ci{ 1360bf215546Sopenharmony_ci enum pvr_pipeline_stage_bits stages = 0; 1361bf215546Sopenharmony_ci 1362bf215546Sopenharmony_ci if (stage_mask & VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) 1363bf215546Sopenharmony_ci return PVR_PIPELINE_STAGE_ALL_BITS; 1364bf215546Sopenharmony_ci 1365bf215546Sopenharmony_ci if (stage_mask & (VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT)) 1366bf215546Sopenharmony_ci stages |= PVR_PIPELINE_STAGE_ALL_GRAPHICS_BITS; 1367bf215546Sopenharmony_ci 1368bf215546Sopenharmony_ci if (stage_mask & (VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | 1369bf215546Sopenharmony_ci VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | 1370bf215546Sopenharmony_ci VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | 1371bf215546Sopenharmony_ci VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT | 1372bf215546Sopenharmony_ci VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT | 1373bf215546Sopenharmony_ci VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT)) { 1374bf215546Sopenharmony_ci stages |= PVR_PIPELINE_STAGE_GEOM_BIT; 1375bf215546Sopenharmony_ci } 1376bf215546Sopenharmony_ci 1377bf215546Sopenharmony_ci if (stage_mask & (VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | 1378bf215546Sopenharmony_ci VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | 1379bf215546Sopenharmony_ci VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | 1380bf215546Sopenharmony_ci VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT)) { 1381bf215546Sopenharmony_ci stages |= PVR_PIPELINE_STAGE_FRAG_BIT; 1382bf215546Sopenharmony_ci } 1383bf215546Sopenharmony_ci 1384bf215546Sopenharmony_ci if (stage_mask & (VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | 1385bf215546Sopenharmony_ci VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT)) { 1386bf215546Sopenharmony_ci stages |= PVR_PIPELINE_STAGE_COMPUTE_BIT; 1387bf215546Sopenharmony_ci } 1388bf215546Sopenharmony_ci 1389bf215546Sopenharmony_ci if (stage_mask & (VK_PIPELINE_STAGE_TRANSFER_BIT)) 1390bf215546Sopenharmony_ci stages |= PVR_PIPELINE_STAGE_TRANSFER_BIT; 1391bf215546Sopenharmony_ci 1392bf215546Sopenharmony_ci return stages; 1393bf215546Sopenharmony_ci} 1394bf215546Sopenharmony_ci 1395bf215546Sopenharmony_cistatic inline enum pvr_pipeline_stage_bits 1396bf215546Sopenharmony_cipvr_stage_mask_src(VkPipelineStageFlags2KHR stage_mask) 1397bf215546Sopenharmony_ci{ 1398bf215546Sopenharmony_ci /* If the source is bottom of pipe, all stages will need to be waited for. */ 1399bf215546Sopenharmony_ci if (stage_mask & VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT) 1400bf215546Sopenharmony_ci return PVR_PIPELINE_STAGE_ALL_BITS; 1401bf215546Sopenharmony_ci 1402bf215546Sopenharmony_ci return pvr_stage_mask(stage_mask); 1403bf215546Sopenharmony_ci} 1404bf215546Sopenharmony_ci 1405bf215546Sopenharmony_cistatic inline enum pvr_pipeline_stage_bits 1406bf215546Sopenharmony_cipvr_stage_mask_dst(VkPipelineStageFlags2KHR stage_mask) 1407bf215546Sopenharmony_ci{ 1408bf215546Sopenharmony_ci /* If the destination is top of pipe, all stages should be blocked by prior 1409bf215546Sopenharmony_ci * commands. 1410bf215546Sopenharmony_ci */ 1411bf215546Sopenharmony_ci if (stage_mask & VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT) 1412bf215546Sopenharmony_ci return PVR_PIPELINE_STAGE_ALL_BITS; 1413bf215546Sopenharmony_ci 1414bf215546Sopenharmony_ci return pvr_stage_mask(stage_mask); 1415bf215546Sopenharmony_ci} 1416bf215546Sopenharmony_ci 1417bf215546Sopenharmony_ciVkResult pvr_pds_fragment_program_create_and_upload( 1418bf215546Sopenharmony_ci struct pvr_device *device, 1419bf215546Sopenharmony_ci const VkAllocationCallbacks *allocator, 1420bf215546Sopenharmony_ci const struct pvr_bo *fragment_shader_bo, 1421bf215546Sopenharmony_ci uint32_t fragment_temp_count, 1422bf215546Sopenharmony_ci enum rogue_msaa_mode msaa_mode, 1423bf215546Sopenharmony_ci bool has_phase_rate_change, 1424bf215546Sopenharmony_ci struct pvr_pds_upload *const pds_upload_out); 1425bf215546Sopenharmony_ci 1426bf215546Sopenharmony_ciVkResult pvr_pds_unitex_state_program_create_and_upload( 1427bf215546Sopenharmony_ci struct pvr_device *device, 1428bf215546Sopenharmony_ci const VkAllocationCallbacks *allocator, 1429bf215546Sopenharmony_ci uint32_t texture_kicks, 1430bf215546Sopenharmony_ci uint32_t uniform_kicks, 1431bf215546Sopenharmony_ci struct pvr_pds_upload *const pds_upload_out); 1432bf215546Sopenharmony_ci 1433bf215546Sopenharmony_ci#define PVR_FROM_HANDLE(__pvr_type, __name, __handle) \ 1434bf215546Sopenharmony_ci VK_FROM_HANDLE(__pvr_type, __name, __handle) 1435bf215546Sopenharmony_ci 1436bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(pvr_cmd_buffer, 1437bf215546Sopenharmony_ci vk.base, 1438bf215546Sopenharmony_ci VkCommandBuffer, 1439bf215546Sopenharmony_ci VK_OBJECT_TYPE_COMMAND_BUFFER) 1440bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(pvr_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE) 1441bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(pvr_instance, 1442bf215546Sopenharmony_ci vk.base, 1443bf215546Sopenharmony_ci VkInstance, 1444bf215546Sopenharmony_ci VK_OBJECT_TYPE_INSTANCE) 1445bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(pvr_physical_device, 1446bf215546Sopenharmony_ci vk.base, 1447bf215546Sopenharmony_ci VkPhysicalDevice, 1448bf215546Sopenharmony_ci VK_OBJECT_TYPE_PHYSICAL_DEVICE) 1449bf215546Sopenharmony_ciVK_DEFINE_HANDLE_CASTS(pvr_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE) 1450bf215546Sopenharmony_ci 1451bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_device_memory, 1452bf215546Sopenharmony_ci base, 1453bf215546Sopenharmony_ci VkDeviceMemory, 1454bf215546Sopenharmony_ci VK_OBJECT_TYPE_DEVICE_MEMORY) 1455bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE) 1456bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_pipeline_cache, 1457bf215546Sopenharmony_ci base, 1458bf215546Sopenharmony_ci VkPipelineCache, 1459bf215546Sopenharmony_ci VK_OBJECT_TYPE_PIPELINE_CACHE) 1460bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_buffer, 1461bf215546Sopenharmony_ci vk.base, 1462bf215546Sopenharmony_ci VkBuffer, 1463bf215546Sopenharmony_ci VK_OBJECT_TYPE_BUFFER) 1464bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_image_view, 1465bf215546Sopenharmony_ci vk.base, 1466bf215546Sopenharmony_ci VkImageView, 1467bf215546Sopenharmony_ci VK_OBJECT_TYPE_IMAGE_VIEW) 1468bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_buffer_view, 1469bf215546Sopenharmony_ci base, 1470bf215546Sopenharmony_ci VkBufferView, 1471bf215546Sopenharmony_ci VK_OBJECT_TYPE_BUFFER_VIEW) 1472bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_descriptor_set_layout, 1473bf215546Sopenharmony_ci base, 1474bf215546Sopenharmony_ci VkDescriptorSetLayout, 1475bf215546Sopenharmony_ci VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT) 1476bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_descriptor_set, 1477bf215546Sopenharmony_ci base, 1478bf215546Sopenharmony_ci VkDescriptorSet, 1479bf215546Sopenharmony_ci VK_OBJECT_TYPE_DESCRIPTOR_SET) 1480bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_descriptor_pool, 1481bf215546Sopenharmony_ci base, 1482bf215546Sopenharmony_ci VkDescriptorPool, 1483bf215546Sopenharmony_ci VK_OBJECT_TYPE_DESCRIPTOR_POOL) 1484bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_sampler, 1485bf215546Sopenharmony_ci base, 1486bf215546Sopenharmony_ci VkSampler, 1487bf215546Sopenharmony_ci VK_OBJECT_TYPE_SAMPLER) 1488bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_pipeline_layout, 1489bf215546Sopenharmony_ci base, 1490bf215546Sopenharmony_ci VkPipelineLayout, 1491bf215546Sopenharmony_ci VK_OBJECT_TYPE_PIPELINE_LAYOUT) 1492bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_pipeline, 1493bf215546Sopenharmony_ci base, 1494bf215546Sopenharmony_ci VkPipeline, 1495bf215546Sopenharmony_ci VK_OBJECT_TYPE_PIPELINE) 1496bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_query_pool, 1497bf215546Sopenharmony_ci base, 1498bf215546Sopenharmony_ci VkQueryPool, 1499bf215546Sopenharmony_ci VK_OBJECT_TYPE_QUERY_POOL) 1500bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_framebuffer, 1501bf215546Sopenharmony_ci base, 1502bf215546Sopenharmony_ci VkFramebuffer, 1503bf215546Sopenharmony_ci VK_OBJECT_TYPE_FRAMEBUFFER) 1504bf215546Sopenharmony_ciVK_DEFINE_NONDISP_HANDLE_CASTS(pvr_render_pass, 1505bf215546Sopenharmony_ci base, 1506bf215546Sopenharmony_ci VkRenderPass, 1507bf215546Sopenharmony_ci VK_OBJECT_TYPE_RENDER_PASS) 1508bf215546Sopenharmony_ci 1509bf215546Sopenharmony_ci/** 1510bf215546Sopenharmony_ci * Warn on ignored extension structs. 1511bf215546Sopenharmony_ci * 1512bf215546Sopenharmony_ci * The Vulkan spec requires us to ignore unsupported or unknown structs in 1513bf215546Sopenharmony_ci * a pNext chain. In debug mode, emitting warnings for ignored structs may 1514bf215546Sopenharmony_ci * help us discover structs that we should not have ignored. 1515bf215546Sopenharmony_ci * 1516bf215546Sopenharmony_ci * 1517bf215546Sopenharmony_ci * From the Vulkan 1.0.38 spec: 1518bf215546Sopenharmony_ci * 1519bf215546Sopenharmony_ci * Any component of the implementation (the loader, any enabled layers, 1520bf215546Sopenharmony_ci * and drivers) must skip over, without processing (other than reading the 1521bf215546Sopenharmony_ci * sType and pNext members) any chained structures with sType values not 1522bf215546Sopenharmony_ci * defined by extensions supported by that component. 1523bf215546Sopenharmony_ci */ 1524bf215546Sopenharmony_ci#define pvr_debug_ignored_stype(sType) \ 1525bf215546Sopenharmony_ci mesa_logd("%s: ignored VkStructureType %u\n", __func__, (sType)) 1526bf215546Sopenharmony_ci 1527bf215546Sopenharmony_ci/* Debug helper macros. */ 1528bf215546Sopenharmony_ci#define PVR_CHECK_COMMAND_BUFFER_BUILDING_STATE(cmd_buffer) \ 1529bf215546Sopenharmony_ci do { \ 1530bf215546Sopenharmony_ci struct pvr_cmd_buffer *const _cmd_buffer = (cmd_buffer); \ 1531bf215546Sopenharmony_ci if (_cmd_buffer->status != PVR_CMD_BUFFER_STATUS_RECORDING) { \ 1532bf215546Sopenharmony_ci vk_errorf(_cmd_buffer, \ 1533bf215546Sopenharmony_ci VK_ERROR_OUT_OF_DEVICE_MEMORY, \ 1534bf215546Sopenharmony_ci "Command buffer is not in recording state"); \ 1535bf215546Sopenharmony_ci return; \ 1536bf215546Sopenharmony_ci } else if (_cmd_buffer->state.status < VK_SUCCESS) { \ 1537bf215546Sopenharmony_ci vk_errorf(_cmd_buffer, \ 1538bf215546Sopenharmony_ci _cmd_buffer->state.status, \ 1539bf215546Sopenharmony_ci "Skipping function as command buffer has " \ 1540bf215546Sopenharmony_ci "previous build error"); \ 1541bf215546Sopenharmony_ci return; \ 1542bf215546Sopenharmony_ci } \ 1543bf215546Sopenharmony_ci } while (0) 1544bf215546Sopenharmony_ci 1545bf215546Sopenharmony_ci/** 1546bf215546Sopenharmony_ci * Print a FINISHME message, including its source location. 1547bf215546Sopenharmony_ci */ 1548bf215546Sopenharmony_ci#define pvr_finishme(format, ...) \ 1549bf215546Sopenharmony_ci do { \ 1550bf215546Sopenharmony_ci static bool reported = false; \ 1551bf215546Sopenharmony_ci if (!reported) { \ 1552bf215546Sopenharmony_ci mesa_logw("%s:%d: FINISHME: " format, \ 1553bf215546Sopenharmony_ci __FILE__, \ 1554bf215546Sopenharmony_ci __LINE__, \ 1555bf215546Sopenharmony_ci ##__VA_ARGS__); \ 1556bf215546Sopenharmony_ci reported = true; \ 1557bf215546Sopenharmony_ci } \ 1558bf215546Sopenharmony_ci } while (false) 1559bf215546Sopenharmony_ci 1560bf215546Sopenharmony_ci/* A non-fatal assert. Useful for debugging. */ 1561bf215546Sopenharmony_ci#ifdef DEBUG 1562bf215546Sopenharmony_ci# define pvr_assert(x) \ 1563bf215546Sopenharmony_ci ({ \ 1564bf215546Sopenharmony_ci if (unlikely(!(x))) \ 1565bf215546Sopenharmony_ci mesa_loge("%s:%d ASSERT: %s", __FILE__, __LINE__, #x); \ 1566bf215546Sopenharmony_ci }) 1567bf215546Sopenharmony_ci#else 1568bf215546Sopenharmony_ci# define pvr_assert(x) 1569bf215546Sopenharmony_ci#endif 1570bf215546Sopenharmony_ci 1571bf215546Sopenharmony_ci#endif /* PVR_PRIVATE_H */ 1572