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_features { 21 VkPhysicalDeviceFeatures vulkan_1_0; 22 VkPhysicalDeviceVulkan11Features vulkan_1_1; 23 VkPhysicalDeviceVulkan12Features vulkan_1_2; 24 25 /* Vulkan 1.3 */ 26 VkPhysicalDevice4444FormatsFeaturesEXT argb_4444_formats; 27 VkPhysicalDeviceDynamicRenderingFeatures dynamic_rendering; 28 VkPhysicalDeviceExtendedDynamicStateFeaturesEXT extended_dynamic_state; 29 VkPhysicalDeviceExtendedDynamicState2FeaturesEXT extended_dynamic_state_2; 30 VkPhysicalDeviceImageRobustnessFeatures image_robustness; 31 VkPhysicalDeviceInlineUniformBlockFeatures inline_uniform_block; 32 VkPhysicalDeviceMaintenance4Features maintenance4; 33 VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures 34 shader_demote_to_helper_invocation; 35 36 /* EXT */ 37 VkPhysicalDeviceConditionalRenderingFeaturesEXT conditional_rendering; 38 VkPhysicalDeviceCustomBorderColorFeaturesEXT custom_border_color; 39 VkPhysicalDeviceDepthClipEnableFeaturesEXT depth_clip_enable; 40 VkPhysicalDeviceImageViewMinLodFeaturesEXT image_view_min_lod; 41 VkPhysicalDeviceIndexTypeUint8FeaturesEXT index_type_uint8; 42 VkPhysicalDeviceLineRasterizationFeaturesEXT line_rasterization; 43 VkPhysicalDeviceProvokingVertexFeaturesEXT provoking_vertex; 44 VkPhysicalDeviceRobustness2FeaturesEXT robustness_2; 45 VkPhysicalDeviceTransformFeedbackFeaturesEXT transform_feedback; 46 VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT vertex_attribute_divisor; 47 }; 48 49 struct vn_physical_device_properties { 50 VkPhysicalDeviceProperties vulkan_1_0; 51 VkPhysicalDeviceVulkan11Properties vulkan_1_1; 52 VkPhysicalDeviceVulkan12Properties vulkan_1_2; 53 54 /* Vulkan 1.3 */ 55 VkPhysicalDeviceInlineUniformBlockProperties inline_uniform_block; 56 VkPhysicalDeviceMaintenance4Properties maintenance4; 57 58 /* EXT */ 59 VkPhysicalDeviceConservativeRasterizationPropertiesEXT 60 conservative_rasterization; 61 VkPhysicalDeviceCustomBorderColorPropertiesEXT custom_border_color; 62 VkPhysicalDeviceLineRasterizationPropertiesEXT line_rasterization; 63 VkPhysicalDeviceProvokingVertexPropertiesEXT provoking_vertex; 64 VkPhysicalDeviceRobustness2PropertiesEXT robustness_2; 65 VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback; 66 VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT 67 vertex_attribute_divisor; 68 }; 69 70 struct vn_format_properties_entry { 71 atomic_bool valid; 72 VkFormatProperties properties; 73 }; 74 75 struct vn_physical_device { 76 struct vn_physical_device_base base; 77 78 struct vn_instance *instance; 79 80 /* Between the driver and the app, properties.properties.apiVersion is what 81 * we advertise and is capped by VN_MAX_API_VERSION and others. 82 * 83 * Between the driver and the renderer, renderer_version is the device 84 * version we can use internally. 85 */ 86 uint32_t renderer_version; 87 88 /* Between the driver and the app, base.base.supported_extensions is what 89 * we advertise. 90 * 91 * Between the driver and the renderer, renderer_extensions is what we can 92 * use internally (after enabling). 93 */ 94 struct vk_device_extension_table renderer_extensions; 95 uint32_t *extension_spec_versions; 96 97 struct vn_physical_device_features features; 98 struct vn_physical_device_properties properties; 99 100 VkQueueFamilyProperties2 *queue_family_properties; 101 uint32_t queue_family_count; 102 103 VkPhysicalDeviceMemoryProperties2 memory_properties; 104 105 struct { 106 VkExternalMemoryHandleTypeFlagBits renderer_handle_type; 107 VkExternalMemoryHandleTypeFlags supported_handle_types; 108 } external_memory; 109 110 VkExternalFenceHandleTypeFlags external_fence_handles; 111 VkExternalSemaphoreHandleTypeFlags external_binary_semaphore_handles; 112 VkExternalSemaphoreHandleTypeFlags external_timeline_semaphore_handles; 113 114 struct wsi_device wsi_device; 115 116 simple_mtx_t format_update_mutex; 117 struct util_sparse_array format_properties; 118 }; 119 VK_DEFINE_HANDLE_CASTS(vn_physical_device, 120 base.base.base, 121 VkPhysicalDevice, 122 VK_OBJECT_TYPE_PHYSICAL_DEVICE) 123 124 void 125 vn_physical_device_fini(struct vn_physical_device *physical_dev); 126 127 #endif /* VN_PHYSICAL_DEVICE_H */ 128