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_physical_device_properties { 21 VkPhysicalDeviceProperties vulkan_1_0; 22 VkPhysicalDeviceVulkan11Properties vulkan_1_1; 23 VkPhysicalDeviceVulkan12Properties vulkan_1_2; 24 VkPhysicalDeviceVulkan13Properties vulkan_1_3; 25 26 /* KHR */ 27 VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor; 28 29 /* EXT */ 30 VkPhysicalDeviceConservativeRasterizationPropertiesEXT 31 conservative_rasterization; 32 VkPhysicalDeviceCustomBorderColorPropertiesEXT custom_border_color; 33 VkPhysicalDeviceExtendedDynamicState3PropertiesEXT extended_dynamic_state_3; 34 VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT 35 graphics_pipeline_library; 36 VkPhysicalDeviceLineRasterizationPropertiesEXT line_rasterization; 37 VkPhysicalDeviceMultiDrawPropertiesEXT multi_draw; 38 VkPhysicalDevicePCIBusInfoPropertiesEXT pci_bus_info; 39 VkPhysicalDeviceProvokingVertexPropertiesEXT provoking_vertex; 40 VkPhysicalDeviceRobustness2PropertiesEXT robustness_2; 41 VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback; 42 VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT 43 vertex_attribute_divisor; 44 }; 45 46 struct vn_format_properties_entry { 47 atomic_bool valid; 48 VkFormatProperties properties; 49 }; 50 51 struct vn_image_format_properties { 52 struct VkImageFormatProperties2 format; 53 VkResult cached_result; 54 55 VkExternalImageFormatProperties ext_image; 56 VkImageCompressionPropertiesEXT compression; 57 VkSamplerYcbcrConversionImageFormatProperties ycbcr_conversion; 58 }; 59 60 struct vn_image_format_cache_entry { 61 struct vn_image_format_properties properties; 62 uint8_t key[SHA1_DIGEST_LENGTH]; 63 struct list_head head; 64 }; 65 66 struct vn_image_format_properties_cache { 67 struct hash_table *ht; 68 struct list_head lru; 69 simple_mtx_t mutex; 70 71 struct { 72 uint32_t cache_hit_count; 73 uint32_t cache_miss_count; 74 uint32_t cache_skip_count; 75 } debug; 76 }; 77 78 struct vn_physical_device { 79 struct vn_physical_device_base base; 80 81 struct vn_instance *instance; 82 83 /* Between the driver and the app, properties.properties.apiVersion is what 84 * we advertise and is capped by VN_MAX_API_VERSION and others. 85 * 86 * Between the driver and the renderer, renderer_version is the device 87 * version we can use internally. 88 */ 89 uint32_t renderer_version; 90 91 /* Between the driver and the app, base.base.supported_extensions is what 92 * we advertise. 93 * 94 * Between the driver and the renderer, renderer_extensions is what we can 95 * use internally (after enabling). 96 */ 97 struct vk_device_extension_table renderer_extensions; 98 uint32_t *extension_spec_versions; 99 100 struct vn_physical_device_properties properties; 101 enum VkDriverId renderer_driver_id; 102 103 VkQueueFamilyProperties2 *queue_family_properties; 104 uint32_t queue_family_count; 105 bool sparse_binding_disabled; 106 107 VkPhysicalDeviceMemoryProperties memory_properties; 108 uint32_t coherent_uncached; 109 uint32_t incoherent_cached; 110 111 struct { 112 VkExternalMemoryHandleTypeFlagBits renderer_handle_type; 113 VkExternalMemoryHandleTypeFlags supported_handle_types; 114 } external_memory; 115 116 struct { 117 bool fence_exportable; 118 bool semaphore_exportable; 119 bool semaphore_importable; 120 } renderer_sync_fd; 121 122 VkExternalFenceHandleTypeFlags external_fence_handles; 123 VkExternalSemaphoreHandleTypeFlags external_binary_semaphore_handles; 124 VkExternalSemaphoreHandleTypeFlags external_timeline_semaphore_handles; 125 126 struct wsi_device wsi_device; 127 128 simple_mtx_t format_update_mutex; 129 struct util_sparse_array format_properties; 130 131 struct vn_image_format_properties_cache image_format_cache; 132 }; 133 VK_DEFINE_HANDLE_CASTS(vn_physical_device, 134 base.base.base, 135 VkPhysicalDevice, 136 VK_OBJECT_TYPE_PHYSICAL_DEVICE) 137 138 void 139 vn_physical_device_fini(struct vn_physical_device *physical_dev); 140 141 #endif /* VN_PHYSICAL_DEVICE_H */ 142