1 /* 2 * Copyright 2019 Google LLC 3 * SPDX-License-Identifier: MIT 4 * 5 * based in part on anv and radv which are: 6 * Copyright © 2015 Intel Corporation 7 * Copyright © 2016 Red Hat. 8 * Copyright © 2016 Bas Nieuwenhuizen 9 */ 10 11 #ifndef VN_PHYSICAL_DEVICE_H 12 #define VN_PHYSICAL_DEVICE_H 13 14 #include "vn_common.h" 15 16 #include "util/sparse_array.h" 17 18 #include "vn_wsi.h" 19 20 struct vn_format_properties_entry { 21 atomic_bool valid; 22 VkFormatProperties properties; 23 atomic_bool props3_valid; 24 VkFormatProperties3 properties3; 25 }; 26 27 struct vn_image_format_properties { 28 struct VkImageFormatProperties2 format; 29 VkResult cached_result; 30 31 VkExternalImageFormatProperties ext_image; 32 VkImageCompressionPropertiesEXT compression; 33 VkSamplerYcbcrConversionImageFormatProperties ycbcr_conversion; 34 }; 35 36 struct vn_image_format_cache_entry { 37 struct vn_image_format_properties properties; 38 uint8_t key[SHA1_DIGEST_LENGTH]; 39 struct list_head head; 40 }; 41 42 struct vn_image_format_properties_cache { 43 struct hash_table *ht; 44 struct list_head lru; 45 simple_mtx_t mutex; 46 47 struct { 48 uint32_t cache_hit_count; 49 uint32_t cache_miss_count; 50 uint32_t cache_skip_count; 51 } debug; 52 }; 53 54 struct vn_physical_device { 55 struct vn_physical_device_base base; 56 57 struct vn_instance *instance; 58 59 /* Between the driver and the app, properties.properties.apiVersion is what 60 * we advertise and is capped by VN_MAX_API_VERSION and others. 61 * 62 * Between the driver and the renderer, renderer_version is the device 63 * version we can use internally. 64 */ 65 uint32_t renderer_version; 66 67 /* Between the driver and the app, base.base.supported_extensions is what 68 * we advertise. 69 * 70 * Between the driver and the renderer, renderer_extensions is what we can 71 * use internally (after enabling). 72 */ 73 struct vk_device_extension_table renderer_extensions; 74 uint32_t *extension_spec_versions; 75 76 /* Venus feedback encounters cacheline overflush issue on Intel JSL, and 77 * has to workaround by further aligning up the feedback buffer alignment. 78 */ 79 uint32_t wa_min_fb_align; 80 81 enum VkDriverId renderer_driver_id; 82 83 VkQueueFamilyProperties2 *queue_family_properties; 84 uint32_t queue_family_count; 85 bool sparse_binding_disabled; 86 87 VkPhysicalDeviceMemoryProperties memory_properties; 88 89 struct { 90 VkExternalMemoryHandleTypeFlagBits renderer_handle_type; 91 VkExternalMemoryHandleTypeFlags supported_handle_types; 92 } external_memory; 93 94 struct { 95 bool fence_exportable; 96 bool semaphore_exportable; 97 bool semaphore_importable; 98 } renderer_sync_fd; 99 100 VkExternalFenceHandleTypeFlags external_fence_handles; 101 VkExternalSemaphoreHandleTypeFlags external_binary_semaphore_handles; 102 VkExternalSemaphoreHandleTypeFlags external_timeline_semaphore_handles; 103 104 struct wsi_device wsi_device; 105 106 simple_mtx_t format_update_mutex; 107 struct util_sparse_array format_properties; 108 109 struct vn_image_format_properties_cache image_format_cache; 110 }; 111 VK_DEFINE_HANDLE_CASTS(vn_physical_device, 112 base.base.base, 113 VkPhysicalDevice, 114 VK_OBJECT_TYPE_PHYSICAL_DEVICE) 115 116 void 117 vn_physical_device_fini(struct vn_physical_device *physical_dev); 118 119 #endif /* VN_PHYSICAL_DEVICE_H */ 120