1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright 2019 Google LLC
3bf215546Sopenharmony_ci * SPDX-License-Identifier: MIT
4bf215546Sopenharmony_ci *
5bf215546Sopenharmony_ci * based in part on anv and radv which are:
6bf215546Sopenharmony_ci * Copyright © 2015 Intel Corporation
7bf215546Sopenharmony_ci * Copyright © 2016 Red Hat.
8bf215546Sopenharmony_ci * Copyright © 2016 Bas Nieuwenhuizen
9bf215546Sopenharmony_ci */
10bf215546Sopenharmony_ci
11bf215546Sopenharmony_ci#include "vn_physical_device.h"
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ci#include <stdio.h>
14bf215546Sopenharmony_ci
15bf215546Sopenharmony_ci#include "git_sha1.h"
16bf215546Sopenharmony_ci#include "util/mesa-sha1.h"
17bf215546Sopenharmony_ci#include "venus-protocol/vn_protocol_driver_device.h"
18bf215546Sopenharmony_ci
19bf215546Sopenharmony_ci#include "vn_android.h"
20bf215546Sopenharmony_ci#include "vn_instance.h"
21bf215546Sopenharmony_ci
22bf215546Sopenharmony_ci#define VN_EXTENSION_TABLE_INDEX(tbl, ext)                                   \
23bf215546Sopenharmony_ci   ((const bool *)((const void *)(&(tbl)) +                                  \
24bf215546Sopenharmony_ci                   offsetof(__typeof__(tbl), ext)) -                         \
25bf215546Sopenharmony_ci    (tbl).extensions)
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci#define VN_PREFIX_STYPE(stype) (VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_##stype)
28bf215546Sopenharmony_ci#define VN_ADD_TO_PNEXT(elem, s_type, head)                                  \
29bf215546Sopenharmony_ci   do {                                                                      \
30bf215546Sopenharmony_ci      (elem).sType = VN_PREFIX_STYPE(s_type);                                \
31bf215546Sopenharmony_ci      (elem).pNext = (head).pNext;                                           \
32bf215546Sopenharmony_ci      (head).pNext = &(elem);                                                \
33bf215546Sopenharmony_ci   } while (0)
34bf215546Sopenharmony_ci#define VN_ADD_EXT_TO_PNEXT(ext, elem, s_type, head)                         \
35bf215546Sopenharmony_ci   if (ext) VN_ADD_TO_PNEXT(elem, s_type, head)
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_cistatic void
38bf215546Sopenharmony_civn_physical_device_init_features(struct vn_physical_device *physical_dev)
39bf215546Sopenharmony_ci{
40bf215546Sopenharmony_ci   struct vn_physical_device_features *feats = &physical_dev->features;
41bf215546Sopenharmony_ci   struct vn_instance *instance = physical_dev->instance;
42bf215546Sopenharmony_ci   const struct vk_device_extension_table *exts =
43bf215546Sopenharmony_ci      &physical_dev->renderer_extensions;
44bf215546Sopenharmony_ci   VkPhysicalDeviceFeatures2 features2 = {
45bf215546Sopenharmony_ci      .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
46bf215546Sopenharmony_ci   };
47bf215546Sopenharmony_ci   struct {
48bf215546Sopenharmony_ci      /* Vulkan 1.1 */
49bf215546Sopenharmony_ci      VkPhysicalDevice16BitStorageFeatures sixteen_bit_storage;
50bf215546Sopenharmony_ci      VkPhysicalDeviceMultiviewFeatures multiview;
51bf215546Sopenharmony_ci      VkPhysicalDeviceVariablePointersFeatures variable_pointers;
52bf215546Sopenharmony_ci      VkPhysicalDeviceProtectedMemoryFeatures protected_memory;
53bf215546Sopenharmony_ci      VkPhysicalDeviceSamplerYcbcrConversionFeatures sampler_ycbcr_conversion;
54bf215546Sopenharmony_ci      VkPhysicalDeviceShaderDrawParametersFeatures shader_draw_parameters;
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci      /* Vulkan 1.2 */
57bf215546Sopenharmony_ci      VkPhysicalDevice8BitStorageFeatures eight_bit_storage;
58bf215546Sopenharmony_ci      VkPhysicalDeviceShaderAtomicInt64Features shader_atomic_int64;
59bf215546Sopenharmony_ci      VkPhysicalDeviceShaderFloat16Int8Features shader_float16_int8;
60bf215546Sopenharmony_ci      VkPhysicalDeviceDescriptorIndexingFeatures descriptor_indexing;
61bf215546Sopenharmony_ci      VkPhysicalDeviceScalarBlockLayoutFeatures scalar_block_layout;
62bf215546Sopenharmony_ci      VkPhysicalDeviceImagelessFramebufferFeatures imageless_framebuffer;
63bf215546Sopenharmony_ci      VkPhysicalDeviceUniformBufferStandardLayoutFeatures
64bf215546Sopenharmony_ci         uniform_buffer_standard_layout;
65bf215546Sopenharmony_ci      VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures
66bf215546Sopenharmony_ci         shader_subgroup_extended_types;
67bf215546Sopenharmony_ci      VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures
68bf215546Sopenharmony_ci         separate_depth_stencil_layouts;
69bf215546Sopenharmony_ci      VkPhysicalDeviceHostQueryResetFeatures host_query_reset;
70bf215546Sopenharmony_ci      VkPhysicalDeviceTimelineSemaphoreFeatures timeline_semaphore;
71bf215546Sopenharmony_ci      VkPhysicalDeviceBufferDeviceAddressFeatures buffer_device_address;
72bf215546Sopenharmony_ci      VkPhysicalDeviceVulkanMemoryModelFeatures vulkan_memory_model;
73bf215546Sopenharmony_ci   } local_feats;
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci   if (physical_dev->renderer_version >= VK_API_VERSION_1_2) {
76bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(feats->vulkan_1_1, VULKAN_1_1_FEATURES, features2);
77bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(feats->vulkan_1_2, VULKAN_1_2_FEATURES, features2);
78bf215546Sopenharmony_ci   } else {
79bf215546Sopenharmony_ci      /* Vulkan 1.1 */
80bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.sixteen_bit_storage, 16BIT_STORAGE_FEATURES,
81bf215546Sopenharmony_ci                      features2);
82bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.multiview, MULTIVIEW_FEATURES, features2);
83bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.variable_pointers,
84bf215546Sopenharmony_ci                      VARIABLE_POINTERS_FEATURES, features2);
85bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.protected_memory, PROTECTED_MEMORY_FEATURES,
86bf215546Sopenharmony_ci                      features2);
87bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.sampler_ycbcr_conversion,
88bf215546Sopenharmony_ci                      SAMPLER_YCBCR_CONVERSION_FEATURES, features2);
89bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.shader_draw_parameters,
90bf215546Sopenharmony_ci                      SHADER_DRAW_PARAMETERS_FEATURES, features2);
91bf215546Sopenharmony_ci
92bf215546Sopenharmony_ci      /* Vulkan 1.2 */
93bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.eight_bit_storage, 8BIT_STORAGE_FEATURES,
94bf215546Sopenharmony_ci                      features2);
95bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.shader_atomic_int64,
96bf215546Sopenharmony_ci                      SHADER_ATOMIC_INT64_FEATURES, features2);
97bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.shader_float16_int8,
98bf215546Sopenharmony_ci                      SHADER_FLOAT16_INT8_FEATURES, features2);
99bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.descriptor_indexing,
100bf215546Sopenharmony_ci                      DESCRIPTOR_INDEXING_FEATURES, features2);
101bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.scalar_block_layout,
102bf215546Sopenharmony_ci                      SCALAR_BLOCK_LAYOUT_FEATURES, features2);
103bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.imageless_framebuffer,
104bf215546Sopenharmony_ci                      IMAGELESS_FRAMEBUFFER_FEATURES, features2);
105bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.uniform_buffer_standard_layout,
106bf215546Sopenharmony_ci                      UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES, features2);
107bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.shader_subgroup_extended_types,
108bf215546Sopenharmony_ci                      SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES, features2);
109bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.separate_depth_stencil_layouts,
110bf215546Sopenharmony_ci                      SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES, features2);
111bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.host_query_reset, HOST_QUERY_RESET_FEATURES,
112bf215546Sopenharmony_ci                      features2);
113bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.timeline_semaphore,
114bf215546Sopenharmony_ci                      TIMELINE_SEMAPHORE_FEATURES, features2);
115bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.buffer_device_address,
116bf215546Sopenharmony_ci                      BUFFER_DEVICE_ADDRESS_FEATURES, features2);
117bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_feats.vulkan_memory_model,
118bf215546Sopenharmony_ci                      VULKAN_MEMORY_MODEL_FEATURES, features2);
119bf215546Sopenharmony_ci   }
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_ci   /* Vulkan 1.3 */
122bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_4444_formats, feats->argb_4444_formats,
123bf215546Sopenharmony_ci                       4444_FORMATS_FEATURES_EXT, features2);
124bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_extended_dynamic_state,
125bf215546Sopenharmony_ci                       feats->extended_dynamic_state,
126bf215546Sopenharmony_ci                       EXTENDED_DYNAMIC_STATE_FEATURES_EXT, features2);
127bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_extended_dynamic_state2,
128bf215546Sopenharmony_ci                       feats->extended_dynamic_state_2,
129bf215546Sopenharmony_ci                       EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT, features2);
130bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_image_robustness, feats->image_robustness,
131bf215546Sopenharmony_ci                       IMAGE_ROBUSTNESS_FEATURES_EXT, features2);
132bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_inline_uniform_block,
133bf215546Sopenharmony_ci                       feats->inline_uniform_block,
134bf215546Sopenharmony_ci                       INLINE_UNIFORM_BLOCK_FEATURES, features2);
135bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->KHR_dynamic_rendering, feats->dynamic_rendering,
136bf215546Sopenharmony_ci                       DYNAMIC_RENDERING_FEATURES, features2);
137bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->KHR_maintenance4, feats->maintenance4,
138bf215546Sopenharmony_ci                       MAINTENANCE_4_FEATURES, features2);
139bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_shader_demote_to_helper_invocation,
140bf215546Sopenharmony_ci                       feats->shader_demote_to_helper_invocation,
141bf215546Sopenharmony_ci                       SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES,
142bf215546Sopenharmony_ci                       features2);
143bf215546Sopenharmony_ci
144bf215546Sopenharmony_ci   /* EXT */
145bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_conditional_rendering,
146bf215546Sopenharmony_ci                       feats->conditional_rendering,
147bf215546Sopenharmony_ci                       CONDITIONAL_RENDERING_FEATURES_EXT, features2);
148bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_custom_border_color,
149bf215546Sopenharmony_ci                       feats->custom_border_color,
150bf215546Sopenharmony_ci                       CUSTOM_BORDER_COLOR_FEATURES_EXT, features2);
151bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_depth_clip_enable, feats->depth_clip_enable,
152bf215546Sopenharmony_ci                       DEPTH_CLIP_ENABLE_FEATURES_EXT, features2);
153bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_image_view_min_lod, feats->image_view_min_lod,
154bf215546Sopenharmony_ci                       IMAGE_VIEW_MIN_LOD_FEATURES_EXT, features2);
155bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_index_type_uint8, feats->index_type_uint8,
156bf215546Sopenharmony_ci                       INDEX_TYPE_UINT8_FEATURES_EXT, features2);
157bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_line_rasterization,
158bf215546Sopenharmony_ci                       feats->line_rasterization,
159bf215546Sopenharmony_ci                       LINE_RASTERIZATION_FEATURES_EXT, features2);
160bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_provoking_vertex, feats->provoking_vertex,
161bf215546Sopenharmony_ci                       PROVOKING_VERTEX_FEATURES_EXT, features2);
162bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_robustness2, feats->robustness_2,
163bf215546Sopenharmony_ci                       ROBUSTNESS_2_FEATURES_EXT, features2);
164bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_transform_feedback,
165bf215546Sopenharmony_ci                       feats->transform_feedback,
166bf215546Sopenharmony_ci                       TRANSFORM_FEEDBACK_FEATURES_EXT, features2);
167bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_vertex_attribute_divisor,
168bf215546Sopenharmony_ci                       feats->vertex_attribute_divisor,
169bf215546Sopenharmony_ci                       VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT, features2);
170bf215546Sopenharmony_ci
171bf215546Sopenharmony_ci   vn_call_vkGetPhysicalDeviceFeatures2(
172bf215546Sopenharmony_ci      instance, vn_physical_device_to_handle(physical_dev), &features2);
173bf215546Sopenharmony_ci
174bf215546Sopenharmony_ci   feats->vulkan_1_0 = features2.features;
175bf215546Sopenharmony_ci
176bf215546Sopenharmony_ci   /* TODO allow sparse resource along with sync feedback
177bf215546Sopenharmony_ci    *
178bf215546Sopenharmony_ci    * vkQueueBindSparse relies on explicit sync primitives. To intercept the
179bf215546Sopenharmony_ci    * timeline semaphores within each bind info to write the feedback buffer,
180bf215546Sopenharmony_ci    * we have to split the call into bindInfoCount number of calls while
181bf215546Sopenharmony_ci    * inserting vkQueueSubmit to wait on the signal timeline semaphores before
182bf215546Sopenharmony_ci    * filling the feedback buffer. To intercept the fence to be signaled, we
183bf215546Sopenharmony_ci    * have to relocate the fence to another vkQueueSubmit call and potentially
184bf215546Sopenharmony_ci    * have to use an internal timeline semaphore to synchronize between them.
185bf215546Sopenharmony_ci    * Those would make the code overly complex, so we disable sparse binding
186bf215546Sopenharmony_ci    * for simplicity.
187bf215546Sopenharmony_ci    */
188bf215546Sopenharmony_ci   if (!VN_PERF(NO_FENCE_FEEDBACK)) {
189bf215546Sopenharmony_ci      feats->vulkan_1_0.sparseBinding = false;
190bf215546Sopenharmony_ci      feats->vulkan_1_0.sparseResidencyBuffer = false;
191bf215546Sopenharmony_ci      feats->vulkan_1_0.sparseResidencyImage2D = false;
192bf215546Sopenharmony_ci      feats->vulkan_1_0.sparseResidencyImage3D = false;
193bf215546Sopenharmony_ci      feats->vulkan_1_0.sparseResidency2Samples = false;
194bf215546Sopenharmony_ci      feats->vulkan_1_0.sparseResidency4Samples = false;
195bf215546Sopenharmony_ci      feats->vulkan_1_0.sparseResidency8Samples = false;
196bf215546Sopenharmony_ci      feats->vulkan_1_0.sparseResidency16Samples = false;
197bf215546Sopenharmony_ci      feats->vulkan_1_0.sparseResidencyAliased = false;
198bf215546Sopenharmony_ci   }
199bf215546Sopenharmony_ci
200bf215546Sopenharmony_ci   struct VkPhysicalDeviceVulkan11Features *vk11_feats = &feats->vulkan_1_1;
201bf215546Sopenharmony_ci   struct VkPhysicalDeviceVulkan12Features *vk12_feats = &feats->vulkan_1_2;
202bf215546Sopenharmony_ci
203bf215546Sopenharmony_ci   if (physical_dev->renderer_version < VK_API_VERSION_1_2) {
204bf215546Sopenharmony_ci      vk11_feats->storageBuffer16BitAccess =
205bf215546Sopenharmony_ci         local_feats.sixteen_bit_storage.storageBuffer16BitAccess;
206bf215546Sopenharmony_ci      vk11_feats->uniformAndStorageBuffer16BitAccess =
207bf215546Sopenharmony_ci         local_feats.sixteen_bit_storage.uniformAndStorageBuffer16BitAccess;
208bf215546Sopenharmony_ci      vk11_feats->storagePushConstant16 =
209bf215546Sopenharmony_ci         local_feats.sixteen_bit_storage.storagePushConstant16;
210bf215546Sopenharmony_ci      vk11_feats->storageInputOutput16 =
211bf215546Sopenharmony_ci         local_feats.sixteen_bit_storage.storageInputOutput16;
212bf215546Sopenharmony_ci
213bf215546Sopenharmony_ci      vk11_feats->multiview = local_feats.multiview.multiview;
214bf215546Sopenharmony_ci      vk11_feats->multiviewGeometryShader =
215bf215546Sopenharmony_ci         local_feats.multiview.multiviewGeometryShader;
216bf215546Sopenharmony_ci      vk11_feats->multiviewTessellationShader =
217bf215546Sopenharmony_ci         local_feats.multiview.multiviewTessellationShader;
218bf215546Sopenharmony_ci
219bf215546Sopenharmony_ci      vk11_feats->variablePointersStorageBuffer =
220bf215546Sopenharmony_ci         local_feats.variable_pointers.variablePointersStorageBuffer;
221bf215546Sopenharmony_ci      vk11_feats->variablePointers =
222bf215546Sopenharmony_ci         local_feats.variable_pointers.variablePointers;
223bf215546Sopenharmony_ci
224bf215546Sopenharmony_ci      vk11_feats->protectedMemory =
225bf215546Sopenharmony_ci         local_feats.protected_memory.protectedMemory;
226bf215546Sopenharmony_ci
227bf215546Sopenharmony_ci      vk11_feats->samplerYcbcrConversion =
228bf215546Sopenharmony_ci         local_feats.sampler_ycbcr_conversion.samplerYcbcrConversion;
229bf215546Sopenharmony_ci
230bf215546Sopenharmony_ci      vk11_feats->shaderDrawParameters =
231bf215546Sopenharmony_ci         local_feats.shader_draw_parameters.shaderDrawParameters;
232bf215546Sopenharmony_ci
233bf215546Sopenharmony_ci      vk12_feats->samplerMirrorClampToEdge =
234bf215546Sopenharmony_ci         exts->KHR_sampler_mirror_clamp_to_edge;
235bf215546Sopenharmony_ci      vk12_feats->drawIndirectCount = exts->KHR_draw_indirect_count;
236bf215546Sopenharmony_ci
237bf215546Sopenharmony_ci      if (exts->KHR_8bit_storage) {
238bf215546Sopenharmony_ci         vk12_feats->storageBuffer8BitAccess =
239bf215546Sopenharmony_ci            local_feats.eight_bit_storage.storageBuffer8BitAccess;
240bf215546Sopenharmony_ci         vk12_feats->uniformAndStorageBuffer8BitAccess =
241bf215546Sopenharmony_ci            local_feats.eight_bit_storage.uniformAndStorageBuffer8BitAccess;
242bf215546Sopenharmony_ci         vk12_feats->storagePushConstant8 =
243bf215546Sopenharmony_ci            local_feats.eight_bit_storage.storagePushConstant8;
244bf215546Sopenharmony_ci      }
245bf215546Sopenharmony_ci      if (exts->KHR_shader_atomic_int64) {
246bf215546Sopenharmony_ci         vk12_feats->shaderBufferInt64Atomics =
247bf215546Sopenharmony_ci            local_feats.shader_atomic_int64.shaderBufferInt64Atomics;
248bf215546Sopenharmony_ci         vk12_feats->shaderSharedInt64Atomics =
249bf215546Sopenharmony_ci            local_feats.shader_atomic_int64.shaderSharedInt64Atomics;
250bf215546Sopenharmony_ci      }
251bf215546Sopenharmony_ci      if (exts->KHR_shader_float16_int8) {
252bf215546Sopenharmony_ci         vk12_feats->shaderFloat16 =
253bf215546Sopenharmony_ci            local_feats.shader_float16_int8.shaderFloat16;
254bf215546Sopenharmony_ci         vk12_feats->shaderInt8 = local_feats.shader_float16_int8.shaderInt8;
255bf215546Sopenharmony_ci      }
256bf215546Sopenharmony_ci      if (exts->EXT_descriptor_indexing) {
257bf215546Sopenharmony_ci         vk12_feats->descriptorIndexing = true;
258bf215546Sopenharmony_ci         vk12_feats->shaderInputAttachmentArrayDynamicIndexing =
259bf215546Sopenharmony_ci            local_feats.descriptor_indexing
260bf215546Sopenharmony_ci               .shaderInputAttachmentArrayDynamicIndexing;
261bf215546Sopenharmony_ci         vk12_feats->shaderUniformTexelBufferArrayDynamicIndexing =
262bf215546Sopenharmony_ci            local_feats.descriptor_indexing
263bf215546Sopenharmony_ci               .shaderUniformTexelBufferArrayDynamicIndexing;
264bf215546Sopenharmony_ci         vk12_feats->shaderStorageTexelBufferArrayDynamicIndexing =
265bf215546Sopenharmony_ci            local_feats.descriptor_indexing
266bf215546Sopenharmony_ci               .shaderStorageTexelBufferArrayDynamicIndexing;
267bf215546Sopenharmony_ci         vk12_feats->shaderUniformBufferArrayNonUniformIndexing =
268bf215546Sopenharmony_ci            local_feats.descriptor_indexing
269bf215546Sopenharmony_ci               .shaderUniformBufferArrayNonUniformIndexing;
270bf215546Sopenharmony_ci         vk12_feats->shaderSampledImageArrayNonUniformIndexing =
271bf215546Sopenharmony_ci            local_feats.descriptor_indexing
272bf215546Sopenharmony_ci               .shaderSampledImageArrayNonUniformIndexing;
273bf215546Sopenharmony_ci         vk12_feats->shaderStorageBufferArrayNonUniformIndexing =
274bf215546Sopenharmony_ci            local_feats.descriptor_indexing
275bf215546Sopenharmony_ci               .shaderStorageBufferArrayNonUniformIndexing;
276bf215546Sopenharmony_ci         vk12_feats->shaderStorageImageArrayNonUniformIndexing =
277bf215546Sopenharmony_ci            local_feats.descriptor_indexing
278bf215546Sopenharmony_ci               .shaderStorageImageArrayNonUniformIndexing;
279bf215546Sopenharmony_ci         vk12_feats->shaderInputAttachmentArrayNonUniformIndexing =
280bf215546Sopenharmony_ci            local_feats.descriptor_indexing
281bf215546Sopenharmony_ci               .shaderInputAttachmentArrayNonUniformIndexing;
282bf215546Sopenharmony_ci         vk12_feats->shaderUniformTexelBufferArrayNonUniformIndexing =
283bf215546Sopenharmony_ci            local_feats.descriptor_indexing
284bf215546Sopenharmony_ci               .shaderUniformTexelBufferArrayNonUniformIndexing;
285bf215546Sopenharmony_ci         vk12_feats->shaderStorageTexelBufferArrayNonUniformIndexing =
286bf215546Sopenharmony_ci            local_feats.descriptor_indexing
287bf215546Sopenharmony_ci               .shaderStorageTexelBufferArrayNonUniformIndexing;
288bf215546Sopenharmony_ci         vk12_feats->descriptorBindingUniformBufferUpdateAfterBind =
289bf215546Sopenharmony_ci            local_feats.descriptor_indexing
290bf215546Sopenharmony_ci               .descriptorBindingUniformBufferUpdateAfterBind;
291bf215546Sopenharmony_ci         vk12_feats->descriptorBindingSampledImageUpdateAfterBind =
292bf215546Sopenharmony_ci            local_feats.descriptor_indexing
293bf215546Sopenharmony_ci               .descriptorBindingSampledImageUpdateAfterBind;
294bf215546Sopenharmony_ci         vk12_feats->descriptorBindingStorageImageUpdateAfterBind =
295bf215546Sopenharmony_ci            local_feats.descriptor_indexing
296bf215546Sopenharmony_ci               .descriptorBindingStorageImageUpdateAfterBind;
297bf215546Sopenharmony_ci         vk12_feats->descriptorBindingStorageBufferUpdateAfterBind =
298bf215546Sopenharmony_ci            local_feats.descriptor_indexing
299bf215546Sopenharmony_ci               .descriptorBindingStorageBufferUpdateAfterBind;
300bf215546Sopenharmony_ci         vk12_feats->descriptorBindingUniformTexelBufferUpdateAfterBind =
301bf215546Sopenharmony_ci            local_feats.descriptor_indexing
302bf215546Sopenharmony_ci               .descriptorBindingUniformTexelBufferUpdateAfterBind;
303bf215546Sopenharmony_ci         vk12_feats->descriptorBindingStorageTexelBufferUpdateAfterBind =
304bf215546Sopenharmony_ci            local_feats.descriptor_indexing
305bf215546Sopenharmony_ci               .descriptorBindingStorageTexelBufferUpdateAfterBind;
306bf215546Sopenharmony_ci         vk12_feats->descriptorBindingUpdateUnusedWhilePending =
307bf215546Sopenharmony_ci            local_feats.descriptor_indexing
308bf215546Sopenharmony_ci               .descriptorBindingUpdateUnusedWhilePending;
309bf215546Sopenharmony_ci         vk12_feats->descriptorBindingPartiallyBound =
310bf215546Sopenharmony_ci            local_feats.descriptor_indexing.descriptorBindingPartiallyBound;
311bf215546Sopenharmony_ci         vk12_feats->descriptorBindingVariableDescriptorCount =
312bf215546Sopenharmony_ci            local_feats.descriptor_indexing
313bf215546Sopenharmony_ci               .descriptorBindingVariableDescriptorCount;
314bf215546Sopenharmony_ci         vk12_feats->runtimeDescriptorArray =
315bf215546Sopenharmony_ci            local_feats.descriptor_indexing.runtimeDescriptorArray;
316bf215546Sopenharmony_ci      }
317bf215546Sopenharmony_ci
318bf215546Sopenharmony_ci      vk12_feats->samplerFilterMinmax = exts->EXT_sampler_filter_minmax;
319bf215546Sopenharmony_ci
320bf215546Sopenharmony_ci      if (exts->EXT_scalar_block_layout) {
321bf215546Sopenharmony_ci         vk12_feats->scalarBlockLayout =
322bf215546Sopenharmony_ci            local_feats.scalar_block_layout.scalarBlockLayout;
323bf215546Sopenharmony_ci      }
324bf215546Sopenharmony_ci      if (exts->KHR_imageless_framebuffer) {
325bf215546Sopenharmony_ci         vk12_feats->imagelessFramebuffer =
326bf215546Sopenharmony_ci            local_feats.imageless_framebuffer.imagelessFramebuffer;
327bf215546Sopenharmony_ci      }
328bf215546Sopenharmony_ci      if (exts->KHR_uniform_buffer_standard_layout) {
329bf215546Sopenharmony_ci         vk12_feats->uniformBufferStandardLayout =
330bf215546Sopenharmony_ci            local_feats.uniform_buffer_standard_layout
331bf215546Sopenharmony_ci               .uniformBufferStandardLayout;
332bf215546Sopenharmony_ci      }
333bf215546Sopenharmony_ci      if (exts->KHR_shader_subgroup_extended_types) {
334bf215546Sopenharmony_ci         vk12_feats->shaderSubgroupExtendedTypes =
335bf215546Sopenharmony_ci            local_feats.shader_subgroup_extended_types
336bf215546Sopenharmony_ci               .shaderSubgroupExtendedTypes;
337bf215546Sopenharmony_ci      }
338bf215546Sopenharmony_ci      if (exts->KHR_separate_depth_stencil_layouts) {
339bf215546Sopenharmony_ci         vk12_feats->separateDepthStencilLayouts =
340bf215546Sopenharmony_ci            local_feats.separate_depth_stencil_layouts
341bf215546Sopenharmony_ci               .separateDepthStencilLayouts;
342bf215546Sopenharmony_ci      }
343bf215546Sopenharmony_ci      if (exts->EXT_host_query_reset) {
344bf215546Sopenharmony_ci         vk12_feats->hostQueryReset =
345bf215546Sopenharmony_ci            local_feats.host_query_reset.hostQueryReset;
346bf215546Sopenharmony_ci      }
347bf215546Sopenharmony_ci      if (exts->KHR_timeline_semaphore) {
348bf215546Sopenharmony_ci         vk12_feats->timelineSemaphore =
349bf215546Sopenharmony_ci            local_feats.timeline_semaphore.timelineSemaphore;
350bf215546Sopenharmony_ci      }
351bf215546Sopenharmony_ci      if (exts->KHR_buffer_device_address) {
352bf215546Sopenharmony_ci         vk12_feats->bufferDeviceAddress =
353bf215546Sopenharmony_ci            local_feats.buffer_device_address.bufferDeviceAddress;
354bf215546Sopenharmony_ci         vk12_feats->bufferDeviceAddressCaptureReplay =
355bf215546Sopenharmony_ci            local_feats.buffer_device_address.bufferDeviceAddressCaptureReplay;
356bf215546Sopenharmony_ci         vk12_feats->bufferDeviceAddressMultiDevice =
357bf215546Sopenharmony_ci            local_feats.buffer_device_address.bufferDeviceAddressMultiDevice;
358bf215546Sopenharmony_ci      }
359bf215546Sopenharmony_ci      if (exts->KHR_vulkan_memory_model) {
360bf215546Sopenharmony_ci         vk12_feats->vulkanMemoryModel =
361bf215546Sopenharmony_ci            local_feats.vulkan_memory_model.vulkanMemoryModel;
362bf215546Sopenharmony_ci         vk12_feats->vulkanMemoryModelDeviceScope =
363bf215546Sopenharmony_ci            local_feats.vulkan_memory_model.vulkanMemoryModelDeviceScope;
364bf215546Sopenharmony_ci         vk12_feats->vulkanMemoryModelAvailabilityVisibilityChains =
365bf215546Sopenharmony_ci            local_feats.vulkan_memory_model
366bf215546Sopenharmony_ci               .vulkanMemoryModelAvailabilityVisibilityChains;
367bf215546Sopenharmony_ci      }
368bf215546Sopenharmony_ci
369bf215546Sopenharmony_ci      vk12_feats->shaderOutputViewportIndex =
370bf215546Sopenharmony_ci         exts->EXT_shader_viewport_index_layer;
371bf215546Sopenharmony_ci      vk12_feats->shaderOutputLayer = exts->EXT_shader_viewport_index_layer;
372bf215546Sopenharmony_ci      vk12_feats->subgroupBroadcastDynamicId = false;
373bf215546Sopenharmony_ci   }
374bf215546Sopenharmony_ci}
375bf215546Sopenharmony_ci
376bf215546Sopenharmony_cistatic void
377bf215546Sopenharmony_civn_physical_device_init_uuids(struct vn_physical_device *physical_dev)
378bf215546Sopenharmony_ci{
379bf215546Sopenharmony_ci   struct vn_physical_device_properties *props = &physical_dev->properties;
380bf215546Sopenharmony_ci   struct VkPhysicalDeviceProperties *vk10_props = &props->vulkan_1_0;
381bf215546Sopenharmony_ci   struct VkPhysicalDeviceVulkan11Properties *vk11_props = &props->vulkan_1_1;
382bf215546Sopenharmony_ci   struct VkPhysicalDeviceVulkan12Properties *vk12_props = &props->vulkan_1_2;
383bf215546Sopenharmony_ci   struct mesa_sha1 sha1_ctx;
384bf215546Sopenharmony_ci   uint8_t sha1[SHA1_DIGEST_LENGTH];
385bf215546Sopenharmony_ci
386bf215546Sopenharmony_ci   static_assert(VK_UUID_SIZE <= SHA1_DIGEST_LENGTH, "");
387bf215546Sopenharmony_ci
388bf215546Sopenharmony_ci   _mesa_sha1_init(&sha1_ctx);
389bf215546Sopenharmony_ci   _mesa_sha1_update(&sha1_ctx, &vk10_props->pipelineCacheUUID,
390bf215546Sopenharmony_ci                     sizeof(vk10_props->pipelineCacheUUID));
391bf215546Sopenharmony_ci   _mesa_sha1_final(&sha1_ctx, sha1);
392bf215546Sopenharmony_ci
393bf215546Sopenharmony_ci   memcpy(vk10_props->pipelineCacheUUID, sha1, VK_UUID_SIZE);
394bf215546Sopenharmony_ci
395bf215546Sopenharmony_ci   _mesa_sha1_init(&sha1_ctx);
396bf215546Sopenharmony_ci   _mesa_sha1_update(&sha1_ctx, &vk10_props->vendorID,
397bf215546Sopenharmony_ci                     sizeof(vk10_props->vendorID));
398bf215546Sopenharmony_ci   _mesa_sha1_update(&sha1_ctx, &vk10_props->deviceID,
399bf215546Sopenharmony_ci                     sizeof(vk10_props->deviceID));
400bf215546Sopenharmony_ci   _mesa_sha1_final(&sha1_ctx, sha1);
401bf215546Sopenharmony_ci
402bf215546Sopenharmony_ci   memcpy(vk11_props->deviceUUID, sha1, VK_UUID_SIZE);
403bf215546Sopenharmony_ci
404bf215546Sopenharmony_ci   _mesa_sha1_init(&sha1_ctx);
405bf215546Sopenharmony_ci   _mesa_sha1_update(&sha1_ctx, vk12_props->driverName,
406bf215546Sopenharmony_ci                     strlen(vk12_props->driverName));
407bf215546Sopenharmony_ci   _mesa_sha1_update(&sha1_ctx, vk12_props->driverInfo,
408bf215546Sopenharmony_ci                     strlen(vk12_props->driverInfo));
409bf215546Sopenharmony_ci   _mesa_sha1_final(&sha1_ctx, sha1);
410bf215546Sopenharmony_ci
411bf215546Sopenharmony_ci   memcpy(vk11_props->driverUUID, sha1, VK_UUID_SIZE);
412bf215546Sopenharmony_ci
413bf215546Sopenharmony_ci   memset(vk11_props->deviceLUID, 0, VK_LUID_SIZE);
414bf215546Sopenharmony_ci   vk11_props->deviceNodeMask = 0;
415bf215546Sopenharmony_ci   vk11_props->deviceLUIDValid = false;
416bf215546Sopenharmony_ci}
417bf215546Sopenharmony_ci
418bf215546Sopenharmony_cistatic void
419bf215546Sopenharmony_civn_physical_device_init_properties(struct vn_physical_device *physical_dev)
420bf215546Sopenharmony_ci{
421bf215546Sopenharmony_ci   struct vn_physical_device_properties *props = &physical_dev->properties;
422bf215546Sopenharmony_ci   struct vn_instance *instance = physical_dev->instance;
423bf215546Sopenharmony_ci   const struct vk_device_extension_table *exts =
424bf215546Sopenharmony_ci      &physical_dev->renderer_extensions;
425bf215546Sopenharmony_ci   VkPhysicalDeviceProperties2 properties2 = {
426bf215546Sopenharmony_ci      .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
427bf215546Sopenharmony_ci   };
428bf215546Sopenharmony_ci   struct {
429bf215546Sopenharmony_ci      /* Vulkan 1.1 */
430bf215546Sopenharmony_ci      VkPhysicalDeviceIDProperties id;
431bf215546Sopenharmony_ci      VkPhysicalDeviceSubgroupProperties subgroup;
432bf215546Sopenharmony_ci      VkPhysicalDevicePointClippingProperties point_clipping;
433bf215546Sopenharmony_ci      VkPhysicalDeviceMultiviewProperties multiview;
434bf215546Sopenharmony_ci      VkPhysicalDeviceProtectedMemoryProperties protected_memory;
435bf215546Sopenharmony_ci      VkPhysicalDeviceMaintenance3Properties maintenance_3;
436bf215546Sopenharmony_ci
437bf215546Sopenharmony_ci      /* Vulkan 1.2 */
438bf215546Sopenharmony_ci      VkPhysicalDeviceDriverProperties driver;
439bf215546Sopenharmony_ci      VkPhysicalDeviceFloatControlsProperties float_controls;
440bf215546Sopenharmony_ci      VkPhysicalDeviceDescriptorIndexingProperties descriptor_indexing;
441bf215546Sopenharmony_ci      VkPhysicalDeviceDepthStencilResolveProperties depth_stencil_resolve;
442bf215546Sopenharmony_ci      VkPhysicalDeviceSamplerFilterMinmaxProperties sampler_filter_minmax;
443bf215546Sopenharmony_ci      VkPhysicalDeviceTimelineSemaphoreProperties timeline_semaphore;
444bf215546Sopenharmony_ci   } local_props;
445bf215546Sopenharmony_ci
446bf215546Sopenharmony_ci   if (physical_dev->renderer_version >= VK_API_VERSION_1_2) {
447bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(props->vulkan_1_1, VULKAN_1_1_PROPERTIES, properties2);
448bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(props->vulkan_1_2, VULKAN_1_2_PROPERTIES, properties2);
449bf215546Sopenharmony_ci   } else {
450bf215546Sopenharmony_ci      /* Vulkan 1.1 */
451bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.id, ID_PROPERTIES, properties2);
452bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.subgroup, SUBGROUP_PROPERTIES, properties2);
453bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.point_clipping, POINT_CLIPPING_PROPERTIES,
454bf215546Sopenharmony_ci                      properties2);
455bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.multiview, MULTIVIEW_PROPERTIES,
456bf215546Sopenharmony_ci                      properties2);
457bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.protected_memory,
458bf215546Sopenharmony_ci                      PROTECTED_MEMORY_PROPERTIES, properties2);
459bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.maintenance_3, MAINTENANCE_3_PROPERTIES,
460bf215546Sopenharmony_ci                      properties2);
461bf215546Sopenharmony_ci
462bf215546Sopenharmony_ci      /* Vulkan 1.2 */
463bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.driver, DRIVER_PROPERTIES, properties2);
464bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.float_controls, FLOAT_CONTROLS_PROPERTIES,
465bf215546Sopenharmony_ci                      properties2);
466bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.descriptor_indexing,
467bf215546Sopenharmony_ci                      DESCRIPTOR_INDEXING_PROPERTIES, properties2);
468bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.depth_stencil_resolve,
469bf215546Sopenharmony_ci                      DEPTH_STENCIL_RESOLVE_PROPERTIES, properties2);
470bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.sampler_filter_minmax,
471bf215546Sopenharmony_ci                      SAMPLER_FILTER_MINMAX_PROPERTIES, properties2);
472bf215546Sopenharmony_ci      VN_ADD_TO_PNEXT(local_props.timeline_semaphore,
473bf215546Sopenharmony_ci                      TIMELINE_SEMAPHORE_PROPERTIES, properties2);
474bf215546Sopenharmony_ci   }
475bf215546Sopenharmony_ci
476bf215546Sopenharmony_ci   /* Vulkan 1.3 */
477bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_inline_uniform_block,
478bf215546Sopenharmony_ci                       props->inline_uniform_block,
479bf215546Sopenharmony_ci                       INLINE_UNIFORM_BLOCK_PROPERTIES, properties2);
480bf215546Sopenharmony_ci
481bf215546Sopenharmony_ci   /* EXT */
482bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(
483bf215546Sopenharmony_ci      exts->EXT_conservative_rasterization, props->conservative_rasterization,
484bf215546Sopenharmony_ci      CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT, properties2);
485bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_custom_border_color,
486bf215546Sopenharmony_ci                       props->custom_border_color,
487bf215546Sopenharmony_ci                       CUSTOM_BORDER_COLOR_PROPERTIES_EXT, properties2);
488bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_line_rasterization,
489bf215546Sopenharmony_ci                       props->line_rasterization,
490bf215546Sopenharmony_ci                       LINE_RASTERIZATION_PROPERTIES_EXT, properties2);
491bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_provoking_vertex, props->provoking_vertex,
492bf215546Sopenharmony_ci                       PROVOKING_VERTEX_PROPERTIES_EXT, properties2);
493bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_robustness2, props->robustness_2,
494bf215546Sopenharmony_ci                       ROBUSTNESS_2_PROPERTIES_EXT, properties2);
495bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_transform_feedback,
496bf215546Sopenharmony_ci                       props->transform_feedback,
497bf215546Sopenharmony_ci                       TRANSFORM_FEEDBACK_PROPERTIES_EXT, properties2);
498bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->KHR_maintenance4, props->maintenance4,
499bf215546Sopenharmony_ci                       MAINTENANCE_4_PROPERTIES, properties2);
500bf215546Sopenharmony_ci   VN_ADD_EXT_TO_PNEXT(exts->EXT_vertex_attribute_divisor,
501bf215546Sopenharmony_ci                       props->vertex_attribute_divisor,
502bf215546Sopenharmony_ci                       VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT, properties2);
503bf215546Sopenharmony_ci
504bf215546Sopenharmony_ci   vn_call_vkGetPhysicalDeviceProperties2(
505bf215546Sopenharmony_ci      instance, vn_physical_device_to_handle(physical_dev), &properties2);
506bf215546Sopenharmony_ci
507bf215546Sopenharmony_ci   props->vulkan_1_0 = properties2.properties;
508bf215546Sopenharmony_ci
509bf215546Sopenharmony_ci   /* TODO allow sparse resource along with sync feedback */
510bf215546Sopenharmony_ci   if (!VN_PERF(NO_FENCE_FEEDBACK)) {
511bf215546Sopenharmony_ci      props->vulkan_1_0.limits.sparseAddressSpaceSize = 0;
512bf215546Sopenharmony_ci      props->vulkan_1_0.sparseProperties =
513bf215546Sopenharmony_ci         (VkPhysicalDeviceSparseProperties){ 0 };
514bf215546Sopenharmony_ci   }
515bf215546Sopenharmony_ci
516bf215546Sopenharmony_ci   struct VkPhysicalDeviceProperties *vk10_props = &props->vulkan_1_0;
517bf215546Sopenharmony_ci   struct VkPhysicalDeviceVulkan11Properties *vk11_props = &props->vulkan_1_1;
518bf215546Sopenharmony_ci   struct VkPhysicalDeviceVulkan12Properties *vk12_props = &props->vulkan_1_2;
519bf215546Sopenharmony_ci
520bf215546Sopenharmony_ci   if (physical_dev->renderer_version < VK_API_VERSION_1_2) {
521bf215546Sopenharmony_ci      memcpy(vk11_props->deviceUUID, local_props.id.deviceUUID,
522bf215546Sopenharmony_ci             sizeof(vk11_props->deviceUUID));
523bf215546Sopenharmony_ci      memcpy(vk11_props->driverUUID, local_props.id.driverUUID,
524bf215546Sopenharmony_ci             sizeof(vk11_props->driverUUID));
525bf215546Sopenharmony_ci      memcpy(vk11_props->deviceLUID, local_props.id.deviceLUID,
526bf215546Sopenharmony_ci             sizeof(vk11_props->deviceLUID));
527bf215546Sopenharmony_ci      vk11_props->deviceNodeMask = local_props.id.deviceNodeMask;
528bf215546Sopenharmony_ci      vk11_props->deviceLUIDValid = local_props.id.deviceLUIDValid;
529bf215546Sopenharmony_ci
530bf215546Sopenharmony_ci      vk11_props->subgroupSize = local_props.subgroup.subgroupSize;
531bf215546Sopenharmony_ci      vk11_props->subgroupSupportedStages =
532bf215546Sopenharmony_ci         local_props.subgroup.supportedStages;
533bf215546Sopenharmony_ci      vk11_props->subgroupSupportedOperations =
534bf215546Sopenharmony_ci         local_props.subgroup.supportedOperations;
535bf215546Sopenharmony_ci      vk11_props->subgroupQuadOperationsInAllStages =
536bf215546Sopenharmony_ci         local_props.subgroup.quadOperationsInAllStages;
537bf215546Sopenharmony_ci
538bf215546Sopenharmony_ci      vk11_props->pointClippingBehavior =
539bf215546Sopenharmony_ci         local_props.point_clipping.pointClippingBehavior;
540bf215546Sopenharmony_ci
541bf215546Sopenharmony_ci      vk11_props->maxMultiviewViewCount =
542bf215546Sopenharmony_ci         local_props.multiview.maxMultiviewViewCount;
543bf215546Sopenharmony_ci      vk11_props->maxMultiviewInstanceIndex =
544bf215546Sopenharmony_ci         local_props.multiview.maxMultiviewInstanceIndex;
545bf215546Sopenharmony_ci
546bf215546Sopenharmony_ci      vk11_props->protectedNoFault =
547bf215546Sopenharmony_ci         local_props.protected_memory.protectedNoFault;
548bf215546Sopenharmony_ci
549bf215546Sopenharmony_ci      vk11_props->maxPerSetDescriptors =
550bf215546Sopenharmony_ci         local_props.maintenance_3.maxPerSetDescriptors;
551bf215546Sopenharmony_ci      vk11_props->maxMemoryAllocationSize =
552bf215546Sopenharmony_ci         local_props.maintenance_3.maxMemoryAllocationSize;
553bf215546Sopenharmony_ci
554bf215546Sopenharmony_ci      if (exts->KHR_driver_properties) {
555bf215546Sopenharmony_ci         vk12_props->driverID = local_props.driver.driverID;
556bf215546Sopenharmony_ci         memcpy(vk12_props->driverName, local_props.driver.driverName,
557bf215546Sopenharmony_ci                VK_MAX_DRIVER_NAME_SIZE);
558bf215546Sopenharmony_ci         memcpy(vk12_props->driverInfo, local_props.driver.driverInfo,
559bf215546Sopenharmony_ci                VK_MAX_DRIVER_INFO_SIZE);
560bf215546Sopenharmony_ci         vk12_props->conformanceVersion =
561bf215546Sopenharmony_ci            local_props.driver.conformanceVersion;
562bf215546Sopenharmony_ci      }
563bf215546Sopenharmony_ci      if (exts->KHR_shader_float_controls) {
564bf215546Sopenharmony_ci         vk12_props->denormBehaviorIndependence =
565bf215546Sopenharmony_ci            local_props.float_controls.denormBehaviorIndependence;
566bf215546Sopenharmony_ci         vk12_props->roundingModeIndependence =
567bf215546Sopenharmony_ci            local_props.float_controls.roundingModeIndependence;
568bf215546Sopenharmony_ci         vk12_props->shaderSignedZeroInfNanPreserveFloat16 =
569bf215546Sopenharmony_ci            local_props.float_controls.shaderSignedZeroInfNanPreserveFloat16;
570bf215546Sopenharmony_ci         vk12_props->shaderSignedZeroInfNanPreserveFloat32 =
571bf215546Sopenharmony_ci            local_props.float_controls.shaderSignedZeroInfNanPreserveFloat32;
572bf215546Sopenharmony_ci         vk12_props->shaderSignedZeroInfNanPreserveFloat64 =
573bf215546Sopenharmony_ci            local_props.float_controls.shaderSignedZeroInfNanPreserveFloat64;
574bf215546Sopenharmony_ci         vk12_props->shaderDenormPreserveFloat16 =
575bf215546Sopenharmony_ci            local_props.float_controls.shaderDenormPreserveFloat16;
576bf215546Sopenharmony_ci         vk12_props->shaderDenormPreserveFloat32 =
577bf215546Sopenharmony_ci            local_props.float_controls.shaderDenormPreserveFloat32;
578bf215546Sopenharmony_ci         vk12_props->shaderDenormPreserveFloat64 =
579bf215546Sopenharmony_ci            local_props.float_controls.shaderDenormPreserveFloat64;
580bf215546Sopenharmony_ci         vk12_props->shaderDenormFlushToZeroFloat16 =
581bf215546Sopenharmony_ci            local_props.float_controls.shaderDenormFlushToZeroFloat16;
582bf215546Sopenharmony_ci         vk12_props->shaderDenormFlushToZeroFloat32 =
583bf215546Sopenharmony_ci            local_props.float_controls.shaderDenormFlushToZeroFloat32;
584bf215546Sopenharmony_ci         vk12_props->shaderDenormFlushToZeroFloat64 =
585bf215546Sopenharmony_ci            local_props.float_controls.shaderDenormFlushToZeroFloat64;
586bf215546Sopenharmony_ci         vk12_props->shaderRoundingModeRTEFloat16 =
587bf215546Sopenharmony_ci            local_props.float_controls.shaderRoundingModeRTEFloat16;
588bf215546Sopenharmony_ci         vk12_props->shaderRoundingModeRTEFloat32 =
589bf215546Sopenharmony_ci            local_props.float_controls.shaderRoundingModeRTEFloat32;
590bf215546Sopenharmony_ci         vk12_props->shaderRoundingModeRTEFloat64 =
591bf215546Sopenharmony_ci            local_props.float_controls.shaderRoundingModeRTEFloat64;
592bf215546Sopenharmony_ci         vk12_props->shaderRoundingModeRTZFloat16 =
593bf215546Sopenharmony_ci            local_props.float_controls.shaderRoundingModeRTZFloat16;
594bf215546Sopenharmony_ci         vk12_props->shaderRoundingModeRTZFloat32 =
595bf215546Sopenharmony_ci            local_props.float_controls.shaderRoundingModeRTZFloat32;
596bf215546Sopenharmony_ci         vk12_props->shaderRoundingModeRTZFloat64 =
597bf215546Sopenharmony_ci            local_props.float_controls.shaderRoundingModeRTZFloat64;
598bf215546Sopenharmony_ci      }
599bf215546Sopenharmony_ci      if (exts->EXT_descriptor_indexing) {
600bf215546Sopenharmony_ci         vk12_props->maxUpdateAfterBindDescriptorsInAllPools =
601bf215546Sopenharmony_ci            local_props.descriptor_indexing
602bf215546Sopenharmony_ci               .maxUpdateAfterBindDescriptorsInAllPools;
603bf215546Sopenharmony_ci         vk12_props->shaderUniformBufferArrayNonUniformIndexingNative =
604bf215546Sopenharmony_ci            local_props.descriptor_indexing
605bf215546Sopenharmony_ci               .shaderUniformBufferArrayNonUniformIndexingNative;
606bf215546Sopenharmony_ci         vk12_props->shaderSampledImageArrayNonUniformIndexingNative =
607bf215546Sopenharmony_ci            local_props.descriptor_indexing
608bf215546Sopenharmony_ci               .shaderSampledImageArrayNonUniformIndexingNative;
609bf215546Sopenharmony_ci         vk12_props->shaderStorageBufferArrayNonUniformIndexingNative =
610bf215546Sopenharmony_ci            local_props.descriptor_indexing
611bf215546Sopenharmony_ci               .shaderStorageBufferArrayNonUniformIndexingNative;
612bf215546Sopenharmony_ci         vk12_props->shaderStorageImageArrayNonUniformIndexingNative =
613bf215546Sopenharmony_ci            local_props.descriptor_indexing
614bf215546Sopenharmony_ci               .shaderStorageImageArrayNonUniformIndexingNative;
615bf215546Sopenharmony_ci         vk12_props->shaderInputAttachmentArrayNonUniformIndexingNative =
616bf215546Sopenharmony_ci            local_props.descriptor_indexing
617bf215546Sopenharmony_ci               .shaderInputAttachmentArrayNonUniformIndexingNative;
618bf215546Sopenharmony_ci         vk12_props->robustBufferAccessUpdateAfterBind =
619bf215546Sopenharmony_ci            local_props.descriptor_indexing.robustBufferAccessUpdateAfterBind;
620bf215546Sopenharmony_ci         vk12_props->quadDivergentImplicitLod =
621bf215546Sopenharmony_ci            local_props.descriptor_indexing.quadDivergentImplicitLod;
622bf215546Sopenharmony_ci         vk12_props->maxPerStageDescriptorUpdateAfterBindSamplers =
623bf215546Sopenharmony_ci            local_props.descriptor_indexing
624bf215546Sopenharmony_ci               .maxPerStageDescriptorUpdateAfterBindSamplers;
625bf215546Sopenharmony_ci         vk12_props->maxPerStageDescriptorUpdateAfterBindUniformBuffers =
626bf215546Sopenharmony_ci            local_props.descriptor_indexing
627bf215546Sopenharmony_ci               .maxPerStageDescriptorUpdateAfterBindUniformBuffers;
628bf215546Sopenharmony_ci         vk12_props->maxPerStageDescriptorUpdateAfterBindStorageBuffers =
629bf215546Sopenharmony_ci            local_props.descriptor_indexing
630bf215546Sopenharmony_ci               .maxPerStageDescriptorUpdateAfterBindStorageBuffers;
631bf215546Sopenharmony_ci         vk12_props->maxPerStageDescriptorUpdateAfterBindSampledImages =
632bf215546Sopenharmony_ci            local_props.descriptor_indexing
633bf215546Sopenharmony_ci               .maxPerStageDescriptorUpdateAfterBindSampledImages;
634bf215546Sopenharmony_ci         vk12_props->maxPerStageDescriptorUpdateAfterBindStorageImages =
635bf215546Sopenharmony_ci            local_props.descriptor_indexing
636bf215546Sopenharmony_ci               .maxPerStageDescriptorUpdateAfterBindStorageImages;
637bf215546Sopenharmony_ci         vk12_props->maxPerStageDescriptorUpdateAfterBindInputAttachments =
638bf215546Sopenharmony_ci            local_props.descriptor_indexing
639bf215546Sopenharmony_ci               .maxPerStageDescriptorUpdateAfterBindInputAttachments;
640bf215546Sopenharmony_ci         vk12_props->maxPerStageUpdateAfterBindResources =
641bf215546Sopenharmony_ci            local_props.descriptor_indexing
642bf215546Sopenharmony_ci               .maxPerStageUpdateAfterBindResources;
643bf215546Sopenharmony_ci         vk12_props->maxDescriptorSetUpdateAfterBindSamplers =
644bf215546Sopenharmony_ci            local_props.descriptor_indexing
645bf215546Sopenharmony_ci               .maxDescriptorSetUpdateAfterBindSamplers;
646bf215546Sopenharmony_ci         vk12_props->maxDescriptorSetUpdateAfterBindUniformBuffers =
647bf215546Sopenharmony_ci            local_props.descriptor_indexing
648bf215546Sopenharmony_ci               .maxDescriptorSetUpdateAfterBindUniformBuffers;
649bf215546Sopenharmony_ci         vk12_props->maxDescriptorSetUpdateAfterBindUniformBuffersDynamic =
650bf215546Sopenharmony_ci            local_props.descriptor_indexing
651bf215546Sopenharmony_ci               .maxDescriptorSetUpdateAfterBindUniformBuffersDynamic;
652bf215546Sopenharmony_ci         vk12_props->maxDescriptorSetUpdateAfterBindStorageBuffers =
653bf215546Sopenharmony_ci            local_props.descriptor_indexing
654bf215546Sopenharmony_ci               .maxDescriptorSetUpdateAfterBindStorageBuffers;
655bf215546Sopenharmony_ci         vk12_props->maxDescriptorSetUpdateAfterBindStorageBuffersDynamic =
656bf215546Sopenharmony_ci            local_props.descriptor_indexing
657bf215546Sopenharmony_ci               .maxDescriptorSetUpdateAfterBindStorageBuffersDynamic;
658bf215546Sopenharmony_ci         vk12_props->maxDescriptorSetUpdateAfterBindSampledImages =
659bf215546Sopenharmony_ci            local_props.descriptor_indexing
660bf215546Sopenharmony_ci               .maxDescriptorSetUpdateAfterBindSampledImages;
661bf215546Sopenharmony_ci         vk12_props->maxDescriptorSetUpdateAfterBindStorageImages =
662bf215546Sopenharmony_ci            local_props.descriptor_indexing
663bf215546Sopenharmony_ci               .maxDescriptorSetUpdateAfterBindStorageImages;
664bf215546Sopenharmony_ci         vk12_props->maxDescriptorSetUpdateAfterBindInputAttachments =
665bf215546Sopenharmony_ci            local_props.descriptor_indexing
666bf215546Sopenharmony_ci               .maxDescriptorSetUpdateAfterBindInputAttachments;
667bf215546Sopenharmony_ci      }
668bf215546Sopenharmony_ci      if (exts->KHR_depth_stencil_resolve) {
669bf215546Sopenharmony_ci         vk12_props->supportedDepthResolveModes =
670bf215546Sopenharmony_ci            local_props.depth_stencil_resolve.supportedDepthResolveModes;
671bf215546Sopenharmony_ci         vk12_props->supportedStencilResolveModes =
672bf215546Sopenharmony_ci            local_props.depth_stencil_resolve.supportedStencilResolveModes;
673bf215546Sopenharmony_ci         vk12_props->independentResolveNone =
674bf215546Sopenharmony_ci            local_props.depth_stencil_resolve.independentResolveNone;
675bf215546Sopenharmony_ci         vk12_props->independentResolve =
676bf215546Sopenharmony_ci            local_props.depth_stencil_resolve.independentResolve;
677bf215546Sopenharmony_ci      }
678bf215546Sopenharmony_ci      if (exts->EXT_sampler_filter_minmax) {
679bf215546Sopenharmony_ci         vk12_props->filterMinmaxSingleComponentFormats =
680bf215546Sopenharmony_ci            local_props.sampler_filter_minmax
681bf215546Sopenharmony_ci               .filterMinmaxSingleComponentFormats;
682bf215546Sopenharmony_ci         vk12_props->filterMinmaxImageComponentMapping =
683bf215546Sopenharmony_ci            local_props.sampler_filter_minmax
684bf215546Sopenharmony_ci               .filterMinmaxImageComponentMapping;
685bf215546Sopenharmony_ci      }
686bf215546Sopenharmony_ci      if (exts->KHR_timeline_semaphore) {
687bf215546Sopenharmony_ci         vk12_props->maxTimelineSemaphoreValueDifference =
688bf215546Sopenharmony_ci            local_props.timeline_semaphore.maxTimelineSemaphoreValueDifference;
689bf215546Sopenharmony_ci      }
690bf215546Sopenharmony_ci
691bf215546Sopenharmony_ci      vk12_props->framebufferIntegerColorSampleCounts = VK_SAMPLE_COUNT_1_BIT;
692bf215546Sopenharmony_ci   }
693bf215546Sopenharmony_ci
694bf215546Sopenharmony_ci   const uint32_t version_override = vk_get_version_override();
695bf215546Sopenharmony_ci   if (version_override) {
696bf215546Sopenharmony_ci      vk10_props->apiVersion = version_override;
697bf215546Sopenharmony_ci   } else {
698bf215546Sopenharmony_ci      /* cap the advertised api version */
699bf215546Sopenharmony_ci      uint32_t ver = MIN3(vk10_props->apiVersion, VN_MAX_API_VERSION,
700bf215546Sopenharmony_ci                          instance->renderer->info.vk_xml_version);
701bf215546Sopenharmony_ci      if (VK_VERSION_PATCH(ver) > VK_VERSION_PATCH(vk10_props->apiVersion)) {
702bf215546Sopenharmony_ci         ver = ver - VK_VERSION_PATCH(ver) +
703bf215546Sopenharmony_ci               VK_VERSION_PATCH(vk10_props->apiVersion);
704bf215546Sopenharmony_ci      }
705bf215546Sopenharmony_ci      vk10_props->apiVersion = ver;
706bf215546Sopenharmony_ci   }
707bf215546Sopenharmony_ci
708bf215546Sopenharmony_ci   vk10_props->driverVersion = vk_get_driver_version();
709bf215546Sopenharmony_ci
710bf215546Sopenharmony_ci   char device_name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE];
711bf215546Sopenharmony_ci   int device_name_len =
712bf215546Sopenharmony_ci      snprintf(device_name, sizeof(device_name), "Virtio-GPU Venus (%s)",
713bf215546Sopenharmony_ci               vk10_props->deviceName);
714bf215546Sopenharmony_ci   if (device_name_len >= VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) {
715bf215546Sopenharmony_ci      memcpy(device_name + VK_MAX_PHYSICAL_DEVICE_NAME_SIZE - 5, "...)", 4);
716bf215546Sopenharmony_ci      device_name_len = VK_MAX_PHYSICAL_DEVICE_NAME_SIZE - 1;
717bf215546Sopenharmony_ci   }
718bf215546Sopenharmony_ci   memcpy(vk10_props->deviceName, device_name, device_name_len + 1);
719bf215546Sopenharmony_ci
720bf215546Sopenharmony_ci   vk12_props->driverID = VK_DRIVER_ID_MESA_VENUS;
721bf215546Sopenharmony_ci   snprintf(vk12_props->driverName, sizeof(vk12_props->driverName), "venus");
722bf215546Sopenharmony_ci   snprintf(vk12_props->driverInfo, sizeof(vk12_props->driverInfo),
723bf215546Sopenharmony_ci            "Mesa " PACKAGE_VERSION MESA_GIT_SHA1);
724bf215546Sopenharmony_ci   vk12_props->conformanceVersion = (VkConformanceVersion){
725bf215546Sopenharmony_ci      .major = 1,
726bf215546Sopenharmony_ci      .minor = 2,
727bf215546Sopenharmony_ci      .subminor = 7,
728bf215546Sopenharmony_ci      .patch = 1,
729bf215546Sopenharmony_ci   };
730bf215546Sopenharmony_ci
731bf215546Sopenharmony_ci   vn_physical_device_init_uuids(physical_dev);
732bf215546Sopenharmony_ci}
733bf215546Sopenharmony_ci
734bf215546Sopenharmony_cistatic VkResult
735bf215546Sopenharmony_civn_physical_device_init_queue_family_properties(
736bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev)
737bf215546Sopenharmony_ci{
738bf215546Sopenharmony_ci   struct vn_instance *instance = physical_dev->instance;
739bf215546Sopenharmony_ci   const VkAllocationCallbacks *alloc = &instance->base.base.alloc;
740bf215546Sopenharmony_ci   uint32_t count;
741bf215546Sopenharmony_ci
742bf215546Sopenharmony_ci   vn_call_vkGetPhysicalDeviceQueueFamilyProperties2(
743bf215546Sopenharmony_ci      instance, vn_physical_device_to_handle(physical_dev), &count, NULL);
744bf215546Sopenharmony_ci
745bf215546Sopenharmony_ci   VkQueueFamilyProperties2 *props =
746bf215546Sopenharmony_ci      vk_alloc(alloc, sizeof(*props) * count, VN_DEFAULT_ALIGN,
747bf215546Sopenharmony_ci               VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
748bf215546Sopenharmony_ci   if (!props)
749bf215546Sopenharmony_ci      return VK_ERROR_OUT_OF_HOST_MEMORY;
750bf215546Sopenharmony_ci
751bf215546Sopenharmony_ci   for (uint32_t i = 0; i < count; i++) {
752bf215546Sopenharmony_ci      props[i].sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2;
753bf215546Sopenharmony_ci      props[i].pNext = NULL;
754bf215546Sopenharmony_ci   }
755bf215546Sopenharmony_ci   vn_call_vkGetPhysicalDeviceQueueFamilyProperties2(
756bf215546Sopenharmony_ci      instance, vn_physical_device_to_handle(physical_dev), &count, props);
757bf215546Sopenharmony_ci
758bf215546Sopenharmony_ci   physical_dev->queue_family_properties = props;
759bf215546Sopenharmony_ci   physical_dev->queue_family_count = count;
760bf215546Sopenharmony_ci
761bf215546Sopenharmony_ci   return VK_SUCCESS;
762bf215546Sopenharmony_ci}
763bf215546Sopenharmony_ci
764bf215546Sopenharmony_cistatic void
765bf215546Sopenharmony_civn_physical_device_init_memory_properties(
766bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev)
767bf215546Sopenharmony_ci{
768bf215546Sopenharmony_ci   struct vn_instance *instance = physical_dev->instance;
769bf215546Sopenharmony_ci
770bf215546Sopenharmony_ci   physical_dev->memory_properties.sType =
771bf215546Sopenharmony_ci      VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
772bf215546Sopenharmony_ci
773bf215546Sopenharmony_ci   vn_call_vkGetPhysicalDeviceMemoryProperties2(
774bf215546Sopenharmony_ci      instance, vn_physical_device_to_handle(physical_dev),
775bf215546Sopenharmony_ci      &physical_dev->memory_properties);
776bf215546Sopenharmony_ci
777bf215546Sopenharmony_ci   if (!instance->renderer->info.has_cache_management) {
778bf215546Sopenharmony_ci      VkPhysicalDeviceMemoryProperties *props =
779bf215546Sopenharmony_ci         &physical_dev->memory_properties.memoryProperties;
780bf215546Sopenharmony_ci      const uint32_t host_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
781bf215546Sopenharmony_ci                                  VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
782bf215546Sopenharmony_ci                                  VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
783bf215546Sopenharmony_ci
784bf215546Sopenharmony_ci      for (uint32_t i = 0; i < props->memoryTypeCount; i++) {
785bf215546Sopenharmony_ci         const bool coherent = props->memoryTypes[i].propertyFlags &
786bf215546Sopenharmony_ci                               VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
787bf215546Sopenharmony_ci         if (!coherent)
788bf215546Sopenharmony_ci            props->memoryTypes[i].propertyFlags &= ~host_flags;
789bf215546Sopenharmony_ci      }
790bf215546Sopenharmony_ci   }
791bf215546Sopenharmony_ci}
792bf215546Sopenharmony_ci
793bf215546Sopenharmony_cistatic void
794bf215546Sopenharmony_civn_physical_device_init_external_memory(
795bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev)
796bf215546Sopenharmony_ci{
797bf215546Sopenharmony_ci   /* When a renderer VkDeviceMemory is exportable, we can create a
798bf215546Sopenharmony_ci    * vn_renderer_bo from it.  The vn_renderer_bo can be freely exported as an
799bf215546Sopenharmony_ci    * opaque fd or a dma-buf.
800bf215546Sopenharmony_ci    *
801bf215546Sopenharmony_ci    * However, to know if a rendender VkDeviceMemory is exportable, we have to
802bf215546Sopenharmony_ci    * start from VkPhysicalDeviceExternalImageFormatInfo (or
803bf215546Sopenharmony_ci    * vkGetPhysicalDeviceExternalBufferProperties).  That means we need to
804bf215546Sopenharmony_ci    * know the handle type that the renderer will use to make those queries.
805bf215546Sopenharmony_ci    *
806bf215546Sopenharmony_ci    * XXX We also assume that a vn_renderer_bo can be created as long as the
807bf215546Sopenharmony_ci    * renderer VkDeviceMemory has a mappable memory type.  That is plain
808bf215546Sopenharmony_ci    * wrong.  It is impossible to fix though until some new extension is
809bf215546Sopenharmony_ci    * created and supported by the driver, and that the renderer switches to
810bf215546Sopenharmony_ci    * the extension.
811bf215546Sopenharmony_ci    */
812bf215546Sopenharmony_ci
813bf215546Sopenharmony_ci   if (!physical_dev->instance->renderer->info.has_dma_buf_import)
814bf215546Sopenharmony_ci      return;
815bf215546Sopenharmony_ci
816bf215546Sopenharmony_ci   /* TODO We assume the renderer uses dma-bufs here.  This should be
817bf215546Sopenharmony_ci    * negotiated by adding a new function to VK_MESA_venus_protocol.
818bf215546Sopenharmony_ci    */
819bf215546Sopenharmony_ci   if (physical_dev->renderer_extensions.EXT_external_memory_dma_buf) {
820bf215546Sopenharmony_ci      physical_dev->external_memory.renderer_handle_type =
821bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
822bf215546Sopenharmony_ci
823bf215546Sopenharmony_ci#ifdef ANDROID
824bf215546Sopenharmony_ci      physical_dev->external_memory.supported_handle_types =
825bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
826bf215546Sopenharmony_ci#else
827bf215546Sopenharmony_ci      physical_dev->external_memory.supported_handle_types =
828bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
829bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
830bf215546Sopenharmony_ci#endif
831bf215546Sopenharmony_ci   }
832bf215546Sopenharmony_ci}
833bf215546Sopenharmony_ci
834bf215546Sopenharmony_cistatic void
835bf215546Sopenharmony_civn_physical_device_init_external_fence_handles(
836bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev)
837bf215546Sopenharmony_ci{
838bf215546Sopenharmony_ci   /* The current code manipulates the host-side VkFence directly.
839bf215546Sopenharmony_ci    * vkWaitForFences is translated to repeated vkGetFenceStatus.
840bf215546Sopenharmony_ci    *
841bf215546Sopenharmony_ci    * External fence is not possible currently.  At best, we could cheat by
842bf215546Sopenharmony_ci    * translating vkGetFenceFdKHR to vkWaitForFences and returning -1, when
843bf215546Sopenharmony_ci    * the handle type is sync file.
844bf215546Sopenharmony_ci    *
845bf215546Sopenharmony_ci    * We would like to create a vn_renderer_sync from a host-side VkFence,
846bf215546Sopenharmony_ci    * similar to how a vn_renderer_bo is created from a host-side
847bf215546Sopenharmony_ci    * VkDeviceMemory.  That would require kernel support and tons of works on
848bf215546Sopenharmony_ci    * the host side.  If we had that, and we kept both the vn_renderer_sync
849bf215546Sopenharmony_ci    * and the host-side VkFence in sync, we would have the freedom to use
850bf215546Sopenharmony_ci    * either of them depending on the occasions, and support external fences
851bf215546Sopenharmony_ci    * and idle waiting.
852bf215546Sopenharmony_ci    */
853bf215546Sopenharmony_ci   physical_dev->external_fence_handles = 0;
854bf215546Sopenharmony_ci
855bf215546Sopenharmony_ci#ifdef ANDROID
856bf215546Sopenharmony_ci   if (physical_dev->instance->experimental.globalFencing) {
857bf215546Sopenharmony_ci      physical_dev->external_fence_handles =
858bf215546Sopenharmony_ci         VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT;
859bf215546Sopenharmony_ci   }
860bf215546Sopenharmony_ci#endif
861bf215546Sopenharmony_ci}
862bf215546Sopenharmony_ci
863bf215546Sopenharmony_cistatic void
864bf215546Sopenharmony_civn_physical_device_init_external_semaphore_handles(
865bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev)
866bf215546Sopenharmony_ci{
867bf215546Sopenharmony_ci   /* The current code manipulates the host-side VkSemaphore directly.  It
868bf215546Sopenharmony_ci    * works very well for binary semaphores because there is no CPU operation.
869bf215546Sopenharmony_ci    * But for timeline semaphores, the situation is similar to that of fences.
870bf215546Sopenharmony_ci    * vkWaitSemaphores is translated to repeated vkGetSemaphoreCounterValue.
871bf215546Sopenharmony_ci    *
872bf215546Sopenharmony_ci    * External semaphore is not possible currently.  We could cheat when the
873bf215546Sopenharmony_ci    * semaphore is binary and the handle type is sync file, but that would
874bf215546Sopenharmony_ci    * require associating a fence with the semaphore and doing vkWaitForFences
875bf215546Sopenharmony_ci    * in vkGetSemaphoreFdKHR.
876bf215546Sopenharmony_ci    *
877bf215546Sopenharmony_ci    * We would like to create a vn_renderer_sync from a host-side VkSemaphore,
878bf215546Sopenharmony_ci    * similar to how a vn_renderer_bo is created from a host-side
879bf215546Sopenharmony_ci    * VkDeviceMemory.  The reasoning is the same as that for fences.
880bf215546Sopenharmony_ci    * Additionally, we would like the sync file exported from the
881bf215546Sopenharmony_ci    * vn_renderer_sync to carry the necessary information to identify the
882bf215546Sopenharmony_ci    * host-side VkSemaphore.  That would allow the consumers to wait on the
883bf215546Sopenharmony_ci    * host side rather than the guest side.
884bf215546Sopenharmony_ci    */
885bf215546Sopenharmony_ci   physical_dev->external_binary_semaphore_handles = 0;
886bf215546Sopenharmony_ci   physical_dev->external_timeline_semaphore_handles = 0;
887bf215546Sopenharmony_ci
888bf215546Sopenharmony_ci#ifdef ANDROID
889bf215546Sopenharmony_ci   if (physical_dev->instance->experimental.globalFencing) {
890bf215546Sopenharmony_ci      physical_dev->external_binary_semaphore_handles =
891bf215546Sopenharmony_ci         VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
892bf215546Sopenharmony_ci   }
893bf215546Sopenharmony_ci#endif
894bf215546Sopenharmony_ci}
895bf215546Sopenharmony_ci
896bf215546Sopenharmony_cistatic void
897bf215546Sopenharmony_civn_physical_device_get_native_extensions(
898bf215546Sopenharmony_ci   const struct vn_physical_device *physical_dev,
899bf215546Sopenharmony_ci   struct vk_device_extension_table *exts)
900bf215546Sopenharmony_ci{
901bf215546Sopenharmony_ci   const struct vn_instance *instance = physical_dev->instance;
902bf215546Sopenharmony_ci   const struct vk_device_extension_table *renderer_exts =
903bf215546Sopenharmony_ci      &physical_dev->renderer_extensions;
904bf215546Sopenharmony_ci
905bf215546Sopenharmony_ci   memset(exts, 0, sizeof(*exts));
906bf215546Sopenharmony_ci
907bf215546Sopenharmony_ci   /* see vn_physical_device_init_external_memory */
908bf215546Sopenharmony_ci   const bool can_external_mem = renderer_exts->EXT_external_memory_dma_buf &&
909bf215546Sopenharmony_ci                                 instance->renderer->info.has_dma_buf_import;
910bf215546Sopenharmony_ci
911bf215546Sopenharmony_ci#ifdef ANDROID
912bf215546Sopenharmony_ci   if (can_external_mem && renderer_exts->EXT_image_drm_format_modifier &&
913bf215546Sopenharmony_ci       renderer_exts->EXT_queue_family_foreign &&
914bf215546Sopenharmony_ci       instance->experimental.memoryResourceAllocationSize == VK_TRUE) {
915bf215546Sopenharmony_ci      exts->ANDROID_external_memory_android_hardware_buffer = true;
916bf215546Sopenharmony_ci      exts->ANDROID_native_buffer = true;
917bf215546Sopenharmony_ci   }
918bf215546Sopenharmony_ci
919bf215546Sopenharmony_ci   /* we have a very poor implementation */
920bf215546Sopenharmony_ci   if (instance->experimental.globalFencing) {
921bf215546Sopenharmony_ci      exts->KHR_external_fence_fd = true;
922bf215546Sopenharmony_ci      exts->KHR_external_semaphore_fd = true;
923bf215546Sopenharmony_ci   }
924bf215546Sopenharmony_ci#else /* ANDROID */
925bf215546Sopenharmony_ci   if (can_external_mem) {
926bf215546Sopenharmony_ci      exts->KHR_external_memory_fd = true;
927bf215546Sopenharmony_ci      exts->EXT_external_memory_dma_buf = true;
928bf215546Sopenharmony_ci   }
929bf215546Sopenharmony_ci
930bf215546Sopenharmony_ci#ifdef VN_USE_WSI_PLATFORM
931bf215546Sopenharmony_ci   /* XXX we should check for EXT_queue_family_foreign */
932bf215546Sopenharmony_ci   exts->KHR_incremental_present = true;
933bf215546Sopenharmony_ci   exts->KHR_swapchain = true;
934bf215546Sopenharmony_ci   exts->KHR_swapchain_mutable_format = true;
935bf215546Sopenharmony_ci#endif
936bf215546Sopenharmony_ci#endif /* ANDROID */
937bf215546Sopenharmony_ci
938bf215546Sopenharmony_ci   exts->EXT_physical_device_drm = true;
939bf215546Sopenharmony_ci}
940bf215546Sopenharmony_ci
941bf215546Sopenharmony_cistatic void
942bf215546Sopenharmony_civn_physical_device_get_passthrough_extensions(
943bf215546Sopenharmony_ci   const struct vn_physical_device *physical_dev,
944bf215546Sopenharmony_ci   struct vk_device_extension_table *exts)
945bf215546Sopenharmony_ci{
946bf215546Sopenharmony_ci   *exts = (struct vk_device_extension_table){
947bf215546Sopenharmony_ci      /* promoted to VK_VERSION_1_1 */
948bf215546Sopenharmony_ci      .KHR_16bit_storage = true,
949bf215546Sopenharmony_ci      .KHR_bind_memory2 = true,
950bf215546Sopenharmony_ci      .KHR_dedicated_allocation = true,
951bf215546Sopenharmony_ci      .KHR_descriptor_update_template = true,
952bf215546Sopenharmony_ci      .KHR_device_group = true,
953bf215546Sopenharmony_ci      .KHR_external_fence = true,
954bf215546Sopenharmony_ci      .KHR_external_memory = true,
955bf215546Sopenharmony_ci      .KHR_external_semaphore = true,
956bf215546Sopenharmony_ci      .KHR_get_memory_requirements2 = true,
957bf215546Sopenharmony_ci      .KHR_maintenance1 = true,
958bf215546Sopenharmony_ci      .KHR_maintenance2 = true,
959bf215546Sopenharmony_ci      .KHR_maintenance3 = true,
960bf215546Sopenharmony_ci      .KHR_multiview = true,
961bf215546Sopenharmony_ci      .KHR_relaxed_block_layout = true,
962bf215546Sopenharmony_ci      .KHR_sampler_ycbcr_conversion = true,
963bf215546Sopenharmony_ci      .KHR_shader_draw_parameters = true,
964bf215546Sopenharmony_ci      .KHR_storage_buffer_storage_class = true,
965bf215546Sopenharmony_ci      .KHR_variable_pointers = true,
966bf215546Sopenharmony_ci
967bf215546Sopenharmony_ci      /* promoted to VK_VERSION_1_2 */
968bf215546Sopenharmony_ci      .KHR_8bit_storage = true,
969bf215546Sopenharmony_ci      .KHR_buffer_device_address = true,
970bf215546Sopenharmony_ci      .KHR_create_renderpass2 = true,
971bf215546Sopenharmony_ci      .KHR_depth_stencil_resolve = true,
972bf215546Sopenharmony_ci      .KHR_draw_indirect_count = true,
973bf215546Sopenharmony_ci#ifndef ANDROID
974bf215546Sopenharmony_ci      /* xxx remove the #ifndef after venus has a driver id */
975bf215546Sopenharmony_ci      .KHR_driver_properties = true,
976bf215546Sopenharmony_ci#endif
977bf215546Sopenharmony_ci      .KHR_image_format_list = true,
978bf215546Sopenharmony_ci      .KHR_imageless_framebuffer = true,
979bf215546Sopenharmony_ci      .KHR_sampler_mirror_clamp_to_edge = true,
980bf215546Sopenharmony_ci      .KHR_separate_depth_stencil_layouts = true,
981bf215546Sopenharmony_ci      .KHR_shader_atomic_int64 = true,
982bf215546Sopenharmony_ci      .KHR_shader_float16_int8 = true,
983bf215546Sopenharmony_ci      .KHR_shader_float_controls = true,
984bf215546Sopenharmony_ci      .KHR_shader_subgroup_extended_types = true,
985bf215546Sopenharmony_ci      .KHR_spirv_1_4 = true,
986bf215546Sopenharmony_ci      .KHR_timeline_semaphore = true,
987bf215546Sopenharmony_ci      .KHR_uniform_buffer_standard_layout = true,
988bf215546Sopenharmony_ci      .KHR_vulkan_memory_model = true,
989bf215546Sopenharmony_ci      .EXT_descriptor_indexing = true,
990bf215546Sopenharmony_ci      .EXT_host_query_reset = true,
991bf215546Sopenharmony_ci      .EXT_sampler_filter_minmax = true,
992bf215546Sopenharmony_ci      .EXT_scalar_block_layout = true,
993bf215546Sopenharmony_ci      .EXT_separate_stencil_usage = true,
994bf215546Sopenharmony_ci      .EXT_shader_viewport_index_layer = true,
995bf215546Sopenharmony_ci
996bf215546Sopenharmony_ci      /* promoted to VK_VERSION_1_3 */
997bf215546Sopenharmony_ci      .EXT_4444_formats = true,
998bf215546Sopenharmony_ci      .EXT_extended_dynamic_state = true,
999bf215546Sopenharmony_ci      .EXT_extended_dynamic_state2 = true,
1000bf215546Sopenharmony_ci      .EXT_image_robustness = true,
1001bf215546Sopenharmony_ci      .EXT_inline_uniform_block = true,
1002bf215546Sopenharmony_ci      .EXT_shader_demote_to_helper_invocation = true,
1003bf215546Sopenharmony_ci      .KHR_copy_commands2 = true,
1004bf215546Sopenharmony_ci      .KHR_dynamic_rendering = true,
1005bf215546Sopenharmony_ci      .KHR_maintenance4 = true,
1006bf215546Sopenharmony_ci
1007bf215546Sopenharmony_ci      /* EXT */
1008bf215546Sopenharmony_ci      .EXT_calibrated_timestamps = true,
1009bf215546Sopenharmony_ci      .EXT_conditional_rendering = true,
1010bf215546Sopenharmony_ci      .EXT_conservative_rasterization = true,
1011bf215546Sopenharmony_ci      .EXT_custom_border_color = true,
1012bf215546Sopenharmony_ci      .EXT_depth_clip_enable = true,
1013bf215546Sopenharmony_ci#ifndef ANDROID
1014bf215546Sopenharmony_ci      .EXT_image_drm_format_modifier = true,
1015bf215546Sopenharmony_ci#endif
1016bf215546Sopenharmony_ci      .EXT_image_view_min_lod = true,
1017bf215546Sopenharmony_ci      .EXT_index_type_uint8 = true,
1018bf215546Sopenharmony_ci      .EXT_line_rasterization = true,
1019bf215546Sopenharmony_ci      .EXT_provoking_vertex = true,
1020bf215546Sopenharmony_ci      .EXT_queue_family_foreign = true,
1021bf215546Sopenharmony_ci      .EXT_robustness2 = true,
1022bf215546Sopenharmony_ci      .EXT_shader_stencil_export = true,
1023bf215546Sopenharmony_ci      .EXT_transform_feedback = true,
1024bf215546Sopenharmony_ci      .EXT_vertex_attribute_divisor = true,
1025bf215546Sopenharmony_ci   };
1026bf215546Sopenharmony_ci}
1027bf215546Sopenharmony_ci
1028bf215546Sopenharmony_cistatic void
1029bf215546Sopenharmony_civn_physical_device_init_supported_extensions(
1030bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev)
1031bf215546Sopenharmony_ci{
1032bf215546Sopenharmony_ci   struct vk_device_extension_table native;
1033bf215546Sopenharmony_ci   struct vk_device_extension_table passthrough;
1034bf215546Sopenharmony_ci   vn_physical_device_get_native_extensions(physical_dev, &native);
1035bf215546Sopenharmony_ci   vn_physical_device_get_passthrough_extensions(physical_dev, &passthrough);
1036bf215546Sopenharmony_ci
1037bf215546Sopenharmony_ci   for (uint32_t i = 0; i < VK_DEVICE_EXTENSION_COUNT; i++) {
1038bf215546Sopenharmony_ci      const VkExtensionProperties *props = &vk_device_extensions[i];
1039bf215546Sopenharmony_ci
1040bf215546Sopenharmony_ci#ifdef ANDROID
1041bf215546Sopenharmony_ci      if (!vk_android_allowed_device_extensions.extensions[i])
1042bf215546Sopenharmony_ci         continue;
1043bf215546Sopenharmony_ci#endif
1044bf215546Sopenharmony_ci
1045bf215546Sopenharmony_ci      if (native.extensions[i]) {
1046bf215546Sopenharmony_ci         physical_dev->base.base.supported_extensions.extensions[i] = true;
1047bf215546Sopenharmony_ci         physical_dev->extension_spec_versions[i] = props->specVersion;
1048bf215546Sopenharmony_ci      } else if (passthrough.extensions[i] &&
1049bf215546Sopenharmony_ci                 physical_dev->renderer_extensions.extensions[i]) {
1050bf215546Sopenharmony_ci         physical_dev->base.base.supported_extensions.extensions[i] = true;
1051bf215546Sopenharmony_ci         physical_dev->extension_spec_versions[i] = MIN2(
1052bf215546Sopenharmony_ci            physical_dev->extension_spec_versions[i], props->specVersion);
1053bf215546Sopenharmony_ci      }
1054bf215546Sopenharmony_ci   }
1055bf215546Sopenharmony_ci
1056bf215546Sopenharmony_ci   /* override VK_ANDROID_native_buffer spec version */
1057bf215546Sopenharmony_ci   if (native.ANDROID_native_buffer) {
1058bf215546Sopenharmony_ci      const uint32_t index =
1059bf215546Sopenharmony_ci         VN_EXTENSION_TABLE_INDEX(native, ANDROID_native_buffer);
1060bf215546Sopenharmony_ci      physical_dev->extension_spec_versions[index] =
1061bf215546Sopenharmony_ci         VN_ANDROID_NATIVE_BUFFER_SPEC_VERSION;
1062bf215546Sopenharmony_ci   }
1063bf215546Sopenharmony_ci}
1064bf215546Sopenharmony_ci
1065bf215546Sopenharmony_cistatic VkResult
1066bf215546Sopenharmony_civn_physical_device_init_renderer_extensions(
1067bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev)
1068bf215546Sopenharmony_ci{
1069bf215546Sopenharmony_ci   struct vn_instance *instance = physical_dev->instance;
1070bf215546Sopenharmony_ci   const VkAllocationCallbacks *alloc = &instance->base.base.alloc;
1071bf215546Sopenharmony_ci
1072bf215546Sopenharmony_ci   /* get renderer extensions */
1073bf215546Sopenharmony_ci   uint32_t count;
1074bf215546Sopenharmony_ci   VkResult result = vn_call_vkEnumerateDeviceExtensionProperties(
1075bf215546Sopenharmony_ci      instance, vn_physical_device_to_handle(physical_dev), NULL, &count,
1076bf215546Sopenharmony_ci      NULL);
1077bf215546Sopenharmony_ci   if (result != VK_SUCCESS)
1078bf215546Sopenharmony_ci      return result;
1079bf215546Sopenharmony_ci
1080bf215546Sopenharmony_ci   VkExtensionProperties *exts = NULL;
1081bf215546Sopenharmony_ci   if (count) {
1082bf215546Sopenharmony_ci      exts = vk_alloc(alloc, sizeof(*exts) * count, VN_DEFAULT_ALIGN,
1083bf215546Sopenharmony_ci                      VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
1084bf215546Sopenharmony_ci      if (!exts)
1085bf215546Sopenharmony_ci         return VK_ERROR_OUT_OF_HOST_MEMORY;
1086bf215546Sopenharmony_ci
1087bf215546Sopenharmony_ci      result = vn_call_vkEnumerateDeviceExtensionProperties(
1088bf215546Sopenharmony_ci         instance, vn_physical_device_to_handle(physical_dev), NULL, &count,
1089bf215546Sopenharmony_ci         exts);
1090bf215546Sopenharmony_ci      if (result < VK_SUCCESS) {
1091bf215546Sopenharmony_ci         vk_free(alloc, exts);
1092bf215546Sopenharmony_ci         return result;
1093bf215546Sopenharmony_ci      }
1094bf215546Sopenharmony_ci   }
1095bf215546Sopenharmony_ci
1096bf215546Sopenharmony_ci   physical_dev->extension_spec_versions =
1097bf215546Sopenharmony_ci      vk_zalloc(alloc,
1098bf215546Sopenharmony_ci                sizeof(*physical_dev->extension_spec_versions) *
1099bf215546Sopenharmony_ci                   VK_DEVICE_EXTENSION_COUNT,
1100bf215546Sopenharmony_ci                VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
1101bf215546Sopenharmony_ci   if (!physical_dev->extension_spec_versions) {
1102bf215546Sopenharmony_ci      vk_free(alloc, exts);
1103bf215546Sopenharmony_ci      return VK_ERROR_OUT_OF_HOST_MEMORY;
1104bf215546Sopenharmony_ci   }
1105bf215546Sopenharmony_ci
1106bf215546Sopenharmony_ci   for (uint32_t i = 0; i < VK_DEVICE_EXTENSION_COUNT; i++) {
1107bf215546Sopenharmony_ci      const VkExtensionProperties *props = &vk_device_extensions[i];
1108bf215546Sopenharmony_ci      for (uint32_t j = 0; j < count; j++) {
1109bf215546Sopenharmony_ci         if (strcmp(props->extensionName, exts[j].extensionName))
1110bf215546Sopenharmony_ci            continue;
1111bf215546Sopenharmony_ci
1112bf215546Sopenharmony_ci         /* check encoder support */
1113bf215546Sopenharmony_ci         const uint32_t enc_ext_spec_version =
1114bf215546Sopenharmony_ci            vn_extension_get_spec_version(props->extensionName);
1115bf215546Sopenharmony_ci         if (!enc_ext_spec_version)
1116bf215546Sopenharmony_ci            continue;
1117bf215546Sopenharmony_ci
1118bf215546Sopenharmony_ci         physical_dev->renderer_extensions.extensions[i] = true;
1119bf215546Sopenharmony_ci         physical_dev->extension_spec_versions[i] =
1120bf215546Sopenharmony_ci            MIN2(exts[j].specVersion, enc_ext_spec_version);
1121bf215546Sopenharmony_ci
1122bf215546Sopenharmony_ci         break;
1123bf215546Sopenharmony_ci      }
1124bf215546Sopenharmony_ci   }
1125bf215546Sopenharmony_ci
1126bf215546Sopenharmony_ci   vk_free(alloc, exts);
1127bf215546Sopenharmony_ci
1128bf215546Sopenharmony_ci   return VK_SUCCESS;
1129bf215546Sopenharmony_ci}
1130bf215546Sopenharmony_ci
1131bf215546Sopenharmony_cistatic VkResult
1132bf215546Sopenharmony_civn_physical_device_init_renderer_version(
1133bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev)
1134bf215546Sopenharmony_ci{
1135bf215546Sopenharmony_ci   struct vn_instance *instance = physical_dev->instance;
1136bf215546Sopenharmony_ci
1137bf215546Sopenharmony_ci   /*
1138bf215546Sopenharmony_ci    * We either check and enable VK_KHR_get_physical_device_properties2, or we
1139bf215546Sopenharmony_ci    * must use vkGetPhysicalDeviceProperties to get the device-level version.
1140bf215546Sopenharmony_ci    */
1141bf215546Sopenharmony_ci   VkPhysicalDeviceProperties props;
1142bf215546Sopenharmony_ci   vn_call_vkGetPhysicalDeviceProperties(
1143bf215546Sopenharmony_ci      instance, vn_physical_device_to_handle(physical_dev), &props);
1144bf215546Sopenharmony_ci   if (props.apiVersion < VN_MIN_RENDERER_VERSION) {
1145bf215546Sopenharmony_ci      if (VN_DEBUG(INIT)) {
1146bf215546Sopenharmony_ci         vn_log(instance, "%s has unsupported renderer device version %d.%d",
1147bf215546Sopenharmony_ci                props.deviceName, VK_VERSION_MAJOR(props.apiVersion),
1148bf215546Sopenharmony_ci                VK_VERSION_MINOR(props.apiVersion));
1149bf215546Sopenharmony_ci      }
1150bf215546Sopenharmony_ci      return VK_ERROR_INITIALIZATION_FAILED;
1151bf215546Sopenharmony_ci   }
1152bf215546Sopenharmony_ci
1153bf215546Sopenharmony_ci   /* device version for internal use is capped */
1154bf215546Sopenharmony_ci   physical_dev->renderer_version =
1155bf215546Sopenharmony_ci      MIN3(props.apiVersion, instance->renderer_api_version,
1156bf215546Sopenharmony_ci           instance->renderer->info.vk_xml_version);
1157bf215546Sopenharmony_ci
1158bf215546Sopenharmony_ci   return VK_SUCCESS;
1159bf215546Sopenharmony_ci}
1160bf215546Sopenharmony_ci
1161bf215546Sopenharmony_cistatic VkResult
1162bf215546Sopenharmony_civn_physical_device_init(struct vn_physical_device *physical_dev)
1163bf215546Sopenharmony_ci{
1164bf215546Sopenharmony_ci   struct vn_instance *instance = physical_dev->instance;
1165bf215546Sopenharmony_ci   const VkAllocationCallbacks *alloc = &instance->base.base.alloc;
1166bf215546Sopenharmony_ci   VkResult result;
1167bf215546Sopenharmony_ci
1168bf215546Sopenharmony_ci   result = vn_physical_device_init_renderer_extensions(physical_dev);
1169bf215546Sopenharmony_ci   if (result != VK_SUCCESS)
1170bf215546Sopenharmony_ci      return result;
1171bf215546Sopenharmony_ci
1172bf215546Sopenharmony_ci   vn_physical_device_init_supported_extensions(physical_dev);
1173bf215546Sopenharmony_ci
1174bf215546Sopenharmony_ci   /* TODO query all caps with minimal round trips */
1175bf215546Sopenharmony_ci   vn_physical_device_init_features(physical_dev);
1176bf215546Sopenharmony_ci   vn_physical_device_init_properties(physical_dev);
1177bf215546Sopenharmony_ci
1178bf215546Sopenharmony_ci   result = vn_physical_device_init_queue_family_properties(physical_dev);
1179bf215546Sopenharmony_ci   if (result != VK_SUCCESS)
1180bf215546Sopenharmony_ci      goto fail;
1181bf215546Sopenharmony_ci
1182bf215546Sopenharmony_ci   vn_physical_device_init_memory_properties(physical_dev);
1183bf215546Sopenharmony_ci
1184bf215546Sopenharmony_ci   vn_physical_device_init_external_memory(physical_dev);
1185bf215546Sopenharmony_ci   vn_physical_device_init_external_fence_handles(physical_dev);
1186bf215546Sopenharmony_ci   vn_physical_device_init_external_semaphore_handles(physical_dev);
1187bf215546Sopenharmony_ci
1188bf215546Sopenharmony_ci   result = vn_wsi_init(physical_dev);
1189bf215546Sopenharmony_ci   if (result != VK_SUCCESS)
1190bf215546Sopenharmony_ci      goto fail;
1191bf215546Sopenharmony_ci
1192bf215546Sopenharmony_ci   simple_mtx_init(&physical_dev->format_update_mutex, mtx_plain);
1193bf215546Sopenharmony_ci   util_sparse_array_init(&physical_dev->format_properties,
1194bf215546Sopenharmony_ci                          sizeof(struct vn_format_properties_entry), 64);
1195bf215546Sopenharmony_ci
1196bf215546Sopenharmony_ci   return VK_SUCCESS;
1197bf215546Sopenharmony_ci
1198bf215546Sopenharmony_cifail:
1199bf215546Sopenharmony_ci   vk_free(alloc, physical_dev->extension_spec_versions);
1200bf215546Sopenharmony_ci   vk_free(alloc, physical_dev->queue_family_properties);
1201bf215546Sopenharmony_ci   return result;
1202bf215546Sopenharmony_ci}
1203bf215546Sopenharmony_ci
1204bf215546Sopenharmony_civoid
1205bf215546Sopenharmony_civn_physical_device_fini(struct vn_physical_device *physical_dev)
1206bf215546Sopenharmony_ci{
1207bf215546Sopenharmony_ci   struct vn_instance *instance = physical_dev->instance;
1208bf215546Sopenharmony_ci   const VkAllocationCallbacks *alloc = &instance->base.base.alloc;
1209bf215546Sopenharmony_ci
1210bf215546Sopenharmony_ci   simple_mtx_destroy(&physical_dev->format_update_mutex);
1211bf215546Sopenharmony_ci   util_sparse_array_finish(&physical_dev->format_properties);
1212bf215546Sopenharmony_ci
1213bf215546Sopenharmony_ci   vn_wsi_fini(physical_dev);
1214bf215546Sopenharmony_ci   vk_free(alloc, physical_dev->extension_spec_versions);
1215bf215546Sopenharmony_ci   vk_free(alloc, physical_dev->queue_family_properties);
1216bf215546Sopenharmony_ci
1217bf215546Sopenharmony_ci   vn_physical_device_base_fini(&physical_dev->base);
1218bf215546Sopenharmony_ci}
1219bf215546Sopenharmony_ci
1220bf215546Sopenharmony_cistatic struct vn_physical_device *
1221bf215546Sopenharmony_cifind_physical_device(struct vn_physical_device *physical_devs,
1222bf215546Sopenharmony_ci                     uint32_t count,
1223bf215546Sopenharmony_ci                     vn_object_id id)
1224bf215546Sopenharmony_ci{
1225bf215546Sopenharmony_ci   for (uint32_t i = 0; i < count; i++) {
1226bf215546Sopenharmony_ci      if (physical_devs[i].base.id == id)
1227bf215546Sopenharmony_ci         return &physical_devs[i];
1228bf215546Sopenharmony_ci   }
1229bf215546Sopenharmony_ci   return NULL;
1230bf215546Sopenharmony_ci}
1231bf215546Sopenharmony_ci
1232bf215546Sopenharmony_cistatic VkResult
1233bf215546Sopenharmony_civn_instance_enumerate_physical_device_groups_locked(
1234bf215546Sopenharmony_ci   struct vn_instance *instance,
1235bf215546Sopenharmony_ci   struct vn_physical_device *physical_devs,
1236bf215546Sopenharmony_ci   uint32_t physical_dev_count)
1237bf215546Sopenharmony_ci{
1238bf215546Sopenharmony_ci   VkInstance instance_handle = vn_instance_to_handle(instance);
1239bf215546Sopenharmony_ci   const VkAllocationCallbacks *alloc = &instance->base.base.alloc;
1240bf215546Sopenharmony_ci   VkResult result;
1241bf215546Sopenharmony_ci
1242bf215546Sopenharmony_ci   uint32_t count;
1243bf215546Sopenharmony_ci   result = vn_call_vkEnumeratePhysicalDeviceGroups(instance, instance_handle,
1244bf215546Sopenharmony_ci                                                    &count, NULL);
1245bf215546Sopenharmony_ci   if (result != VK_SUCCESS)
1246bf215546Sopenharmony_ci      return result;
1247bf215546Sopenharmony_ci
1248bf215546Sopenharmony_ci   VkPhysicalDeviceGroupProperties *groups =
1249bf215546Sopenharmony_ci      vk_alloc(alloc, sizeof(*groups) * count, VN_DEFAULT_ALIGN,
1250bf215546Sopenharmony_ci               VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
1251bf215546Sopenharmony_ci   if (!groups)
1252bf215546Sopenharmony_ci      return VK_ERROR_OUT_OF_HOST_MEMORY;
1253bf215546Sopenharmony_ci
1254bf215546Sopenharmony_ci   /* VkPhysicalDeviceGroupProperties::physicalDevices is treated as an input
1255bf215546Sopenharmony_ci    * by the encoder.  Each VkPhysicalDevice must point to a valid object.
1256bf215546Sopenharmony_ci    * Each object must have id 0 as well, which is interpreted as a query by
1257bf215546Sopenharmony_ci    * the renderer.
1258bf215546Sopenharmony_ci    */
1259bf215546Sopenharmony_ci   struct vn_physical_device_base *temp_objs =
1260bf215546Sopenharmony_ci      vk_zalloc(alloc, sizeof(*temp_objs) * VK_MAX_DEVICE_GROUP_SIZE * count,
1261bf215546Sopenharmony_ci                VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
1262bf215546Sopenharmony_ci   if (!temp_objs) {
1263bf215546Sopenharmony_ci      vk_free(alloc, groups);
1264bf215546Sopenharmony_ci      return VK_ERROR_OUT_OF_HOST_MEMORY;
1265bf215546Sopenharmony_ci   }
1266bf215546Sopenharmony_ci
1267bf215546Sopenharmony_ci   for (uint32_t i = 0; i < count; i++) {
1268bf215546Sopenharmony_ci      VkPhysicalDeviceGroupProperties *group = &groups[i];
1269bf215546Sopenharmony_ci      group->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES;
1270bf215546Sopenharmony_ci      group->pNext = NULL;
1271bf215546Sopenharmony_ci      for (uint32_t j = 0; j < VK_MAX_DEVICE_GROUP_SIZE; j++) {
1272bf215546Sopenharmony_ci         struct vn_physical_device_base *temp_obj =
1273bf215546Sopenharmony_ci            &temp_objs[VK_MAX_DEVICE_GROUP_SIZE * i + j];
1274bf215546Sopenharmony_ci         temp_obj->base.base.type = VK_OBJECT_TYPE_PHYSICAL_DEVICE;
1275bf215546Sopenharmony_ci         group->physicalDevices[j] = (VkPhysicalDevice)temp_obj;
1276bf215546Sopenharmony_ci      }
1277bf215546Sopenharmony_ci   }
1278bf215546Sopenharmony_ci
1279bf215546Sopenharmony_ci   result = vn_call_vkEnumeratePhysicalDeviceGroups(instance, instance_handle,
1280bf215546Sopenharmony_ci                                                    &count, groups);
1281bf215546Sopenharmony_ci   if (result != VK_SUCCESS) {
1282bf215546Sopenharmony_ci      vk_free(alloc, groups);
1283bf215546Sopenharmony_ci      vk_free(alloc, temp_objs);
1284bf215546Sopenharmony_ci      return result;
1285bf215546Sopenharmony_ci   }
1286bf215546Sopenharmony_ci
1287bf215546Sopenharmony_ci   /* fix VkPhysicalDeviceGroupProperties::physicalDevices to point to
1288bf215546Sopenharmony_ci    * physical_devs and discard unsupported ones
1289bf215546Sopenharmony_ci    */
1290bf215546Sopenharmony_ci   uint32_t supported_count = 0;
1291bf215546Sopenharmony_ci   for (uint32_t i = 0; i < count; i++) {
1292bf215546Sopenharmony_ci      VkPhysicalDeviceGroupProperties *group = &groups[i];
1293bf215546Sopenharmony_ci
1294bf215546Sopenharmony_ci      uint32_t group_physical_dev_count = 0;
1295bf215546Sopenharmony_ci      for (uint32_t j = 0; j < group->physicalDeviceCount; j++) {
1296bf215546Sopenharmony_ci         struct vn_physical_device_base *temp_obj =
1297bf215546Sopenharmony_ci            (struct vn_physical_device_base *)group->physicalDevices[j];
1298bf215546Sopenharmony_ci         struct vn_physical_device *physical_dev = find_physical_device(
1299bf215546Sopenharmony_ci            physical_devs, physical_dev_count, temp_obj->id);
1300bf215546Sopenharmony_ci         if (!physical_dev)
1301bf215546Sopenharmony_ci            continue;
1302bf215546Sopenharmony_ci
1303bf215546Sopenharmony_ci         group->physicalDevices[group_physical_dev_count++] =
1304bf215546Sopenharmony_ci            vn_physical_device_to_handle(physical_dev);
1305bf215546Sopenharmony_ci      }
1306bf215546Sopenharmony_ci
1307bf215546Sopenharmony_ci      group->physicalDeviceCount = group_physical_dev_count;
1308bf215546Sopenharmony_ci      if (!group->physicalDeviceCount)
1309bf215546Sopenharmony_ci         continue;
1310bf215546Sopenharmony_ci
1311bf215546Sopenharmony_ci      if (supported_count < i)
1312bf215546Sopenharmony_ci         groups[supported_count] = *group;
1313bf215546Sopenharmony_ci      supported_count++;
1314bf215546Sopenharmony_ci   }
1315bf215546Sopenharmony_ci
1316bf215546Sopenharmony_ci   count = supported_count;
1317bf215546Sopenharmony_ci   assert(count);
1318bf215546Sopenharmony_ci
1319bf215546Sopenharmony_ci   vk_free(alloc, temp_objs);
1320bf215546Sopenharmony_ci
1321bf215546Sopenharmony_ci   instance->physical_device.groups = groups;
1322bf215546Sopenharmony_ci   instance->physical_device.group_count = count;
1323bf215546Sopenharmony_ci
1324bf215546Sopenharmony_ci   return VK_SUCCESS;
1325bf215546Sopenharmony_ci}
1326bf215546Sopenharmony_ci
1327bf215546Sopenharmony_cistatic VkResult
1328bf215546Sopenharmony_cienumerate_physical_devices(struct vn_instance *instance,
1329bf215546Sopenharmony_ci                           struct vn_physical_device **out_physical_devs,
1330bf215546Sopenharmony_ci                           uint32_t *out_count)
1331bf215546Sopenharmony_ci{
1332bf215546Sopenharmony_ci   const VkAllocationCallbacks *alloc = &instance->base.base.alloc;
1333bf215546Sopenharmony_ci   struct vn_physical_device *physical_devs = NULL;
1334bf215546Sopenharmony_ci   VkPhysicalDevice *handles = NULL;
1335bf215546Sopenharmony_ci   VkResult result;
1336bf215546Sopenharmony_ci
1337bf215546Sopenharmony_ci   uint32_t count;
1338bf215546Sopenharmony_ci   result = vn_call_vkEnumeratePhysicalDevices(
1339bf215546Sopenharmony_ci      instance, vn_instance_to_handle(instance), &count, NULL);
1340bf215546Sopenharmony_ci   if (result != VK_SUCCESS || !count)
1341bf215546Sopenharmony_ci      return result;
1342bf215546Sopenharmony_ci
1343bf215546Sopenharmony_ci   physical_devs =
1344bf215546Sopenharmony_ci      vk_zalloc(alloc, sizeof(*physical_devs) * count, VN_DEFAULT_ALIGN,
1345bf215546Sopenharmony_ci                VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
1346bf215546Sopenharmony_ci   if (!physical_devs)
1347bf215546Sopenharmony_ci      return VK_ERROR_OUT_OF_HOST_MEMORY;
1348bf215546Sopenharmony_ci
1349bf215546Sopenharmony_ci   handles = vk_alloc(alloc, sizeof(*handles) * count, VN_DEFAULT_ALIGN,
1350bf215546Sopenharmony_ci                      VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
1351bf215546Sopenharmony_ci   if (!handles) {
1352bf215546Sopenharmony_ci      vk_free(alloc, physical_devs);
1353bf215546Sopenharmony_ci      return VK_ERROR_OUT_OF_HOST_MEMORY;
1354bf215546Sopenharmony_ci   }
1355bf215546Sopenharmony_ci
1356bf215546Sopenharmony_ci   for (uint32_t i = 0; i < count; i++) {
1357bf215546Sopenharmony_ci      struct vn_physical_device *physical_dev = &physical_devs[i];
1358bf215546Sopenharmony_ci
1359bf215546Sopenharmony_ci      struct vk_physical_device_dispatch_table dispatch_table;
1360bf215546Sopenharmony_ci      vk_physical_device_dispatch_table_from_entrypoints(
1361bf215546Sopenharmony_ci         &dispatch_table, &vn_physical_device_entrypoints, true);
1362bf215546Sopenharmony_ci      vk_physical_device_dispatch_table_from_entrypoints(
1363bf215546Sopenharmony_ci         &dispatch_table, &wsi_physical_device_entrypoints, false);
1364bf215546Sopenharmony_ci      result = vn_physical_device_base_init(
1365bf215546Sopenharmony_ci         &physical_dev->base, &instance->base, NULL, &dispatch_table);
1366bf215546Sopenharmony_ci      if (result != VK_SUCCESS) {
1367bf215546Sopenharmony_ci         count = i;
1368bf215546Sopenharmony_ci         goto fail;
1369bf215546Sopenharmony_ci      }
1370bf215546Sopenharmony_ci
1371bf215546Sopenharmony_ci      physical_dev->instance = instance;
1372bf215546Sopenharmony_ci
1373bf215546Sopenharmony_ci      handles[i] = vn_physical_device_to_handle(physical_dev);
1374bf215546Sopenharmony_ci   }
1375bf215546Sopenharmony_ci
1376bf215546Sopenharmony_ci   result = vn_call_vkEnumeratePhysicalDevices(
1377bf215546Sopenharmony_ci      instance, vn_instance_to_handle(instance), &count, handles);
1378bf215546Sopenharmony_ci   if (result != VK_SUCCESS)
1379bf215546Sopenharmony_ci      goto fail;
1380bf215546Sopenharmony_ci
1381bf215546Sopenharmony_ci   vk_free(alloc, handles);
1382bf215546Sopenharmony_ci   *out_physical_devs = physical_devs;
1383bf215546Sopenharmony_ci   *out_count = count;
1384bf215546Sopenharmony_ci
1385bf215546Sopenharmony_ci   return VK_SUCCESS;
1386bf215546Sopenharmony_ci
1387bf215546Sopenharmony_cifail:
1388bf215546Sopenharmony_ci   for (uint32_t i = 0; i < count; i++)
1389bf215546Sopenharmony_ci      vn_physical_device_base_fini(&physical_devs[i].base);
1390bf215546Sopenharmony_ci   vk_free(alloc, physical_devs);
1391bf215546Sopenharmony_ci   vk_free(alloc, handles);
1392bf215546Sopenharmony_ci   return result;
1393bf215546Sopenharmony_ci}
1394bf215546Sopenharmony_ci
1395bf215546Sopenharmony_cistatic uint32_t
1396bf215546Sopenharmony_cifilter_physical_devices(struct vn_physical_device *physical_devs,
1397bf215546Sopenharmony_ci                        uint32_t count)
1398bf215546Sopenharmony_ci{
1399bf215546Sopenharmony_ci   uint32_t supported_count = 0;
1400bf215546Sopenharmony_ci   for (uint32_t i = 0; i < count; i++) {
1401bf215546Sopenharmony_ci      struct vn_physical_device *physical_dev = &physical_devs[i];
1402bf215546Sopenharmony_ci
1403bf215546Sopenharmony_ci      /* init renderer version and discard unsupported devices */
1404bf215546Sopenharmony_ci      VkResult result =
1405bf215546Sopenharmony_ci         vn_physical_device_init_renderer_version(physical_dev);
1406bf215546Sopenharmony_ci      if (result != VK_SUCCESS) {
1407bf215546Sopenharmony_ci         vn_physical_device_base_fini(&physical_dev->base);
1408bf215546Sopenharmony_ci         continue;
1409bf215546Sopenharmony_ci      }
1410bf215546Sopenharmony_ci
1411bf215546Sopenharmony_ci      if (supported_count < i)
1412bf215546Sopenharmony_ci         physical_devs[supported_count] = *physical_dev;
1413bf215546Sopenharmony_ci      supported_count++;
1414bf215546Sopenharmony_ci   }
1415bf215546Sopenharmony_ci
1416bf215546Sopenharmony_ci   return supported_count;
1417bf215546Sopenharmony_ci}
1418bf215546Sopenharmony_ci
1419bf215546Sopenharmony_cistatic VkResult
1420bf215546Sopenharmony_civn_instance_enumerate_physical_devices_and_groups(struct vn_instance *instance)
1421bf215546Sopenharmony_ci{
1422bf215546Sopenharmony_ci   const VkAllocationCallbacks *alloc = &instance->base.base.alloc;
1423bf215546Sopenharmony_ci   struct vn_physical_device *physical_devs = NULL;
1424bf215546Sopenharmony_ci   uint32_t count = 0;
1425bf215546Sopenharmony_ci   VkResult result = VK_SUCCESS;
1426bf215546Sopenharmony_ci
1427bf215546Sopenharmony_ci   mtx_lock(&instance->physical_device.mutex);
1428bf215546Sopenharmony_ci
1429bf215546Sopenharmony_ci   if (instance->physical_device.initialized)
1430bf215546Sopenharmony_ci      goto unlock;
1431bf215546Sopenharmony_ci   instance->physical_device.initialized = true;
1432bf215546Sopenharmony_ci
1433bf215546Sopenharmony_ci   result = enumerate_physical_devices(instance, &physical_devs, &count);
1434bf215546Sopenharmony_ci   if (result != VK_SUCCESS)
1435bf215546Sopenharmony_ci      goto unlock;
1436bf215546Sopenharmony_ci
1437bf215546Sopenharmony_ci   count = filter_physical_devices(physical_devs, count);
1438bf215546Sopenharmony_ci   if (!count) {
1439bf215546Sopenharmony_ci      vk_free(alloc, physical_devs);
1440bf215546Sopenharmony_ci      goto unlock;
1441bf215546Sopenharmony_ci   }
1442bf215546Sopenharmony_ci
1443bf215546Sopenharmony_ci   /* fully initialize physical devices */
1444bf215546Sopenharmony_ci   for (uint32_t i = 0; i < count; i++) {
1445bf215546Sopenharmony_ci      struct vn_physical_device *physical_dev = &physical_devs[i];
1446bf215546Sopenharmony_ci
1447bf215546Sopenharmony_ci      result = vn_physical_device_init(physical_dev);
1448bf215546Sopenharmony_ci      if (result != VK_SUCCESS) {
1449bf215546Sopenharmony_ci         for (uint32_t j = 0; j < i; j++)
1450bf215546Sopenharmony_ci            vn_physical_device_fini(&physical_devs[j]);
1451bf215546Sopenharmony_ci         for (uint32_t j = i; j < count; j++)
1452bf215546Sopenharmony_ci            vn_physical_device_base_fini(&physical_devs[j].base);
1453bf215546Sopenharmony_ci         vk_free(alloc, physical_devs);
1454bf215546Sopenharmony_ci         goto unlock;
1455bf215546Sopenharmony_ci      }
1456bf215546Sopenharmony_ci   }
1457bf215546Sopenharmony_ci
1458bf215546Sopenharmony_ci   result = vn_instance_enumerate_physical_device_groups_locked(
1459bf215546Sopenharmony_ci      instance, physical_devs, count);
1460bf215546Sopenharmony_ci   if (result != VK_SUCCESS) {
1461bf215546Sopenharmony_ci      for (uint32_t i = 0; i < count; i++)
1462bf215546Sopenharmony_ci         vn_physical_device_fini(&physical_devs[i]);
1463bf215546Sopenharmony_ci      vk_free(alloc, physical_devs);
1464bf215546Sopenharmony_ci      goto unlock;
1465bf215546Sopenharmony_ci   }
1466bf215546Sopenharmony_ci
1467bf215546Sopenharmony_ci   instance->physical_device.devices = physical_devs;
1468bf215546Sopenharmony_ci   instance->physical_device.device_count = count;
1469bf215546Sopenharmony_ci
1470bf215546Sopenharmony_ciunlock:
1471bf215546Sopenharmony_ci   mtx_unlock(&instance->physical_device.mutex);
1472bf215546Sopenharmony_ci   return result;
1473bf215546Sopenharmony_ci}
1474bf215546Sopenharmony_ci
1475bf215546Sopenharmony_ci/* physical device commands */
1476bf215546Sopenharmony_ci
1477bf215546Sopenharmony_ciVkResult
1478bf215546Sopenharmony_civn_EnumeratePhysicalDevices(VkInstance _instance,
1479bf215546Sopenharmony_ci                            uint32_t *pPhysicalDeviceCount,
1480bf215546Sopenharmony_ci                            VkPhysicalDevice *pPhysicalDevices)
1481bf215546Sopenharmony_ci{
1482bf215546Sopenharmony_ci   struct vn_instance *instance = vn_instance_from_handle(_instance);
1483bf215546Sopenharmony_ci
1484bf215546Sopenharmony_ci   VkResult result =
1485bf215546Sopenharmony_ci      vn_instance_enumerate_physical_devices_and_groups(instance);
1486bf215546Sopenharmony_ci   if (result != VK_SUCCESS)
1487bf215546Sopenharmony_ci      return vn_error(instance, result);
1488bf215546Sopenharmony_ci
1489bf215546Sopenharmony_ci   VK_OUTARRAY_MAKE_TYPED(VkPhysicalDevice, out, pPhysicalDevices, pPhysicalDeviceCount);
1490bf215546Sopenharmony_ci   for (uint32_t i = 0; i < instance->physical_device.device_count; i++) {
1491bf215546Sopenharmony_ci      vk_outarray_append_typed(VkPhysicalDevice, &out, physical_dev) {
1492bf215546Sopenharmony_ci         *physical_dev = vn_physical_device_to_handle(
1493bf215546Sopenharmony_ci            &instance->physical_device.devices[i]);
1494bf215546Sopenharmony_ci      }
1495bf215546Sopenharmony_ci   }
1496bf215546Sopenharmony_ci
1497bf215546Sopenharmony_ci   return vk_outarray_status(&out);
1498bf215546Sopenharmony_ci}
1499bf215546Sopenharmony_ci
1500bf215546Sopenharmony_ciVkResult
1501bf215546Sopenharmony_civn_EnumeratePhysicalDeviceGroups(
1502bf215546Sopenharmony_ci   VkInstance _instance,
1503bf215546Sopenharmony_ci   uint32_t *pPhysicalDeviceGroupCount,
1504bf215546Sopenharmony_ci   VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties)
1505bf215546Sopenharmony_ci{
1506bf215546Sopenharmony_ci   struct vn_instance *instance = vn_instance_from_handle(_instance);
1507bf215546Sopenharmony_ci
1508bf215546Sopenharmony_ci   VkResult result =
1509bf215546Sopenharmony_ci      vn_instance_enumerate_physical_devices_and_groups(instance);
1510bf215546Sopenharmony_ci   if (result != VK_SUCCESS)
1511bf215546Sopenharmony_ci      return vn_error(instance, result);
1512bf215546Sopenharmony_ci
1513bf215546Sopenharmony_ci   VK_OUTARRAY_MAKE_TYPED(VkPhysicalDeviceGroupProperties, out,
1514bf215546Sopenharmony_ci                          pPhysicalDeviceGroupProperties,
1515bf215546Sopenharmony_ci                          pPhysicalDeviceGroupCount);
1516bf215546Sopenharmony_ci   for (uint32_t i = 0; i < instance->physical_device.group_count; i++) {
1517bf215546Sopenharmony_ci      vk_outarray_append_typed(VkPhysicalDeviceGroupProperties, &out, props) {
1518bf215546Sopenharmony_ci         *props = instance->physical_device.groups[i];
1519bf215546Sopenharmony_ci      }
1520bf215546Sopenharmony_ci   }
1521bf215546Sopenharmony_ci
1522bf215546Sopenharmony_ci   return vk_outarray_status(&out);
1523bf215546Sopenharmony_ci}
1524bf215546Sopenharmony_ci
1525bf215546Sopenharmony_ciVkResult
1526bf215546Sopenharmony_civn_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
1527bf215546Sopenharmony_ci                                      const char *pLayerName,
1528bf215546Sopenharmony_ci                                      uint32_t *pPropertyCount,
1529bf215546Sopenharmony_ci                                      VkExtensionProperties *pProperties)
1530bf215546Sopenharmony_ci{
1531bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
1532bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
1533bf215546Sopenharmony_ci
1534bf215546Sopenharmony_ci   if (pLayerName)
1535bf215546Sopenharmony_ci      return vn_error(physical_dev->instance, VK_ERROR_LAYER_NOT_PRESENT);
1536bf215546Sopenharmony_ci
1537bf215546Sopenharmony_ci   VK_OUTARRAY_MAKE_TYPED(VkExtensionProperties, out, pProperties, pPropertyCount);
1538bf215546Sopenharmony_ci   for (uint32_t i = 0; i < VK_DEVICE_EXTENSION_COUNT; i++) {
1539bf215546Sopenharmony_ci      if (physical_dev->base.base.supported_extensions.extensions[i]) {
1540bf215546Sopenharmony_ci         vk_outarray_append_typed(VkExtensionProperties, &out, prop) {
1541bf215546Sopenharmony_ci            *prop = vk_device_extensions[i];
1542bf215546Sopenharmony_ci            prop->specVersion = physical_dev->extension_spec_versions[i];
1543bf215546Sopenharmony_ci         }
1544bf215546Sopenharmony_ci      }
1545bf215546Sopenharmony_ci   }
1546bf215546Sopenharmony_ci
1547bf215546Sopenharmony_ci   return vk_outarray_status(&out);
1548bf215546Sopenharmony_ci}
1549bf215546Sopenharmony_ci
1550bf215546Sopenharmony_ciVkResult
1551bf215546Sopenharmony_civn_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice,
1552bf215546Sopenharmony_ci                                  uint32_t *pPropertyCount,
1553bf215546Sopenharmony_ci                                  VkLayerProperties *pProperties)
1554bf215546Sopenharmony_ci{
1555bf215546Sopenharmony_ci   *pPropertyCount = 0;
1556bf215546Sopenharmony_ci   return VK_SUCCESS;
1557bf215546Sopenharmony_ci}
1558bf215546Sopenharmony_ci
1559bf215546Sopenharmony_cistatic struct vn_format_properties_entry *
1560bf215546Sopenharmony_civn_physical_device_get_format_properties(
1561bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev, VkFormat format)
1562bf215546Sopenharmony_ci{
1563bf215546Sopenharmony_ci   return util_sparse_array_get(&physical_dev->format_properties, format);
1564bf215546Sopenharmony_ci}
1565bf215546Sopenharmony_ci
1566bf215546Sopenharmony_cistatic void
1567bf215546Sopenharmony_civn_physical_device_add_format_properties(
1568bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev,
1569bf215546Sopenharmony_ci   struct vn_format_properties_entry *entry,
1570bf215546Sopenharmony_ci   const VkFormatProperties *props)
1571bf215546Sopenharmony_ci{
1572bf215546Sopenharmony_ci   simple_mtx_lock(&physical_dev->format_update_mutex);
1573bf215546Sopenharmony_ci   if (!entry->valid) {
1574bf215546Sopenharmony_ci      entry->properties = *props;
1575bf215546Sopenharmony_ci      entry->valid = true;
1576bf215546Sopenharmony_ci   }
1577bf215546Sopenharmony_ci   simple_mtx_unlock(&physical_dev->format_update_mutex);
1578bf215546Sopenharmony_ci}
1579bf215546Sopenharmony_ci
1580bf215546Sopenharmony_civoid
1581bf215546Sopenharmony_civn_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
1582bf215546Sopenharmony_ci                              VkPhysicalDeviceFeatures2 *pFeatures)
1583bf215546Sopenharmony_ci{
1584bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
1585bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
1586bf215546Sopenharmony_ci   const struct vn_physical_device_features *feats = &physical_dev->features;
1587bf215546Sopenharmony_ci   const struct VkPhysicalDeviceVulkan11Features *vk11_feats =
1588bf215546Sopenharmony_ci      &feats->vulkan_1_1;
1589bf215546Sopenharmony_ci   const struct VkPhysicalDeviceVulkan12Features *vk12_feats =
1590bf215546Sopenharmony_ci      &feats->vulkan_1_2;
1591bf215546Sopenharmony_ci   union {
1592bf215546Sopenharmony_ci      VkBaseOutStructure *pnext;
1593bf215546Sopenharmony_ci
1594bf215546Sopenharmony_ci      VkPhysicalDeviceFeatures2 *features2;
1595bf215546Sopenharmony_ci      VkPhysicalDeviceVulkan11Features *vulkan_1_1;
1596bf215546Sopenharmony_ci      VkPhysicalDeviceVulkan12Features *vulkan_1_2;
1597bf215546Sopenharmony_ci
1598bf215546Sopenharmony_ci      /* Vulkan 1.1 */
1599bf215546Sopenharmony_ci      VkPhysicalDevice16BitStorageFeatures *sixteen_bit_storage;
1600bf215546Sopenharmony_ci      VkPhysicalDeviceMultiviewFeatures *multiview;
1601bf215546Sopenharmony_ci      VkPhysicalDeviceVariablePointersFeatures *variable_pointers;
1602bf215546Sopenharmony_ci      VkPhysicalDeviceProtectedMemoryFeatures *protected_memory;
1603bf215546Sopenharmony_ci      VkPhysicalDeviceSamplerYcbcrConversionFeatures *sampler_ycbcr_conversion;
1604bf215546Sopenharmony_ci      VkPhysicalDeviceShaderDrawParametersFeatures *shader_draw_parameters;
1605bf215546Sopenharmony_ci
1606bf215546Sopenharmony_ci      /* Vulkan 1.2 */
1607bf215546Sopenharmony_ci      VkPhysicalDevice8BitStorageFeatures *eight_bit_storage;
1608bf215546Sopenharmony_ci      VkPhysicalDeviceShaderAtomicInt64Features *shader_atomic_int64;
1609bf215546Sopenharmony_ci      VkPhysicalDeviceShaderFloat16Int8Features *shader_float16_int8;
1610bf215546Sopenharmony_ci      VkPhysicalDeviceDescriptorIndexingFeatures *descriptor_indexing;
1611bf215546Sopenharmony_ci      VkPhysicalDeviceScalarBlockLayoutFeatures *scalar_block_layout;
1612bf215546Sopenharmony_ci      VkPhysicalDeviceImagelessFramebufferFeatures *imageless_framebuffer;
1613bf215546Sopenharmony_ci      VkPhysicalDeviceUniformBufferStandardLayoutFeatures
1614bf215546Sopenharmony_ci         *uniform_buffer_standard_layout;
1615bf215546Sopenharmony_ci      VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures
1616bf215546Sopenharmony_ci         *shader_subgroup_extended_types;
1617bf215546Sopenharmony_ci      VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures
1618bf215546Sopenharmony_ci         *separate_depth_stencil_layouts;
1619bf215546Sopenharmony_ci      VkPhysicalDeviceHostQueryResetFeatures *host_query_reset;
1620bf215546Sopenharmony_ci      VkPhysicalDeviceTimelineSemaphoreFeatures *timeline_semaphore;
1621bf215546Sopenharmony_ci      VkPhysicalDeviceBufferDeviceAddressFeatures *buffer_device_address;
1622bf215546Sopenharmony_ci      VkPhysicalDeviceVulkanMemoryModelFeatures *vulkan_memory_model;
1623bf215546Sopenharmony_ci
1624bf215546Sopenharmony_ci      /* Vulkan 1.3 */
1625bf215546Sopenharmony_ci      VkPhysicalDevice4444FormatsFeaturesEXT *argb_4444_formats;
1626bf215546Sopenharmony_ci      VkPhysicalDeviceDynamicRenderingFeatures *dynamic_rendering;
1627bf215546Sopenharmony_ci      VkPhysicalDeviceExtendedDynamicStateFeaturesEXT *extended_dynamic_state;
1628bf215546Sopenharmony_ci      VkPhysicalDeviceExtendedDynamicState2FeaturesEXT
1629bf215546Sopenharmony_ci         *extended_dynamic_state2;
1630bf215546Sopenharmony_ci      VkPhysicalDeviceImageRobustnessFeatures *image_robustness;
1631bf215546Sopenharmony_ci      VkPhysicalDeviceInlineUniformBlockFeatures *inline_uniform_block;
1632bf215546Sopenharmony_ci      VkPhysicalDeviceMaintenance4Features *maintenance4;
1633bf215546Sopenharmony_ci      VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures
1634bf215546Sopenharmony_ci         *shader_demote_to_helper_invocation;
1635bf215546Sopenharmony_ci
1636bf215546Sopenharmony_ci      /* EXT */
1637bf215546Sopenharmony_ci      VkPhysicalDeviceConditionalRenderingFeaturesEXT *conditional_rendering;
1638bf215546Sopenharmony_ci      VkPhysicalDeviceCustomBorderColorFeaturesEXT *custom_border_color;
1639bf215546Sopenharmony_ci      VkPhysicalDeviceDepthClipEnableFeaturesEXT *depth_clip_enable;
1640bf215546Sopenharmony_ci      VkPhysicalDeviceIndexTypeUint8FeaturesEXT *index_type_uint8;
1641bf215546Sopenharmony_ci      VkPhysicalDeviceLineRasterizationFeaturesEXT *line_rasterization;
1642bf215546Sopenharmony_ci      VkPhysicalDeviceProvokingVertexFeaturesEXT *provoking_vertex;
1643bf215546Sopenharmony_ci      VkPhysicalDeviceRobustness2FeaturesEXT *robustness_2;
1644bf215546Sopenharmony_ci      VkPhysicalDeviceTransformFeedbackFeaturesEXT *transform_feedback;
1645bf215546Sopenharmony_ci      VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT
1646bf215546Sopenharmony_ci         *vertex_attribute_divisor;
1647bf215546Sopenharmony_ci   } u;
1648bf215546Sopenharmony_ci
1649bf215546Sopenharmony_ci   u.pnext = (VkBaseOutStructure *)pFeatures;
1650bf215546Sopenharmony_ci   while (u.pnext) {
1651bf215546Sopenharmony_ci      void *saved = u.pnext->pNext;
1652bf215546Sopenharmony_ci      switch (u.pnext->sType) {
1653bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2:
1654bf215546Sopenharmony_ci         u.features2->features = feats->vulkan_1_0;
1655bf215546Sopenharmony_ci         break;
1656bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES:
1657bf215546Sopenharmony_ci         *u.vulkan_1_1 = *vk11_feats;
1658bf215546Sopenharmony_ci         break;
1659bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES:
1660bf215546Sopenharmony_ci         *u.vulkan_1_2 = *vk12_feats;
1661bf215546Sopenharmony_ci         break;
1662bf215546Sopenharmony_ci
1663bf215546Sopenharmony_ci      /* Vulkan 1.1 */
1664bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
1665bf215546Sopenharmony_ci         u.sixteen_bit_storage->storageBuffer16BitAccess =
1666bf215546Sopenharmony_ci            vk11_feats->storageBuffer16BitAccess;
1667bf215546Sopenharmony_ci         u.sixteen_bit_storage->uniformAndStorageBuffer16BitAccess =
1668bf215546Sopenharmony_ci            vk11_feats->uniformAndStorageBuffer16BitAccess;
1669bf215546Sopenharmony_ci         u.sixteen_bit_storage->storagePushConstant16 =
1670bf215546Sopenharmony_ci            vk11_feats->storagePushConstant16;
1671bf215546Sopenharmony_ci         u.sixteen_bit_storage->storageInputOutput16 =
1672bf215546Sopenharmony_ci            vk11_feats->storageInputOutput16;
1673bf215546Sopenharmony_ci         break;
1674bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES:
1675bf215546Sopenharmony_ci         u.multiview->multiview = vk11_feats->multiview;
1676bf215546Sopenharmony_ci         u.multiview->multiviewGeometryShader =
1677bf215546Sopenharmony_ci            vk11_feats->multiviewGeometryShader;
1678bf215546Sopenharmony_ci         u.multiview->multiviewTessellationShader =
1679bf215546Sopenharmony_ci            vk11_feats->multiviewTessellationShader;
1680bf215546Sopenharmony_ci         break;
1681bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES:
1682bf215546Sopenharmony_ci         u.variable_pointers->variablePointersStorageBuffer =
1683bf215546Sopenharmony_ci            vk11_feats->variablePointersStorageBuffer;
1684bf215546Sopenharmony_ci         u.variable_pointers->variablePointers = vk11_feats->variablePointers;
1685bf215546Sopenharmony_ci         break;
1686bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES:
1687bf215546Sopenharmony_ci         u.protected_memory->protectedMemory = vk11_feats->protectedMemory;
1688bf215546Sopenharmony_ci         break;
1689bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
1690bf215546Sopenharmony_ci         u.sampler_ycbcr_conversion->samplerYcbcrConversion =
1691bf215546Sopenharmony_ci            vk11_feats->samplerYcbcrConversion;
1692bf215546Sopenharmony_ci         break;
1693bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES:
1694bf215546Sopenharmony_ci         u.shader_draw_parameters->shaderDrawParameters =
1695bf215546Sopenharmony_ci            vk11_feats->shaderDrawParameters;
1696bf215546Sopenharmony_ci         break;
1697bf215546Sopenharmony_ci
1698bf215546Sopenharmony_ci      /* Vulkan 1.2 */
1699bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES:
1700bf215546Sopenharmony_ci         u.eight_bit_storage->storageBuffer8BitAccess =
1701bf215546Sopenharmony_ci            vk12_feats->storageBuffer8BitAccess;
1702bf215546Sopenharmony_ci         u.eight_bit_storage->uniformAndStorageBuffer8BitAccess =
1703bf215546Sopenharmony_ci            vk12_feats->uniformAndStorageBuffer8BitAccess;
1704bf215546Sopenharmony_ci         u.eight_bit_storage->storagePushConstant8 =
1705bf215546Sopenharmony_ci            vk12_feats->storagePushConstant8;
1706bf215546Sopenharmony_ci         break;
1707bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES:
1708bf215546Sopenharmony_ci         u.shader_atomic_int64->shaderBufferInt64Atomics =
1709bf215546Sopenharmony_ci            vk12_feats->shaderBufferInt64Atomics;
1710bf215546Sopenharmony_ci         u.shader_atomic_int64->shaderSharedInt64Atomics =
1711bf215546Sopenharmony_ci            vk12_feats->shaderSharedInt64Atomics;
1712bf215546Sopenharmony_ci         break;
1713bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES:
1714bf215546Sopenharmony_ci         u.shader_float16_int8->shaderFloat16 = vk12_feats->shaderFloat16;
1715bf215546Sopenharmony_ci         u.shader_float16_int8->shaderInt8 = vk12_feats->shaderInt8;
1716bf215546Sopenharmony_ci         break;
1717bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES:
1718bf215546Sopenharmony_ci         u.descriptor_indexing->shaderInputAttachmentArrayDynamicIndexing =
1719bf215546Sopenharmony_ci            vk12_feats->shaderInputAttachmentArrayDynamicIndexing;
1720bf215546Sopenharmony_ci         u.descriptor_indexing->shaderUniformTexelBufferArrayDynamicIndexing =
1721bf215546Sopenharmony_ci            vk12_feats->shaderUniformTexelBufferArrayDynamicIndexing;
1722bf215546Sopenharmony_ci         u.descriptor_indexing->shaderStorageTexelBufferArrayDynamicIndexing =
1723bf215546Sopenharmony_ci            vk12_feats->shaderStorageTexelBufferArrayDynamicIndexing;
1724bf215546Sopenharmony_ci         u.descriptor_indexing->shaderUniformBufferArrayNonUniformIndexing =
1725bf215546Sopenharmony_ci            vk12_feats->shaderUniformBufferArrayNonUniformIndexing;
1726bf215546Sopenharmony_ci         u.descriptor_indexing->shaderSampledImageArrayNonUniformIndexing =
1727bf215546Sopenharmony_ci            vk12_feats->shaderSampledImageArrayNonUniformIndexing;
1728bf215546Sopenharmony_ci         u.descriptor_indexing->shaderStorageBufferArrayNonUniformIndexing =
1729bf215546Sopenharmony_ci            vk12_feats->shaderStorageBufferArrayNonUniformIndexing;
1730bf215546Sopenharmony_ci         u.descriptor_indexing->shaderStorageImageArrayNonUniformIndexing =
1731bf215546Sopenharmony_ci            vk12_feats->shaderStorageImageArrayNonUniformIndexing;
1732bf215546Sopenharmony_ci         u.descriptor_indexing->shaderInputAttachmentArrayNonUniformIndexing =
1733bf215546Sopenharmony_ci            vk12_feats->shaderInputAttachmentArrayNonUniformIndexing;
1734bf215546Sopenharmony_ci         u.descriptor_indexing
1735bf215546Sopenharmony_ci            ->shaderUniformTexelBufferArrayNonUniformIndexing =
1736bf215546Sopenharmony_ci            vk12_feats->shaderUniformTexelBufferArrayNonUniformIndexing;
1737bf215546Sopenharmony_ci         u.descriptor_indexing
1738bf215546Sopenharmony_ci            ->shaderStorageTexelBufferArrayNonUniformIndexing =
1739bf215546Sopenharmony_ci            vk12_feats->shaderStorageTexelBufferArrayNonUniformIndexing;
1740bf215546Sopenharmony_ci         u.descriptor_indexing->descriptorBindingUniformBufferUpdateAfterBind =
1741bf215546Sopenharmony_ci            vk12_feats->descriptorBindingUniformBufferUpdateAfterBind;
1742bf215546Sopenharmony_ci         u.descriptor_indexing->descriptorBindingSampledImageUpdateAfterBind =
1743bf215546Sopenharmony_ci            vk12_feats->descriptorBindingSampledImageUpdateAfterBind;
1744bf215546Sopenharmony_ci         u.descriptor_indexing->descriptorBindingStorageImageUpdateAfterBind =
1745bf215546Sopenharmony_ci            vk12_feats->descriptorBindingStorageImageUpdateAfterBind;
1746bf215546Sopenharmony_ci         u.descriptor_indexing->descriptorBindingStorageBufferUpdateAfterBind =
1747bf215546Sopenharmony_ci            vk12_feats->descriptorBindingStorageBufferUpdateAfterBind;
1748bf215546Sopenharmony_ci         u.descriptor_indexing
1749bf215546Sopenharmony_ci            ->descriptorBindingUniformTexelBufferUpdateAfterBind =
1750bf215546Sopenharmony_ci            vk12_feats->descriptorBindingUniformTexelBufferUpdateAfterBind;
1751bf215546Sopenharmony_ci         u.descriptor_indexing
1752bf215546Sopenharmony_ci            ->descriptorBindingStorageTexelBufferUpdateAfterBind =
1753bf215546Sopenharmony_ci            vk12_feats->descriptorBindingStorageTexelBufferUpdateAfterBind;
1754bf215546Sopenharmony_ci         u.descriptor_indexing->descriptorBindingUpdateUnusedWhilePending =
1755bf215546Sopenharmony_ci            vk12_feats->descriptorBindingUpdateUnusedWhilePending;
1756bf215546Sopenharmony_ci         u.descriptor_indexing->descriptorBindingPartiallyBound =
1757bf215546Sopenharmony_ci            vk12_feats->descriptorBindingPartiallyBound;
1758bf215546Sopenharmony_ci         u.descriptor_indexing->descriptorBindingVariableDescriptorCount =
1759bf215546Sopenharmony_ci            vk12_feats->descriptorBindingVariableDescriptorCount;
1760bf215546Sopenharmony_ci         u.descriptor_indexing->runtimeDescriptorArray =
1761bf215546Sopenharmony_ci            vk12_feats->runtimeDescriptorArray;
1762bf215546Sopenharmony_ci         break;
1763bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES:
1764bf215546Sopenharmony_ci         u.scalar_block_layout->scalarBlockLayout =
1765bf215546Sopenharmony_ci            vk12_feats->scalarBlockLayout;
1766bf215546Sopenharmony_ci         break;
1767bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES:
1768bf215546Sopenharmony_ci         u.imageless_framebuffer->imagelessFramebuffer =
1769bf215546Sopenharmony_ci            vk12_feats->imagelessFramebuffer;
1770bf215546Sopenharmony_ci         break;
1771bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES:
1772bf215546Sopenharmony_ci         u.uniform_buffer_standard_layout->uniformBufferStandardLayout =
1773bf215546Sopenharmony_ci            vk12_feats->uniformBufferStandardLayout;
1774bf215546Sopenharmony_ci         break;
1775bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES:
1776bf215546Sopenharmony_ci         u.shader_subgroup_extended_types->shaderSubgroupExtendedTypes =
1777bf215546Sopenharmony_ci            vk12_feats->shaderSubgroupExtendedTypes;
1778bf215546Sopenharmony_ci         break;
1779bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES:
1780bf215546Sopenharmony_ci         u.separate_depth_stencil_layouts->separateDepthStencilLayouts =
1781bf215546Sopenharmony_ci            vk12_feats->separateDepthStencilLayouts;
1782bf215546Sopenharmony_ci         break;
1783bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES:
1784bf215546Sopenharmony_ci         u.host_query_reset->hostQueryReset = vk12_feats->hostQueryReset;
1785bf215546Sopenharmony_ci         break;
1786bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES:
1787bf215546Sopenharmony_ci         u.timeline_semaphore->timelineSemaphore =
1788bf215546Sopenharmony_ci            vk12_feats->timelineSemaphore;
1789bf215546Sopenharmony_ci         break;
1790bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES:
1791bf215546Sopenharmony_ci         u.buffer_device_address->bufferDeviceAddress =
1792bf215546Sopenharmony_ci            vk12_feats->bufferDeviceAddress;
1793bf215546Sopenharmony_ci         u.buffer_device_address->bufferDeviceAddressCaptureReplay =
1794bf215546Sopenharmony_ci            vk12_feats->bufferDeviceAddressCaptureReplay;
1795bf215546Sopenharmony_ci         u.buffer_device_address->bufferDeviceAddressMultiDevice =
1796bf215546Sopenharmony_ci            vk12_feats->bufferDeviceAddressMultiDevice;
1797bf215546Sopenharmony_ci         break;
1798bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES:
1799bf215546Sopenharmony_ci         u.vulkan_memory_model->vulkanMemoryModel =
1800bf215546Sopenharmony_ci            vk12_feats->vulkanMemoryModel;
1801bf215546Sopenharmony_ci         u.vulkan_memory_model->vulkanMemoryModelDeviceScope =
1802bf215546Sopenharmony_ci            vk12_feats->vulkanMemoryModelDeviceScope;
1803bf215546Sopenharmony_ci         u.vulkan_memory_model->vulkanMemoryModelAvailabilityVisibilityChains =
1804bf215546Sopenharmony_ci            vk12_feats->vulkanMemoryModelAvailabilityVisibilityChains;
1805bf215546Sopenharmony_ci         break;
1806bf215546Sopenharmony_ci
1807bf215546Sopenharmony_ci      /* Vulkan 1.3 */
1808bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT:
1809bf215546Sopenharmony_ci         *u.argb_4444_formats = feats->argb_4444_formats;
1810bf215546Sopenharmony_ci         break;
1811bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES:
1812bf215546Sopenharmony_ci         *u.dynamic_rendering = feats->dynamic_rendering;
1813bf215546Sopenharmony_ci         break;
1814bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT:
1815bf215546Sopenharmony_ci         *u.extended_dynamic_state = feats->extended_dynamic_state;
1816bf215546Sopenharmony_ci         break;
1817bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT:
1818bf215546Sopenharmony_ci         *u.extended_dynamic_state2 = feats->extended_dynamic_state_2;
1819bf215546Sopenharmony_ci         break;
1820bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES:
1821bf215546Sopenharmony_ci         *u.image_robustness = feats->image_robustness;
1822bf215546Sopenharmony_ci         break;
1823bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES:
1824bf215546Sopenharmony_ci         *u.inline_uniform_block = feats->inline_uniform_block;
1825bf215546Sopenharmony_ci         break;
1826bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES:
1827bf215546Sopenharmony_ci         *u.shader_demote_to_helper_invocation =
1828bf215546Sopenharmony_ci            feats->shader_demote_to_helper_invocation;
1829bf215546Sopenharmony_ci         break;
1830bf215546Sopenharmony_ci
1831bf215546Sopenharmony_ci      /* EXT */
1832bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT:
1833bf215546Sopenharmony_ci         *u.conditional_rendering = feats->conditional_rendering;
1834bf215546Sopenharmony_ci         break;
1835bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT:
1836bf215546Sopenharmony_ci         *u.custom_border_color = feats->custom_border_color;
1837bf215546Sopenharmony_ci         break;
1838bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT:
1839bf215546Sopenharmony_ci         *u.depth_clip_enable = feats->depth_clip_enable;
1840bf215546Sopenharmony_ci         break;
1841bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT:
1842bf215546Sopenharmony_ci         *u.index_type_uint8 = feats->index_type_uint8;
1843bf215546Sopenharmony_ci         break;
1844bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT:
1845bf215546Sopenharmony_ci         *u.line_rasterization = feats->line_rasterization;
1846bf215546Sopenharmony_ci         break;
1847bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT:
1848bf215546Sopenharmony_ci         *u.provoking_vertex = feats->provoking_vertex;
1849bf215546Sopenharmony_ci         break;
1850bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT:
1851bf215546Sopenharmony_ci         *u.robustness_2 = feats->robustness_2;
1852bf215546Sopenharmony_ci         break;
1853bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT:
1854bf215546Sopenharmony_ci         *u.transform_feedback = feats->transform_feedback;
1855bf215546Sopenharmony_ci         break;
1856bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT:
1857bf215546Sopenharmony_ci         *u.vertex_attribute_divisor = feats->vertex_attribute_divisor;
1858bf215546Sopenharmony_ci         break;
1859bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES:
1860bf215546Sopenharmony_ci         *u.maintenance4 = feats->maintenance4;
1861bf215546Sopenharmony_ci         break;
1862bf215546Sopenharmony_ci      default:
1863bf215546Sopenharmony_ci         break;
1864bf215546Sopenharmony_ci      }
1865bf215546Sopenharmony_ci
1866bf215546Sopenharmony_ci      u.pnext->pNext = saved;
1867bf215546Sopenharmony_ci      u.pnext = u.pnext->pNext;
1868bf215546Sopenharmony_ci   }
1869bf215546Sopenharmony_ci}
1870bf215546Sopenharmony_ci
1871bf215546Sopenharmony_civoid
1872bf215546Sopenharmony_civn_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
1873bf215546Sopenharmony_ci                                VkPhysicalDeviceProperties2 *pProperties)
1874bf215546Sopenharmony_ci{
1875bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
1876bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
1877bf215546Sopenharmony_ci   const struct vn_physical_device_properties *props =
1878bf215546Sopenharmony_ci      &physical_dev->properties;
1879bf215546Sopenharmony_ci   const struct VkPhysicalDeviceVulkan11Properties *vk11_props =
1880bf215546Sopenharmony_ci      &props->vulkan_1_1;
1881bf215546Sopenharmony_ci   const struct VkPhysicalDeviceVulkan12Properties *vk12_props =
1882bf215546Sopenharmony_ci      &props->vulkan_1_2;
1883bf215546Sopenharmony_ci   union {
1884bf215546Sopenharmony_ci      VkBaseOutStructure *pnext;
1885bf215546Sopenharmony_ci
1886bf215546Sopenharmony_ci      VkPhysicalDeviceProperties2 *properties2;
1887bf215546Sopenharmony_ci      VkPhysicalDeviceVulkan11Properties *vulkan_1_1;
1888bf215546Sopenharmony_ci      VkPhysicalDeviceVulkan12Properties *vulkan_1_2;
1889bf215546Sopenharmony_ci
1890bf215546Sopenharmony_ci      /* Vulkan 1.1 */
1891bf215546Sopenharmony_ci      VkPhysicalDeviceIDProperties *id;
1892bf215546Sopenharmony_ci      VkPhysicalDeviceSubgroupProperties *subgroup;
1893bf215546Sopenharmony_ci      VkPhysicalDevicePointClippingProperties *point_clipping;
1894bf215546Sopenharmony_ci      VkPhysicalDeviceMultiviewProperties *multiview;
1895bf215546Sopenharmony_ci      VkPhysicalDeviceProtectedMemoryProperties *protected_memory;
1896bf215546Sopenharmony_ci      VkPhysicalDeviceMaintenance3Properties *maintenance_3;
1897bf215546Sopenharmony_ci
1898bf215546Sopenharmony_ci      /* Vulkan 1.2 */
1899bf215546Sopenharmony_ci      VkPhysicalDeviceDriverProperties *driver;
1900bf215546Sopenharmony_ci      VkPhysicalDeviceFloatControlsProperties *float_controls;
1901bf215546Sopenharmony_ci      VkPhysicalDeviceDescriptorIndexingProperties *descriptor_indexing;
1902bf215546Sopenharmony_ci      VkPhysicalDeviceDepthStencilResolveProperties *depth_stencil_resolve;
1903bf215546Sopenharmony_ci      VkPhysicalDeviceSamplerFilterMinmaxProperties *sampler_filter_minmax;
1904bf215546Sopenharmony_ci      VkPhysicalDeviceTimelineSemaphoreProperties *timeline_semaphore;
1905bf215546Sopenharmony_ci
1906bf215546Sopenharmony_ci      /* Vulkan 1.3 */
1907bf215546Sopenharmony_ci      VkPhysicalDeviceInlineUniformBlockProperties *inline_uniform_block;
1908bf215546Sopenharmony_ci
1909bf215546Sopenharmony_ci      /* EXT */
1910bf215546Sopenharmony_ci      VkPhysicalDeviceConservativeRasterizationPropertiesEXT
1911bf215546Sopenharmony_ci         *conservative_rasterization;
1912bf215546Sopenharmony_ci      VkPhysicalDeviceCustomBorderColorPropertiesEXT *custom_border_color;
1913bf215546Sopenharmony_ci      VkPhysicalDeviceDrmPropertiesEXT *drm;
1914bf215546Sopenharmony_ci      VkPhysicalDeviceLineRasterizationPropertiesEXT *line_rasterization;
1915bf215546Sopenharmony_ci      VkPhysicalDevicePCIBusInfoPropertiesEXT *pci_bus_info;
1916bf215546Sopenharmony_ci      VkPhysicalDevicePresentationPropertiesANDROID *presentation_properties;
1917bf215546Sopenharmony_ci      VkPhysicalDeviceProvokingVertexPropertiesEXT *provoking_vertex;
1918bf215546Sopenharmony_ci      VkPhysicalDeviceRobustness2PropertiesEXT *robustness_2;
1919bf215546Sopenharmony_ci      VkPhysicalDeviceMaintenance4Properties *maintenance4;
1920bf215546Sopenharmony_ci      VkPhysicalDeviceTransformFeedbackPropertiesEXT *transform_feedback;
1921bf215546Sopenharmony_ci      VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT
1922bf215546Sopenharmony_ci         *vertex_attribute_divisor;
1923bf215546Sopenharmony_ci   } u;
1924bf215546Sopenharmony_ci
1925bf215546Sopenharmony_ci   u.pnext = (VkBaseOutStructure *)pProperties;
1926bf215546Sopenharmony_ci   while (u.pnext) {
1927bf215546Sopenharmony_ci      void *saved = u.pnext->pNext;
1928bf215546Sopenharmony_ci      switch ((int32_t)u.pnext->sType) {
1929bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2:
1930bf215546Sopenharmony_ci         u.properties2->properties = props->vulkan_1_0;
1931bf215546Sopenharmony_ci         break;
1932bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES:
1933bf215546Sopenharmony_ci         *u.vulkan_1_1 = *vk11_props;
1934bf215546Sopenharmony_ci         break;
1935bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES:
1936bf215546Sopenharmony_ci         *u.vulkan_1_2 = *vk12_props;
1937bf215546Sopenharmony_ci         break;
1938bf215546Sopenharmony_ci
1939bf215546Sopenharmony_ci      /* Vulkan 1.1 */
1940bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES:
1941bf215546Sopenharmony_ci         memcpy(u.id->deviceUUID, vk11_props->deviceUUID,
1942bf215546Sopenharmony_ci                sizeof(vk11_props->deviceUUID));
1943bf215546Sopenharmony_ci         memcpy(u.id->driverUUID, vk11_props->driverUUID,
1944bf215546Sopenharmony_ci                sizeof(vk11_props->driverUUID));
1945bf215546Sopenharmony_ci         memcpy(u.id->deviceLUID, vk11_props->deviceLUID,
1946bf215546Sopenharmony_ci                sizeof(vk11_props->deviceLUID));
1947bf215546Sopenharmony_ci         u.id->deviceNodeMask = vk11_props->deviceNodeMask;
1948bf215546Sopenharmony_ci         u.id->deviceLUIDValid = vk11_props->deviceLUIDValid;
1949bf215546Sopenharmony_ci         break;
1950bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES:
1951bf215546Sopenharmony_ci         u.subgroup->subgroupSize = vk11_props->subgroupSize;
1952bf215546Sopenharmony_ci         u.subgroup->supportedStages = vk11_props->subgroupSupportedStages;
1953bf215546Sopenharmony_ci         u.subgroup->supportedOperations =
1954bf215546Sopenharmony_ci            vk11_props->subgroupSupportedOperations;
1955bf215546Sopenharmony_ci         u.subgroup->quadOperationsInAllStages =
1956bf215546Sopenharmony_ci            vk11_props->subgroupQuadOperationsInAllStages;
1957bf215546Sopenharmony_ci         break;
1958bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES:
1959bf215546Sopenharmony_ci         u.point_clipping->pointClippingBehavior =
1960bf215546Sopenharmony_ci            vk11_props->pointClippingBehavior;
1961bf215546Sopenharmony_ci         break;
1962bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES:
1963bf215546Sopenharmony_ci         u.multiview->maxMultiviewViewCount =
1964bf215546Sopenharmony_ci            vk11_props->maxMultiviewViewCount;
1965bf215546Sopenharmony_ci         u.multiview->maxMultiviewInstanceIndex =
1966bf215546Sopenharmony_ci            vk11_props->maxMultiviewInstanceIndex;
1967bf215546Sopenharmony_ci         break;
1968bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES:
1969bf215546Sopenharmony_ci         u.protected_memory->protectedNoFault = vk11_props->protectedNoFault;
1970bf215546Sopenharmony_ci         break;
1971bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES:
1972bf215546Sopenharmony_ci         u.maintenance_3->maxPerSetDescriptors =
1973bf215546Sopenharmony_ci            vk11_props->maxPerSetDescriptors;
1974bf215546Sopenharmony_ci         u.maintenance_3->maxMemoryAllocationSize =
1975bf215546Sopenharmony_ci            vk11_props->maxMemoryAllocationSize;
1976bf215546Sopenharmony_ci         break;
1977bf215546Sopenharmony_ci
1978bf215546Sopenharmony_ci      /* Vulkan 1.2 */
1979bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES:
1980bf215546Sopenharmony_ci         u.driver->driverID = vk12_props->driverID;
1981bf215546Sopenharmony_ci         memcpy(u.driver->driverName, vk12_props->driverName,
1982bf215546Sopenharmony_ci                sizeof(vk12_props->driverName));
1983bf215546Sopenharmony_ci         memcpy(u.driver->driverInfo, vk12_props->driverInfo,
1984bf215546Sopenharmony_ci                sizeof(vk12_props->driverInfo));
1985bf215546Sopenharmony_ci         u.driver->conformanceVersion = vk12_props->conformanceVersion;
1986bf215546Sopenharmony_ci         break;
1987bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES:
1988bf215546Sopenharmony_ci         u.float_controls->denormBehaviorIndependence =
1989bf215546Sopenharmony_ci            vk12_props->denormBehaviorIndependence;
1990bf215546Sopenharmony_ci         u.float_controls->roundingModeIndependence =
1991bf215546Sopenharmony_ci            vk12_props->roundingModeIndependence;
1992bf215546Sopenharmony_ci         u.float_controls->shaderSignedZeroInfNanPreserveFloat16 =
1993bf215546Sopenharmony_ci            vk12_props->shaderSignedZeroInfNanPreserveFloat16;
1994bf215546Sopenharmony_ci         u.float_controls->shaderSignedZeroInfNanPreserveFloat32 =
1995bf215546Sopenharmony_ci            vk12_props->shaderSignedZeroInfNanPreserveFloat32;
1996bf215546Sopenharmony_ci         u.float_controls->shaderSignedZeroInfNanPreserveFloat64 =
1997bf215546Sopenharmony_ci            vk12_props->shaderSignedZeroInfNanPreserveFloat64;
1998bf215546Sopenharmony_ci         u.float_controls->shaderDenormPreserveFloat16 =
1999bf215546Sopenharmony_ci            vk12_props->shaderDenormPreserveFloat16;
2000bf215546Sopenharmony_ci         u.float_controls->shaderDenormPreserveFloat32 =
2001bf215546Sopenharmony_ci            vk12_props->shaderDenormPreserveFloat32;
2002bf215546Sopenharmony_ci         u.float_controls->shaderDenormPreserveFloat64 =
2003bf215546Sopenharmony_ci            vk12_props->shaderDenormPreserveFloat64;
2004bf215546Sopenharmony_ci         u.float_controls->shaderDenormFlushToZeroFloat16 =
2005bf215546Sopenharmony_ci            vk12_props->shaderDenormFlushToZeroFloat16;
2006bf215546Sopenharmony_ci         u.float_controls->shaderDenormFlushToZeroFloat32 =
2007bf215546Sopenharmony_ci            vk12_props->shaderDenormFlushToZeroFloat32;
2008bf215546Sopenharmony_ci         u.float_controls->shaderDenormFlushToZeroFloat64 =
2009bf215546Sopenharmony_ci            vk12_props->shaderDenormFlushToZeroFloat64;
2010bf215546Sopenharmony_ci         u.float_controls->shaderRoundingModeRTEFloat16 =
2011bf215546Sopenharmony_ci            vk12_props->shaderRoundingModeRTEFloat16;
2012bf215546Sopenharmony_ci         u.float_controls->shaderRoundingModeRTEFloat32 =
2013bf215546Sopenharmony_ci            vk12_props->shaderRoundingModeRTEFloat32;
2014bf215546Sopenharmony_ci         u.float_controls->shaderRoundingModeRTEFloat64 =
2015bf215546Sopenharmony_ci            vk12_props->shaderRoundingModeRTEFloat64;
2016bf215546Sopenharmony_ci         u.float_controls->shaderRoundingModeRTZFloat16 =
2017bf215546Sopenharmony_ci            vk12_props->shaderRoundingModeRTZFloat16;
2018bf215546Sopenharmony_ci         u.float_controls->shaderRoundingModeRTZFloat32 =
2019bf215546Sopenharmony_ci            vk12_props->shaderRoundingModeRTZFloat32;
2020bf215546Sopenharmony_ci         u.float_controls->shaderRoundingModeRTZFloat64 =
2021bf215546Sopenharmony_ci            vk12_props->shaderRoundingModeRTZFloat64;
2022bf215546Sopenharmony_ci         break;
2023bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES:
2024bf215546Sopenharmony_ci         u.descriptor_indexing->maxUpdateAfterBindDescriptorsInAllPools =
2025bf215546Sopenharmony_ci            vk12_props->maxUpdateAfterBindDescriptorsInAllPools;
2026bf215546Sopenharmony_ci         u.descriptor_indexing
2027bf215546Sopenharmony_ci            ->shaderUniformBufferArrayNonUniformIndexingNative =
2028bf215546Sopenharmony_ci            vk12_props->shaderUniformBufferArrayNonUniformIndexingNative;
2029bf215546Sopenharmony_ci         u.descriptor_indexing
2030bf215546Sopenharmony_ci            ->shaderSampledImageArrayNonUniformIndexingNative =
2031bf215546Sopenharmony_ci            vk12_props->shaderSampledImageArrayNonUniformIndexingNative;
2032bf215546Sopenharmony_ci         u.descriptor_indexing
2033bf215546Sopenharmony_ci            ->shaderStorageBufferArrayNonUniformIndexingNative =
2034bf215546Sopenharmony_ci            vk12_props->shaderStorageBufferArrayNonUniformIndexingNative;
2035bf215546Sopenharmony_ci         u.descriptor_indexing
2036bf215546Sopenharmony_ci            ->shaderStorageImageArrayNonUniformIndexingNative =
2037bf215546Sopenharmony_ci            vk12_props->shaderStorageImageArrayNonUniformIndexingNative;
2038bf215546Sopenharmony_ci         u.descriptor_indexing
2039bf215546Sopenharmony_ci            ->shaderInputAttachmentArrayNonUniformIndexingNative =
2040bf215546Sopenharmony_ci            vk12_props->shaderInputAttachmentArrayNonUniformIndexingNative;
2041bf215546Sopenharmony_ci         u.descriptor_indexing->robustBufferAccessUpdateAfterBind =
2042bf215546Sopenharmony_ci            vk12_props->robustBufferAccessUpdateAfterBind;
2043bf215546Sopenharmony_ci         u.descriptor_indexing->quadDivergentImplicitLod =
2044bf215546Sopenharmony_ci            vk12_props->quadDivergentImplicitLod;
2045bf215546Sopenharmony_ci         u.descriptor_indexing->maxPerStageDescriptorUpdateAfterBindSamplers =
2046bf215546Sopenharmony_ci            vk12_props->maxPerStageDescriptorUpdateAfterBindSamplers;
2047bf215546Sopenharmony_ci         u.descriptor_indexing
2048bf215546Sopenharmony_ci            ->maxPerStageDescriptorUpdateAfterBindUniformBuffers =
2049bf215546Sopenharmony_ci            vk12_props->maxPerStageDescriptorUpdateAfterBindUniformBuffers;
2050bf215546Sopenharmony_ci         u.descriptor_indexing
2051bf215546Sopenharmony_ci            ->maxPerStageDescriptorUpdateAfterBindStorageBuffers =
2052bf215546Sopenharmony_ci            vk12_props->maxPerStageDescriptorUpdateAfterBindStorageBuffers;
2053bf215546Sopenharmony_ci         u.descriptor_indexing
2054bf215546Sopenharmony_ci            ->maxPerStageDescriptorUpdateAfterBindSampledImages =
2055bf215546Sopenharmony_ci            vk12_props->maxPerStageDescriptorUpdateAfterBindSampledImages;
2056bf215546Sopenharmony_ci         u.descriptor_indexing
2057bf215546Sopenharmony_ci            ->maxPerStageDescriptorUpdateAfterBindStorageImages =
2058bf215546Sopenharmony_ci            vk12_props->maxPerStageDescriptorUpdateAfterBindStorageImages;
2059bf215546Sopenharmony_ci         u.descriptor_indexing
2060bf215546Sopenharmony_ci            ->maxPerStageDescriptorUpdateAfterBindInputAttachments =
2061bf215546Sopenharmony_ci            vk12_props->maxPerStageDescriptorUpdateAfterBindInputAttachments;
2062bf215546Sopenharmony_ci         u.descriptor_indexing->maxPerStageUpdateAfterBindResources =
2063bf215546Sopenharmony_ci            vk12_props->maxPerStageUpdateAfterBindResources;
2064bf215546Sopenharmony_ci         u.descriptor_indexing->maxDescriptorSetUpdateAfterBindSamplers =
2065bf215546Sopenharmony_ci            vk12_props->maxDescriptorSetUpdateAfterBindSamplers;
2066bf215546Sopenharmony_ci         u.descriptor_indexing->maxDescriptorSetUpdateAfterBindUniformBuffers =
2067bf215546Sopenharmony_ci            vk12_props->maxDescriptorSetUpdateAfterBindUniformBuffers;
2068bf215546Sopenharmony_ci         u.descriptor_indexing
2069bf215546Sopenharmony_ci            ->maxDescriptorSetUpdateAfterBindUniformBuffersDynamic =
2070bf215546Sopenharmony_ci            vk12_props->maxDescriptorSetUpdateAfterBindUniformBuffersDynamic;
2071bf215546Sopenharmony_ci         u.descriptor_indexing->maxDescriptorSetUpdateAfterBindStorageBuffers =
2072bf215546Sopenharmony_ci            vk12_props->maxDescriptorSetUpdateAfterBindStorageBuffers;
2073bf215546Sopenharmony_ci         u.descriptor_indexing
2074bf215546Sopenharmony_ci            ->maxDescriptorSetUpdateAfterBindStorageBuffersDynamic =
2075bf215546Sopenharmony_ci            vk12_props->maxDescriptorSetUpdateAfterBindStorageBuffersDynamic;
2076bf215546Sopenharmony_ci         u.descriptor_indexing->maxDescriptorSetUpdateAfterBindSampledImages =
2077bf215546Sopenharmony_ci            vk12_props->maxDescriptorSetUpdateAfterBindSampledImages;
2078bf215546Sopenharmony_ci         u.descriptor_indexing->maxDescriptorSetUpdateAfterBindStorageImages =
2079bf215546Sopenharmony_ci            vk12_props->maxDescriptorSetUpdateAfterBindStorageImages;
2080bf215546Sopenharmony_ci         u.descriptor_indexing
2081bf215546Sopenharmony_ci            ->maxDescriptorSetUpdateAfterBindInputAttachments =
2082bf215546Sopenharmony_ci            vk12_props->maxDescriptorSetUpdateAfterBindInputAttachments;
2083bf215546Sopenharmony_ci         break;
2084bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES:
2085bf215546Sopenharmony_ci         u.depth_stencil_resolve->supportedDepthResolveModes =
2086bf215546Sopenharmony_ci            vk12_props->supportedDepthResolveModes;
2087bf215546Sopenharmony_ci         u.depth_stencil_resolve->supportedStencilResolveModes =
2088bf215546Sopenharmony_ci            vk12_props->supportedStencilResolveModes;
2089bf215546Sopenharmony_ci         u.depth_stencil_resolve->independentResolveNone =
2090bf215546Sopenharmony_ci            vk12_props->independentResolveNone;
2091bf215546Sopenharmony_ci         u.depth_stencil_resolve->independentResolve =
2092bf215546Sopenharmony_ci            vk12_props->independentResolve;
2093bf215546Sopenharmony_ci         break;
2094bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES:
2095bf215546Sopenharmony_ci         u.sampler_filter_minmax->filterMinmaxSingleComponentFormats =
2096bf215546Sopenharmony_ci            vk12_props->filterMinmaxSingleComponentFormats;
2097bf215546Sopenharmony_ci         u.sampler_filter_minmax->filterMinmaxImageComponentMapping =
2098bf215546Sopenharmony_ci            vk12_props->filterMinmaxImageComponentMapping;
2099bf215546Sopenharmony_ci         break;
2100bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES:
2101bf215546Sopenharmony_ci         u.timeline_semaphore->maxTimelineSemaphoreValueDifference =
2102bf215546Sopenharmony_ci            vk12_props->maxTimelineSemaphoreValueDifference;
2103bf215546Sopenharmony_ci         break;
2104bf215546Sopenharmony_ci
2105bf215546Sopenharmony_ci      /* Vulkan 1.3 */
2106bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES:
2107bf215546Sopenharmony_ci         *u.inline_uniform_block = props->inline_uniform_block;
2108bf215546Sopenharmony_ci         break;
2109bf215546Sopenharmony_ci
2110bf215546Sopenharmony_ci      /* EXT */
2111bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT:
2112bf215546Sopenharmony_ci         *u.conservative_rasterization = props->conservative_rasterization;
2113bf215546Sopenharmony_ci         break;
2114bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT:
2115bf215546Sopenharmony_ci         *u.custom_border_color = props->custom_border_color;
2116bf215546Sopenharmony_ci         break;
2117bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT:
2118bf215546Sopenharmony_ci         u.drm->hasPrimary =
2119bf215546Sopenharmony_ci            physical_dev->instance->renderer->info.drm.has_primary;
2120bf215546Sopenharmony_ci         u.drm->primaryMajor =
2121bf215546Sopenharmony_ci            physical_dev->instance->renderer->info.drm.primary_major;
2122bf215546Sopenharmony_ci         u.drm->primaryMinor =
2123bf215546Sopenharmony_ci            physical_dev->instance->renderer->info.drm.primary_minor;
2124bf215546Sopenharmony_ci         u.drm->hasRender =
2125bf215546Sopenharmony_ci            physical_dev->instance->renderer->info.drm.has_render;
2126bf215546Sopenharmony_ci         u.drm->renderMajor =
2127bf215546Sopenharmony_ci            physical_dev->instance->renderer->info.drm.render_major;
2128bf215546Sopenharmony_ci         u.drm->renderMinor =
2129bf215546Sopenharmony_ci            physical_dev->instance->renderer->info.drm.render_minor;
2130bf215546Sopenharmony_ci         break;
2131bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT:
2132bf215546Sopenharmony_ci         *u.line_rasterization = props->line_rasterization;
2133bf215546Sopenharmony_ci         break;
2134bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT:
2135bf215546Sopenharmony_ci         /* this is used by WSI */
2136bf215546Sopenharmony_ci         if (physical_dev->instance->renderer->info.pci.has_bus_info) {
2137bf215546Sopenharmony_ci            u.pci_bus_info->pciDomain =
2138bf215546Sopenharmony_ci               physical_dev->instance->renderer->info.pci.domain;
2139bf215546Sopenharmony_ci            u.pci_bus_info->pciBus =
2140bf215546Sopenharmony_ci               physical_dev->instance->renderer->info.pci.bus;
2141bf215546Sopenharmony_ci            u.pci_bus_info->pciDevice =
2142bf215546Sopenharmony_ci               physical_dev->instance->renderer->info.pci.device;
2143bf215546Sopenharmony_ci            u.pci_bus_info->pciFunction =
2144bf215546Sopenharmony_ci               physical_dev->instance->renderer->info.pci.function;
2145bf215546Sopenharmony_ci         }
2146bf215546Sopenharmony_ci         break;
2147bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID:
2148bf215546Sopenharmony_ci         u.presentation_properties->sharedImage =
2149bf215546Sopenharmony_ci            vn_android_gralloc_get_shared_present_usage() ? VK_TRUE
2150bf215546Sopenharmony_ci                                                          : VK_FALSE;
2151bf215546Sopenharmony_ci         break;
2152bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT:
2153bf215546Sopenharmony_ci         *u.provoking_vertex = props->provoking_vertex;
2154bf215546Sopenharmony_ci         break;
2155bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_PROPERTIES_EXT:
2156bf215546Sopenharmony_ci         *u.robustness_2 = props->robustness_2;
2157bf215546Sopenharmony_ci         break;
2158bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT:
2159bf215546Sopenharmony_ci         *u.transform_feedback = props->transform_feedback;
2160bf215546Sopenharmony_ci         break;
2161bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT:
2162bf215546Sopenharmony_ci         *u.vertex_attribute_divisor = props->vertex_attribute_divisor;
2163bf215546Sopenharmony_ci         break;
2164bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES:
2165bf215546Sopenharmony_ci         *u.maintenance4 = props->maintenance4;
2166bf215546Sopenharmony_ci         break;
2167bf215546Sopenharmony_ci      default:
2168bf215546Sopenharmony_ci         break;
2169bf215546Sopenharmony_ci      }
2170bf215546Sopenharmony_ci
2171bf215546Sopenharmony_ci      u.pnext->pNext = saved;
2172bf215546Sopenharmony_ci      u.pnext = u.pnext->pNext;
2173bf215546Sopenharmony_ci   }
2174bf215546Sopenharmony_ci}
2175bf215546Sopenharmony_ci
2176bf215546Sopenharmony_civoid
2177bf215546Sopenharmony_civn_GetPhysicalDeviceQueueFamilyProperties2(
2178bf215546Sopenharmony_ci   VkPhysicalDevice physicalDevice,
2179bf215546Sopenharmony_ci   uint32_t *pQueueFamilyPropertyCount,
2180bf215546Sopenharmony_ci   VkQueueFamilyProperties2 *pQueueFamilyProperties)
2181bf215546Sopenharmony_ci{
2182bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
2183bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
2184bf215546Sopenharmony_ci
2185bf215546Sopenharmony_ci   VK_OUTARRAY_MAKE_TYPED(VkQueueFamilyProperties2, out,
2186bf215546Sopenharmony_ci                          pQueueFamilyProperties, pQueueFamilyPropertyCount);
2187bf215546Sopenharmony_ci   for (uint32_t i = 0; i < physical_dev->queue_family_count; i++) {
2188bf215546Sopenharmony_ci      vk_outarray_append_typed(VkQueueFamilyProperties2, &out, props) {
2189bf215546Sopenharmony_ci         *props = physical_dev->queue_family_properties[i];
2190bf215546Sopenharmony_ci      }
2191bf215546Sopenharmony_ci   }
2192bf215546Sopenharmony_ci}
2193bf215546Sopenharmony_ci
2194bf215546Sopenharmony_civoid
2195bf215546Sopenharmony_civn_GetPhysicalDeviceMemoryProperties2(
2196bf215546Sopenharmony_ci   VkPhysicalDevice physicalDevice,
2197bf215546Sopenharmony_ci   VkPhysicalDeviceMemoryProperties2 *pMemoryProperties)
2198bf215546Sopenharmony_ci{
2199bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
2200bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
2201bf215546Sopenharmony_ci
2202bf215546Sopenharmony_ci   pMemoryProperties->memoryProperties =
2203bf215546Sopenharmony_ci      physical_dev->memory_properties.memoryProperties;
2204bf215546Sopenharmony_ci}
2205bf215546Sopenharmony_ci
2206bf215546Sopenharmony_civoid
2207bf215546Sopenharmony_civn_GetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice,
2208bf215546Sopenharmony_ci                                      VkFormat format,
2209bf215546Sopenharmony_ci                                      VkFormatProperties2 *pFormatProperties)
2210bf215546Sopenharmony_ci{
2211bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
2212bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
2213bf215546Sopenharmony_ci
2214bf215546Sopenharmony_ci   struct vn_format_properties_entry *entry = NULL;
2215bf215546Sopenharmony_ci   if (!pFormatProperties->pNext) {
2216bf215546Sopenharmony_ci      entry = vn_physical_device_get_format_properties(physical_dev, format);
2217bf215546Sopenharmony_ci      if (entry->valid) {
2218bf215546Sopenharmony_ci         pFormatProperties->formatProperties = entry->properties;
2219bf215546Sopenharmony_ci         return;
2220bf215546Sopenharmony_ci      }
2221bf215546Sopenharmony_ci   }
2222bf215546Sopenharmony_ci
2223bf215546Sopenharmony_ci   vn_call_vkGetPhysicalDeviceFormatProperties2(
2224bf215546Sopenharmony_ci      physical_dev->instance, physicalDevice, format, pFormatProperties);
2225bf215546Sopenharmony_ci
2226bf215546Sopenharmony_ci   if (entry) {
2227bf215546Sopenharmony_ci      vn_physical_device_add_format_properties(
2228bf215546Sopenharmony_ci         physical_dev, entry, &pFormatProperties->formatProperties);
2229bf215546Sopenharmony_ci   }
2230bf215546Sopenharmony_ci}
2231bf215546Sopenharmony_ci
2232bf215546Sopenharmony_cistruct vn_physical_device_image_format_info {
2233bf215546Sopenharmony_ci   VkPhysicalDeviceImageFormatInfo2 format;
2234bf215546Sopenharmony_ci   VkPhysicalDeviceExternalImageFormatInfo external;
2235bf215546Sopenharmony_ci   VkImageFormatListCreateInfo list;
2236bf215546Sopenharmony_ci   VkImageStencilUsageCreateInfo stencil_usage;
2237bf215546Sopenharmony_ci   VkPhysicalDeviceImageDrmFormatModifierInfoEXT modifier;
2238bf215546Sopenharmony_ci};
2239bf215546Sopenharmony_ci
2240bf215546Sopenharmony_cistatic const VkPhysicalDeviceImageFormatInfo2 *
2241bf215546Sopenharmony_civn_physical_device_fix_image_format_info(
2242bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev,
2243bf215546Sopenharmony_ci   const VkPhysicalDeviceImageFormatInfo2 *info,
2244bf215546Sopenharmony_ci   struct vn_physical_device_image_format_info *local_info)
2245bf215546Sopenharmony_ci{
2246bf215546Sopenharmony_ci   local_info->format = *info;
2247bf215546Sopenharmony_ci   VkBaseOutStructure *dst = (void *)&local_info->format;
2248bf215546Sopenharmony_ci
2249bf215546Sopenharmony_ci   bool is_ahb = false;
2250bf215546Sopenharmony_ci   bool has_format_list = false;
2251bf215546Sopenharmony_ci   /* we should generate deep copy functions... */
2252bf215546Sopenharmony_ci   vk_foreach_struct_const(src, info->pNext) {
2253bf215546Sopenharmony_ci      void *pnext = NULL;
2254bf215546Sopenharmony_ci      switch (src->sType) {
2255bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
2256bf215546Sopenharmony_ci         memcpy(&local_info->external, src, sizeof(local_info->external));
2257bf215546Sopenharmony_ci         is_ahb =
2258bf215546Sopenharmony_ci            local_info->external.handleType ==
2259bf215546Sopenharmony_ci            VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
2260bf215546Sopenharmony_ci         local_info->external.handleType =
2261bf215546Sopenharmony_ci            physical_dev->external_memory.renderer_handle_type;
2262bf215546Sopenharmony_ci         pnext = &local_info->external;
2263bf215546Sopenharmony_ci         break;
2264bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO:
2265bf215546Sopenharmony_ci         has_format_list = true;
2266bf215546Sopenharmony_ci         memcpy(&local_info->list, src, sizeof(local_info->list));
2267bf215546Sopenharmony_ci         pnext = &local_info->list;
2268bf215546Sopenharmony_ci         break;
2269bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO:
2270bf215546Sopenharmony_ci         memcpy(&local_info->stencil_usage, src,
2271bf215546Sopenharmony_ci                sizeof(local_info->stencil_usage));
2272bf215546Sopenharmony_ci         pnext = &local_info->stencil_usage;
2273bf215546Sopenharmony_ci         break;
2274bf215546Sopenharmony_ci      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT:
2275bf215546Sopenharmony_ci         memcpy(&local_info->modifier, src, sizeof(local_info->modifier));
2276bf215546Sopenharmony_ci         pnext = &local_info->modifier;
2277bf215546Sopenharmony_ci         break;
2278bf215546Sopenharmony_ci      default:
2279bf215546Sopenharmony_ci         break;
2280bf215546Sopenharmony_ci      }
2281bf215546Sopenharmony_ci
2282bf215546Sopenharmony_ci      if (pnext) {
2283bf215546Sopenharmony_ci         dst->pNext = pnext;
2284bf215546Sopenharmony_ci         dst = pnext;
2285bf215546Sopenharmony_ci      }
2286bf215546Sopenharmony_ci   }
2287bf215546Sopenharmony_ci
2288bf215546Sopenharmony_ci   if (is_ahb) {
2289bf215546Sopenharmony_ci      assert(local_info->format.tiling !=
2290bf215546Sopenharmony_ci             VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT);
2291bf215546Sopenharmony_ci      local_info->format.tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
2292bf215546Sopenharmony_ci      if (!vn_android_get_drm_format_modifier_info(&local_info->format,
2293bf215546Sopenharmony_ci                                                   &local_info->modifier))
2294bf215546Sopenharmony_ci         return NULL;
2295bf215546Sopenharmony_ci
2296bf215546Sopenharmony_ci      dst->pNext = (void *)&local_info->modifier;
2297bf215546Sopenharmony_ci      dst = dst->pNext;
2298bf215546Sopenharmony_ci
2299bf215546Sopenharmony_ci      if ((info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) &&
2300bf215546Sopenharmony_ci          !local_info->list.viewFormatCount) {
2301bf215546Sopenharmony_ci         /* 12.3. Images
2302bf215546Sopenharmony_ci          *
2303bf215546Sopenharmony_ci          * If tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags
2304bf215546Sopenharmony_ci          * contains VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, then the pNext chain
2305bf215546Sopenharmony_ci          * must include a VkImageFormatListCreateInfo structure with non-zero
2306bf215546Sopenharmony_ci          * viewFormatCount.
2307bf215546Sopenharmony_ci          */
2308bf215546Sopenharmony_ci         VkImageFormatListCreateInfo *list = &local_info->list;
2309bf215546Sopenharmony_ci         uint32_t vcount = 0;
2310bf215546Sopenharmony_ci         const VkFormat *vformats =
2311bf215546Sopenharmony_ci            vn_android_format_to_view_formats(info->format, &vcount);
2312bf215546Sopenharmony_ci         if (!vformats) {
2313bf215546Sopenharmony_ci            /* local_info persists through the image format query call */
2314bf215546Sopenharmony_ci            vformats = &local_info->format.format;
2315bf215546Sopenharmony_ci            vcount = 1;
2316bf215546Sopenharmony_ci         }
2317bf215546Sopenharmony_ci
2318bf215546Sopenharmony_ci         list->sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO;
2319bf215546Sopenharmony_ci         list->viewFormatCount = vcount;
2320bf215546Sopenharmony_ci         list->pViewFormats = vformats;
2321bf215546Sopenharmony_ci
2322bf215546Sopenharmony_ci         if (!has_format_list) {
2323bf215546Sopenharmony_ci            dst->pNext = (void *)list;
2324bf215546Sopenharmony_ci            dst = dst->pNext;
2325bf215546Sopenharmony_ci         }
2326bf215546Sopenharmony_ci      }
2327bf215546Sopenharmony_ci   }
2328bf215546Sopenharmony_ci
2329bf215546Sopenharmony_ci   dst->pNext = NULL;
2330bf215546Sopenharmony_ci
2331bf215546Sopenharmony_ci   return &local_info->format;
2332bf215546Sopenharmony_ci}
2333bf215546Sopenharmony_ci
2334bf215546Sopenharmony_ciVkResult
2335bf215546Sopenharmony_civn_GetPhysicalDeviceImageFormatProperties2(
2336bf215546Sopenharmony_ci   VkPhysicalDevice physicalDevice,
2337bf215546Sopenharmony_ci   const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2338bf215546Sopenharmony_ci   VkImageFormatProperties2 *pImageFormatProperties)
2339bf215546Sopenharmony_ci{
2340bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
2341bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
2342bf215546Sopenharmony_ci   const VkExternalMemoryHandleTypeFlagBits renderer_handle_type =
2343bf215546Sopenharmony_ci      physical_dev->external_memory.renderer_handle_type;
2344bf215546Sopenharmony_ci   const VkExternalMemoryHandleTypeFlags supported_handle_types =
2345bf215546Sopenharmony_ci      physical_dev->external_memory.supported_handle_types;
2346bf215546Sopenharmony_ci
2347bf215546Sopenharmony_ci   const VkPhysicalDeviceExternalImageFormatInfo *external_info =
2348bf215546Sopenharmony_ci      vk_find_struct_const(pImageFormatInfo->pNext,
2349bf215546Sopenharmony_ci                           PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO);
2350bf215546Sopenharmony_ci   if (external_info && !external_info->handleType)
2351bf215546Sopenharmony_ci      external_info = NULL;
2352bf215546Sopenharmony_ci
2353bf215546Sopenharmony_ci   struct vn_physical_device_image_format_info local_info;
2354bf215546Sopenharmony_ci   if (external_info) {
2355bf215546Sopenharmony_ci      if (!(external_info->handleType & supported_handle_types)) {
2356bf215546Sopenharmony_ci         return vn_error(physical_dev->instance,
2357bf215546Sopenharmony_ci                         VK_ERROR_FORMAT_NOT_SUPPORTED);
2358bf215546Sopenharmony_ci      }
2359bf215546Sopenharmony_ci
2360bf215546Sopenharmony_ci      if (external_info->handleType != renderer_handle_type) {
2361bf215546Sopenharmony_ci         pImageFormatInfo = vn_physical_device_fix_image_format_info(
2362bf215546Sopenharmony_ci            physical_dev, pImageFormatInfo, &local_info);
2363bf215546Sopenharmony_ci         if (!pImageFormatInfo) {
2364bf215546Sopenharmony_ci            return vn_error(physical_dev->instance,
2365bf215546Sopenharmony_ci                            VK_ERROR_FORMAT_NOT_SUPPORTED);
2366bf215546Sopenharmony_ci         }
2367bf215546Sopenharmony_ci      }
2368bf215546Sopenharmony_ci   }
2369bf215546Sopenharmony_ci
2370bf215546Sopenharmony_ci   VkResult result;
2371bf215546Sopenharmony_ci   /* TODO per-device cache */
2372bf215546Sopenharmony_ci   result = vn_call_vkGetPhysicalDeviceImageFormatProperties2(
2373bf215546Sopenharmony_ci      physical_dev->instance, physicalDevice, pImageFormatInfo,
2374bf215546Sopenharmony_ci      pImageFormatProperties);
2375bf215546Sopenharmony_ci   if (result != VK_SUCCESS || !external_info)
2376bf215546Sopenharmony_ci      return vn_result(physical_dev->instance, result);
2377bf215546Sopenharmony_ci
2378bf215546Sopenharmony_ci   if (external_info->handleType ==
2379bf215546Sopenharmony_ci       VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) {
2380bf215546Sopenharmony_ci      VkAndroidHardwareBufferUsageANDROID *ahb_usage =
2381bf215546Sopenharmony_ci         vk_find_struct(pImageFormatProperties->pNext,
2382bf215546Sopenharmony_ci                        ANDROID_HARDWARE_BUFFER_USAGE_ANDROID);
2383bf215546Sopenharmony_ci      if (ahb_usage) {
2384bf215546Sopenharmony_ci         ahb_usage->androidHardwareBufferUsage = vn_android_get_ahb_usage(
2385bf215546Sopenharmony_ci            pImageFormatInfo->usage, pImageFormatInfo->flags);
2386bf215546Sopenharmony_ci      }
2387bf215546Sopenharmony_ci
2388bf215546Sopenharmony_ci      /* AHBs with mipmap usage will ignore this property */
2389bf215546Sopenharmony_ci      pImageFormatProperties->imageFormatProperties.maxMipLevels = 1;
2390bf215546Sopenharmony_ci   }
2391bf215546Sopenharmony_ci
2392bf215546Sopenharmony_ci   VkExternalImageFormatProperties *img_props = vk_find_struct(
2393bf215546Sopenharmony_ci      pImageFormatProperties->pNext, EXTERNAL_IMAGE_FORMAT_PROPERTIES);
2394bf215546Sopenharmony_ci   if (!img_props)
2395bf215546Sopenharmony_ci      return VK_SUCCESS;
2396bf215546Sopenharmony_ci
2397bf215546Sopenharmony_ci   VkExternalMemoryProperties *mem_props =
2398bf215546Sopenharmony_ci      &img_props->externalMemoryProperties;
2399bf215546Sopenharmony_ci
2400bf215546Sopenharmony_ci   if (external_info->handleType ==
2401bf215546Sopenharmony_ci       VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) {
2402bf215546Sopenharmony_ci      /* AHB backed image requires renderer to support import bit */
2403bf215546Sopenharmony_ci      if (!(mem_props->externalMemoryFeatures &
2404bf215546Sopenharmony_ci            VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT))
2405bf215546Sopenharmony_ci         return vn_error(physical_dev->instance,
2406bf215546Sopenharmony_ci                         VK_ERROR_FORMAT_NOT_SUPPORTED);
2407bf215546Sopenharmony_ci
2408bf215546Sopenharmony_ci      mem_props->externalMemoryFeatures =
2409bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT |
2410bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
2411bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT;
2412bf215546Sopenharmony_ci      mem_props->exportFromImportedHandleTypes =
2413bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
2414bf215546Sopenharmony_ci      mem_props->compatibleHandleTypes =
2415bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
2416bf215546Sopenharmony_ci   } else {
2417bf215546Sopenharmony_ci      mem_props->compatibleHandleTypes = supported_handle_types;
2418bf215546Sopenharmony_ci      mem_props->exportFromImportedHandleTypes =
2419bf215546Sopenharmony_ci         (mem_props->exportFromImportedHandleTypes & renderer_handle_type)
2420bf215546Sopenharmony_ci            ? supported_handle_types
2421bf215546Sopenharmony_ci            : 0;
2422bf215546Sopenharmony_ci   }
2423bf215546Sopenharmony_ci
2424bf215546Sopenharmony_ci   return VK_SUCCESS;
2425bf215546Sopenharmony_ci}
2426bf215546Sopenharmony_ci
2427bf215546Sopenharmony_civoid
2428bf215546Sopenharmony_civn_GetPhysicalDeviceSparseImageFormatProperties2(
2429bf215546Sopenharmony_ci   VkPhysicalDevice physicalDevice,
2430bf215546Sopenharmony_ci   const VkPhysicalDeviceSparseImageFormatInfo2 *pFormatInfo,
2431bf215546Sopenharmony_ci   uint32_t *pPropertyCount,
2432bf215546Sopenharmony_ci   VkSparseImageFormatProperties2 *pProperties)
2433bf215546Sopenharmony_ci{
2434bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
2435bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
2436bf215546Sopenharmony_ci
2437bf215546Sopenharmony_ci   /* TODO allow sparse resource along with sync feedback
2438bf215546Sopenharmony_ci    *
2439bf215546Sopenharmony_ci    * If VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT is not supported for the given
2440bf215546Sopenharmony_ci    * arguments, pPropertyCount will be set to zero upon return, and no data
2441bf215546Sopenharmony_ci    * will be written to pProperties.
2442bf215546Sopenharmony_ci    */
2443bf215546Sopenharmony_ci   if (!VN_PERF(NO_FENCE_FEEDBACK)) {
2444bf215546Sopenharmony_ci      *pPropertyCount = 0;
2445bf215546Sopenharmony_ci      return;
2446bf215546Sopenharmony_ci   }
2447bf215546Sopenharmony_ci
2448bf215546Sopenharmony_ci   /* TODO per-device cache */
2449bf215546Sopenharmony_ci   vn_call_vkGetPhysicalDeviceSparseImageFormatProperties2(
2450bf215546Sopenharmony_ci      physical_dev->instance, physicalDevice, pFormatInfo, pPropertyCount,
2451bf215546Sopenharmony_ci      pProperties);
2452bf215546Sopenharmony_ci}
2453bf215546Sopenharmony_ci
2454bf215546Sopenharmony_civoid
2455bf215546Sopenharmony_civn_GetPhysicalDeviceExternalBufferProperties(
2456bf215546Sopenharmony_ci   VkPhysicalDevice physicalDevice,
2457bf215546Sopenharmony_ci   const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo,
2458bf215546Sopenharmony_ci   VkExternalBufferProperties *pExternalBufferProperties)
2459bf215546Sopenharmony_ci{
2460bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
2461bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
2462bf215546Sopenharmony_ci   const VkExternalMemoryHandleTypeFlagBits renderer_handle_type =
2463bf215546Sopenharmony_ci      physical_dev->external_memory.renderer_handle_type;
2464bf215546Sopenharmony_ci   const VkExternalMemoryHandleTypeFlags supported_handle_types =
2465bf215546Sopenharmony_ci      physical_dev->external_memory.supported_handle_types;
2466bf215546Sopenharmony_ci   const bool is_ahb =
2467bf215546Sopenharmony_ci      pExternalBufferInfo->handleType ==
2468bf215546Sopenharmony_ci      VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
2469bf215546Sopenharmony_ci
2470bf215546Sopenharmony_ci   VkExternalMemoryProperties *props =
2471bf215546Sopenharmony_ci      &pExternalBufferProperties->externalMemoryProperties;
2472bf215546Sopenharmony_ci   if (!(pExternalBufferInfo->handleType & supported_handle_types)) {
2473bf215546Sopenharmony_ci      props->compatibleHandleTypes = pExternalBufferInfo->handleType;
2474bf215546Sopenharmony_ci      props->exportFromImportedHandleTypes = 0;
2475bf215546Sopenharmony_ci      props->externalMemoryFeatures = 0;
2476bf215546Sopenharmony_ci      return;
2477bf215546Sopenharmony_ci   }
2478bf215546Sopenharmony_ci
2479bf215546Sopenharmony_ci   VkPhysicalDeviceExternalBufferInfo local_info;
2480bf215546Sopenharmony_ci   if (pExternalBufferInfo->handleType != renderer_handle_type) {
2481bf215546Sopenharmony_ci      local_info = *pExternalBufferInfo;
2482bf215546Sopenharmony_ci      local_info.handleType = renderer_handle_type;
2483bf215546Sopenharmony_ci      pExternalBufferInfo = &local_info;
2484bf215546Sopenharmony_ci   }
2485bf215546Sopenharmony_ci
2486bf215546Sopenharmony_ci   /* TODO per-device cache */
2487bf215546Sopenharmony_ci   vn_call_vkGetPhysicalDeviceExternalBufferProperties(
2488bf215546Sopenharmony_ci      physical_dev->instance, physicalDevice, pExternalBufferInfo,
2489bf215546Sopenharmony_ci      pExternalBufferProperties);
2490bf215546Sopenharmony_ci
2491bf215546Sopenharmony_ci   if (is_ahb) {
2492bf215546Sopenharmony_ci      props->compatibleHandleTypes =
2493bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
2494bf215546Sopenharmony_ci      /* AHB backed buffer requires renderer to support import bit while it
2495bf215546Sopenharmony_ci       * also requires the renderer to must not advertise dedicated only bit
2496bf215546Sopenharmony_ci       */
2497bf215546Sopenharmony_ci      if (!(props->externalMemoryFeatures &
2498bf215546Sopenharmony_ci            VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) ||
2499bf215546Sopenharmony_ci          (props->externalMemoryFeatures &
2500bf215546Sopenharmony_ci           VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT)) {
2501bf215546Sopenharmony_ci         props->externalMemoryFeatures = 0;
2502bf215546Sopenharmony_ci         props->exportFromImportedHandleTypes = 0;
2503bf215546Sopenharmony_ci         return;
2504bf215546Sopenharmony_ci      }
2505bf215546Sopenharmony_ci      props->externalMemoryFeatures =
2506bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
2507bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT;
2508bf215546Sopenharmony_ci      props->exportFromImportedHandleTypes =
2509bf215546Sopenharmony_ci         VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
2510bf215546Sopenharmony_ci   } else {
2511bf215546Sopenharmony_ci      props->compatibleHandleTypes = supported_handle_types;
2512bf215546Sopenharmony_ci      props->exportFromImportedHandleTypes =
2513bf215546Sopenharmony_ci         (props->exportFromImportedHandleTypes & renderer_handle_type)
2514bf215546Sopenharmony_ci            ? supported_handle_types
2515bf215546Sopenharmony_ci            : 0;
2516bf215546Sopenharmony_ci   }
2517bf215546Sopenharmony_ci}
2518bf215546Sopenharmony_ci
2519bf215546Sopenharmony_civoid
2520bf215546Sopenharmony_civn_GetPhysicalDeviceExternalFenceProperties(
2521bf215546Sopenharmony_ci   VkPhysicalDevice physicalDevice,
2522bf215546Sopenharmony_ci   const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo,
2523bf215546Sopenharmony_ci   VkExternalFenceProperties *pExternalFenceProperties)
2524bf215546Sopenharmony_ci{
2525bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
2526bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
2527bf215546Sopenharmony_ci
2528bf215546Sopenharmony_ci   if (pExternalFenceInfo->handleType &
2529bf215546Sopenharmony_ci       physical_dev->external_fence_handles) {
2530bf215546Sopenharmony_ci      pExternalFenceProperties->compatibleHandleTypes =
2531bf215546Sopenharmony_ci         physical_dev->external_fence_handles;
2532bf215546Sopenharmony_ci      pExternalFenceProperties->exportFromImportedHandleTypes =
2533bf215546Sopenharmony_ci         physical_dev->external_fence_handles;
2534bf215546Sopenharmony_ci      pExternalFenceProperties->externalFenceFeatures =
2535bf215546Sopenharmony_ci         VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT |
2536bf215546Sopenharmony_ci         VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT;
2537bf215546Sopenharmony_ci   } else {
2538bf215546Sopenharmony_ci      pExternalFenceProperties->compatibleHandleTypes = 0;
2539bf215546Sopenharmony_ci      pExternalFenceProperties->exportFromImportedHandleTypes = 0;
2540bf215546Sopenharmony_ci      pExternalFenceProperties->externalFenceFeatures = 0;
2541bf215546Sopenharmony_ci   }
2542bf215546Sopenharmony_ci}
2543bf215546Sopenharmony_ci
2544bf215546Sopenharmony_civoid
2545bf215546Sopenharmony_civn_GetPhysicalDeviceExternalSemaphoreProperties(
2546bf215546Sopenharmony_ci   VkPhysicalDevice physicalDevice,
2547bf215546Sopenharmony_ci   const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo,
2548bf215546Sopenharmony_ci   VkExternalSemaphoreProperties *pExternalSemaphoreProperties)
2549bf215546Sopenharmony_ci{
2550bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
2551bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
2552bf215546Sopenharmony_ci
2553bf215546Sopenharmony_ci   const VkSemaphoreTypeCreateInfo *type_info = vk_find_struct_const(
2554bf215546Sopenharmony_ci      pExternalSemaphoreInfo->pNext, SEMAPHORE_TYPE_CREATE_INFO);
2555bf215546Sopenharmony_ci   const VkSemaphoreType sem_type =
2556bf215546Sopenharmony_ci      type_info ? type_info->semaphoreType : VK_SEMAPHORE_TYPE_BINARY;
2557bf215546Sopenharmony_ci   const VkExternalSemaphoreHandleTypeFlags valid_handles =
2558bf215546Sopenharmony_ci      sem_type == VK_SEMAPHORE_TYPE_BINARY
2559bf215546Sopenharmony_ci         ? physical_dev->external_binary_semaphore_handles
2560bf215546Sopenharmony_ci         : physical_dev->external_timeline_semaphore_handles;
2561bf215546Sopenharmony_ci   if (pExternalSemaphoreInfo->handleType & valid_handles) {
2562bf215546Sopenharmony_ci      pExternalSemaphoreProperties->compatibleHandleTypes = valid_handles;
2563bf215546Sopenharmony_ci      pExternalSemaphoreProperties->exportFromImportedHandleTypes =
2564bf215546Sopenharmony_ci         valid_handles;
2565bf215546Sopenharmony_ci      pExternalSemaphoreProperties->externalSemaphoreFeatures =
2566bf215546Sopenharmony_ci         VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT |
2567bf215546Sopenharmony_ci         VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT;
2568bf215546Sopenharmony_ci   } else {
2569bf215546Sopenharmony_ci      pExternalSemaphoreProperties->compatibleHandleTypes = 0;
2570bf215546Sopenharmony_ci      pExternalSemaphoreProperties->exportFromImportedHandleTypes = 0;
2571bf215546Sopenharmony_ci      pExternalSemaphoreProperties->externalSemaphoreFeatures = 0;
2572bf215546Sopenharmony_ci   }
2573bf215546Sopenharmony_ci}
2574bf215546Sopenharmony_ci
2575bf215546Sopenharmony_ciVkResult
2576bf215546Sopenharmony_civn_GetPhysicalDeviceCalibrateableTimeDomainsEXT(
2577bf215546Sopenharmony_ci   VkPhysicalDevice physicalDevice,
2578bf215546Sopenharmony_ci   uint32_t *pTimeDomainCount,
2579bf215546Sopenharmony_ci   VkTimeDomainEXT *pTimeDomains)
2580bf215546Sopenharmony_ci{
2581bf215546Sopenharmony_ci   struct vn_physical_device *physical_dev =
2582bf215546Sopenharmony_ci      vn_physical_device_from_handle(physicalDevice);
2583bf215546Sopenharmony_ci
2584bf215546Sopenharmony_ci   return vn_call_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(
2585bf215546Sopenharmony_ci      physical_dev->instance, physicalDevice, pTimeDomainCount, pTimeDomains);
2586bf215546Sopenharmony_ci}
2587