1/*
2 * Copyright © 2020 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24#include "vk_device.h"
25
26#include "vk_common_entrypoints.h"
27#include "vk_instance.h"
28#include "vk_log.h"
29#include "vk_physical_device.h"
30#include "vk_queue.h"
31#include "vk_util.h"
32#include "util/hash_table.h"
33#include "util/ralloc.h"
34
35VkResult
36vk_device_init(struct vk_device *device,
37               struct vk_physical_device *physical_device,
38               const struct vk_device_dispatch_table *dispatch_table,
39               const VkDeviceCreateInfo *pCreateInfo,
40               const VkAllocationCallbacks *alloc)
41{
42   memset(device, 0, sizeof(*device));
43   vk_object_base_init(device, &device->base, VK_OBJECT_TYPE_DEVICE);
44   if (alloc != NULL)
45      device->alloc = *alloc;
46   else
47      device->alloc = physical_device->instance->alloc;
48
49   device->physical = physical_device;
50
51   device->dispatch_table = *dispatch_table;
52
53   /* Add common entrypoints without overwriting driver-provided ones. */
54   vk_device_dispatch_table_from_entrypoints(
55      &device->dispatch_table, &vk_common_device_entrypoints, false);
56
57   for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
58      int idx;
59      for (idx = 0; idx < VK_DEVICE_EXTENSION_COUNT; idx++) {
60         if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
61                    vk_device_extensions[idx].extensionName) == 0)
62            break;
63      }
64
65      if (idx >= VK_DEVICE_EXTENSION_COUNT)
66         return vk_errorf(physical_device, VK_ERROR_EXTENSION_NOT_PRESENT,
67                          "%s not supported",
68                          pCreateInfo->ppEnabledExtensionNames[i]);
69
70      if (!physical_device->supported_extensions.extensions[idx])
71         return vk_errorf(physical_device, VK_ERROR_EXTENSION_NOT_PRESENT,
72                          "%s not supported",
73                          pCreateInfo->ppEnabledExtensionNames[i]);
74
75#ifdef ANDROID
76      if (!vk_android_allowed_device_extensions.extensions[idx])
77         return vk_errorf(physical_device, VK_ERROR_EXTENSION_NOT_PRESENT,
78                          "%s not supported",
79                          pCreateInfo->ppEnabledExtensionNames[i]);
80#endif
81
82      device->enabled_extensions.extensions[idx] = true;
83   }
84
85   VkResult result =
86      vk_physical_device_check_device_features(physical_device,
87                                               pCreateInfo);
88   if (result != VK_SUCCESS)
89      return result;
90
91   p_atomic_set(&device->private_data_next_index, 0);
92
93   list_inithead(&device->queues);
94
95#ifdef ANDROID
96   mtx_init(&device->swapchain_private_mtx, mtx_plain);
97   device->swapchain_private = NULL;
98#endif /* ANDROID */
99
100   return VK_SUCCESS;
101}
102
103void
104vk_device_finish(UNUSED struct vk_device *device)
105{
106   /* Drivers should tear down their own queues */
107   assert(list_is_empty(&device->queues));
108
109#ifdef ANDROID
110   if (device->swapchain_private) {
111      hash_table_foreach(device->swapchain_private, entry)
112         util_sparse_array_finish(entry->data);
113      ralloc_free(device->swapchain_private);
114   }
115#endif /* ANDROID */
116
117   vk_object_base_finish(&device->base);
118}
119
120PFN_vkVoidFunction
121vk_device_get_proc_addr(const struct vk_device *device,
122                        const char *name)
123{
124   if (device == NULL || name == NULL)
125      return NULL;
126
127   struct vk_instance *instance = device->physical->instance;
128   return vk_device_dispatch_table_get_if_supported(&device->dispatch_table,
129                                                    name,
130                                                    instance->app_info.api_version,
131                                                    &instance->enabled_extensions,
132                                                    &device->enabled_extensions);
133}
134
135VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
136vk_common_GetDeviceProcAddr(VkDevice _device,
137                            const char *pName)
138{
139   VK_FROM_HANDLE(vk_device, device, _device);
140   return vk_device_get_proc_addr(device, pName);
141}
142
143VKAPI_ATTR void VKAPI_CALL
144vk_common_GetDeviceQueue(VkDevice _device,
145                         uint32_t queueFamilyIndex,
146                         uint32_t queueIndex,
147                         VkQueue *pQueue)
148{
149   VK_FROM_HANDLE(vk_device, device, _device);
150
151   const VkDeviceQueueInfo2 info = {
152      .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2,
153      .pNext = NULL,
154      /* flags = 0 because (Vulkan spec 1.2.170 - vkGetDeviceQueue):
155       *
156       *    "vkGetDeviceQueue must only be used to get queues that were
157       *     created with the flags parameter of VkDeviceQueueCreateInfo set
158       *     to zero. To get queues that were created with a non-zero flags
159       *     parameter use vkGetDeviceQueue2."
160       */
161      .flags = 0,
162      .queueFamilyIndex = queueFamilyIndex,
163      .queueIndex = queueIndex,
164   };
165
166   device->dispatch_table.GetDeviceQueue2(_device, &info, pQueue);
167}
168
169VKAPI_ATTR void VKAPI_CALL
170vk_common_GetDeviceQueue2(VkDevice _device,
171                          const VkDeviceQueueInfo2 *pQueueInfo,
172                          VkQueue *pQueue)
173{
174   VK_FROM_HANDLE(vk_device, device, _device);
175
176   struct vk_queue *queue = NULL;
177   vk_foreach_queue(iter, device) {
178      if (iter->queue_family_index == pQueueInfo->queueFamilyIndex &&
179          iter->index_in_family == pQueueInfo->queueIndex) {
180         queue = iter;
181         break;
182      }
183   }
184
185   /* From the Vulkan 1.1.70 spec:
186    *
187    *    "The queue returned by vkGetDeviceQueue2 must have the same flags
188    *    value from this structure as that used at device creation time in a
189    *    VkDeviceQueueCreateInfo instance. If no matching flags were specified
190    *    at device creation time then pQueue will return VK_NULL_HANDLE."
191    */
192   if (queue && queue->flags == pQueueInfo->flags)
193      *pQueue = vk_queue_to_handle(queue);
194   else
195      *pQueue = VK_NULL_HANDLE;
196}
197
198VKAPI_ATTR void VKAPI_CALL
199vk_common_GetBufferMemoryRequirements(VkDevice _device,
200                                      VkBuffer buffer,
201                                      VkMemoryRequirements *pMemoryRequirements)
202{
203   VK_FROM_HANDLE(vk_device, device, _device);
204
205   VkBufferMemoryRequirementsInfo2 info = {
206      .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2,
207      .buffer = buffer,
208   };
209   VkMemoryRequirements2 reqs = {
210      .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
211   };
212   device->dispatch_table.GetBufferMemoryRequirements2(_device, &info, &reqs);
213
214   *pMemoryRequirements = reqs.memoryRequirements;
215}
216
217VKAPI_ATTR VkResult VKAPI_CALL
218vk_common_BindBufferMemory(VkDevice _device,
219                           VkBuffer buffer,
220                           VkDeviceMemory memory,
221                           VkDeviceSize memoryOffset)
222{
223   VK_FROM_HANDLE(vk_device, device, _device);
224
225   VkBindBufferMemoryInfo bind = {
226      .sType         = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO,
227      .buffer        = buffer,
228      .memory        = memory,
229      .memoryOffset  = memoryOffset,
230   };
231
232   return device->dispatch_table.BindBufferMemory2(_device, 1, &bind);
233}
234
235VKAPI_ATTR void VKAPI_CALL
236vk_common_GetImageMemoryRequirements(VkDevice _device,
237                                     VkImage image,
238                                     VkMemoryRequirements *pMemoryRequirements)
239{
240   VK_FROM_HANDLE(vk_device, device, _device);
241
242   VkImageMemoryRequirementsInfo2 info = {
243      .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2,
244      .image = image,
245   };
246   VkMemoryRequirements2 reqs = {
247      .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
248   };
249   device->dispatch_table.GetImageMemoryRequirements2(_device, &info, &reqs);
250
251   *pMemoryRequirements = reqs.memoryRequirements;
252}
253
254VKAPI_ATTR VkResult VKAPI_CALL
255vk_common_BindImageMemory(VkDevice _device,
256                          VkImage image,
257                          VkDeviceMemory memory,
258                          VkDeviceSize memoryOffset)
259{
260   VK_FROM_HANDLE(vk_device, device, _device);
261
262   VkBindImageMemoryInfo bind = {
263      .sType         = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO,
264      .image         = image,
265      .memory        = memory,
266      .memoryOffset  = memoryOffset,
267   };
268
269   return device->dispatch_table.BindImageMemory2(_device, 1, &bind);
270}
271
272VKAPI_ATTR void VKAPI_CALL
273vk_common_GetImageSparseMemoryRequirements(VkDevice _device,
274                                           VkImage image,
275                                           uint32_t *pSparseMemoryRequirementCount,
276                                           VkSparseImageMemoryRequirements *pSparseMemoryRequirements)
277{
278   VK_FROM_HANDLE(vk_device, device, _device);
279
280   VkImageSparseMemoryRequirementsInfo2 info = {
281      .sType = VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2,
282      .image = image,
283   };
284
285   if (!pSparseMemoryRequirements) {
286      device->dispatch_table.GetImageSparseMemoryRequirements2(_device,
287                                                               &info,
288                                                               pSparseMemoryRequirementCount,
289                                                               NULL);
290      return;
291   }
292
293   STACK_ARRAY(VkSparseImageMemoryRequirements2, mem_reqs2, *pSparseMemoryRequirementCount);
294
295   for (unsigned i = 0; i < *pSparseMemoryRequirementCount; ++i) {
296      mem_reqs2[i].sType = VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2;
297      mem_reqs2[i].pNext = NULL;
298   }
299
300   device->dispatch_table.GetImageSparseMemoryRequirements2(_device,
301                                                            &info,
302                                                            pSparseMemoryRequirementCount,
303                                                            mem_reqs2);
304
305   for (unsigned i = 0; i < *pSparseMemoryRequirementCount; ++i)
306      pSparseMemoryRequirements[i] = mem_reqs2[i].memoryRequirements;
307
308   STACK_ARRAY_FINISH(mem_reqs2);
309}
310
311VKAPI_ATTR VkResult VKAPI_CALL
312vk_common_DeviceWaitIdle(VkDevice _device)
313{
314   VK_FROM_HANDLE(vk_device, device, _device);
315   const struct vk_device_dispatch_table *disp = &device->dispatch_table;
316
317   vk_foreach_queue(queue, device) {
318      VkResult result = disp->QueueWaitIdle(vk_queue_to_handle(queue));
319      if (result != VK_SUCCESS)
320         return result;
321   }
322
323   return VK_SUCCESS;
324}
325
326static void
327copy_vk_struct_guts(VkBaseOutStructure *dst, VkBaseInStructure *src, size_t struct_size)
328{
329   STATIC_ASSERT(sizeof(*dst) == sizeof(*src));
330   memcpy(dst + 1, src + 1, struct_size - sizeof(VkBaseOutStructure));
331}
332
333#define CORE_FEATURE(feature) features->feature = core->feature
334
335bool
336vk_get_physical_device_core_1_1_feature_ext(struct VkBaseOutStructure *ext,
337                                            const VkPhysicalDeviceVulkan11Features *core)
338{
339
340   switch (ext->sType) {
341   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES: {
342      VkPhysicalDevice16BitStorageFeatures *features = (void *)ext;
343      CORE_FEATURE(storageBuffer16BitAccess);
344      CORE_FEATURE(uniformAndStorageBuffer16BitAccess);
345      CORE_FEATURE(storagePushConstant16);
346      CORE_FEATURE(storageInputOutput16);
347      return true;
348   }
349
350   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES: {
351      VkPhysicalDeviceMultiviewFeatures *features = (void *)ext;
352      CORE_FEATURE(multiview);
353      CORE_FEATURE(multiviewGeometryShader);
354      CORE_FEATURE(multiviewTessellationShader);
355      return true;
356   }
357
358   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES: {
359      VkPhysicalDeviceProtectedMemoryFeatures *features = (void *)ext;
360      CORE_FEATURE(protectedMemory);
361      return true;
362   }
363
364   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES: {
365      VkPhysicalDeviceSamplerYcbcrConversionFeatures *features = (void *) ext;
366      CORE_FEATURE(samplerYcbcrConversion);
367      return true;
368   }
369
370   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES: {
371      VkPhysicalDeviceShaderDrawParametersFeatures *features = (void *)ext;
372      CORE_FEATURE(shaderDrawParameters);
373      return true;
374   }
375
376   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES: {
377      VkPhysicalDeviceVariablePointersFeatures *features = (void *)ext;
378      CORE_FEATURE(variablePointersStorageBuffer);
379      CORE_FEATURE(variablePointers);
380      return true;
381   }
382
383   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES:
384      copy_vk_struct_guts(ext, (void *)core, sizeof(*core));
385      return true;
386
387   default:
388      return false;
389   }
390}
391
392bool
393vk_get_physical_device_core_1_2_feature_ext(struct VkBaseOutStructure *ext,
394                                            const VkPhysicalDeviceVulkan12Features *core)
395{
396
397   switch (ext->sType) {
398   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR: {
399      VkPhysicalDevice8BitStorageFeaturesKHR *features = (void *)ext;
400      CORE_FEATURE(storageBuffer8BitAccess);
401      CORE_FEATURE(uniformAndStorageBuffer8BitAccess);
402      CORE_FEATURE(storagePushConstant8);
403      return true;
404   }
405
406   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR: {
407      VkPhysicalDeviceBufferDeviceAddressFeaturesKHR *features = (void *)ext;
408      CORE_FEATURE(bufferDeviceAddress);
409      CORE_FEATURE(bufferDeviceAddressCaptureReplay);
410      CORE_FEATURE(bufferDeviceAddressMultiDevice);
411      return true;
412   }
413
414   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT: {
415      VkPhysicalDeviceDescriptorIndexingFeaturesEXT *features = (void *)ext;
416      CORE_FEATURE(shaderInputAttachmentArrayDynamicIndexing);
417      CORE_FEATURE(shaderUniformTexelBufferArrayDynamicIndexing);
418      CORE_FEATURE(shaderStorageTexelBufferArrayDynamicIndexing);
419      CORE_FEATURE(shaderUniformBufferArrayNonUniformIndexing);
420      CORE_FEATURE(shaderSampledImageArrayNonUniformIndexing);
421      CORE_FEATURE(shaderStorageBufferArrayNonUniformIndexing);
422      CORE_FEATURE(shaderStorageImageArrayNonUniformIndexing);
423      CORE_FEATURE(shaderInputAttachmentArrayNonUniformIndexing);
424      CORE_FEATURE(shaderUniformTexelBufferArrayNonUniformIndexing);
425      CORE_FEATURE(shaderStorageTexelBufferArrayNonUniformIndexing);
426      CORE_FEATURE(descriptorBindingUniformBufferUpdateAfterBind);
427      CORE_FEATURE(descriptorBindingSampledImageUpdateAfterBind);
428      CORE_FEATURE(descriptorBindingStorageImageUpdateAfterBind);
429      CORE_FEATURE(descriptorBindingStorageBufferUpdateAfterBind);
430      CORE_FEATURE(descriptorBindingUniformTexelBufferUpdateAfterBind);
431      CORE_FEATURE(descriptorBindingStorageTexelBufferUpdateAfterBind);
432      CORE_FEATURE(descriptorBindingUpdateUnusedWhilePending);
433      CORE_FEATURE(descriptorBindingPartiallyBound);
434      CORE_FEATURE(descriptorBindingVariableDescriptorCount);
435      CORE_FEATURE(runtimeDescriptorArray);
436      return true;
437   }
438
439   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR: {
440      VkPhysicalDeviceFloat16Int8FeaturesKHR *features = (void *)ext;
441      CORE_FEATURE(shaderFloat16);
442      CORE_FEATURE(shaderInt8);
443      return true;
444   }
445
446   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES_EXT: {
447      VkPhysicalDeviceHostQueryResetFeaturesEXT *features = (void *)ext;
448      CORE_FEATURE(hostQueryReset);
449      return true;
450   }
451
452   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES_KHR: {
453      VkPhysicalDeviceImagelessFramebufferFeaturesKHR *features = (void *)ext;
454      CORE_FEATURE(imagelessFramebuffer);
455      return true;
456   }
457
458   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT: {
459      VkPhysicalDeviceScalarBlockLayoutFeaturesEXT *features =(void *)ext;
460      CORE_FEATURE(scalarBlockLayout);
461      return true;
462   }
463
464   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR: {
465      VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *features = (void *)ext;
466      CORE_FEATURE(separateDepthStencilLayouts);
467      return true;
468   }
469
470   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR: {
471      VkPhysicalDeviceShaderAtomicInt64FeaturesKHR *features = (void *)ext;
472      CORE_FEATURE(shaderBufferInt64Atomics);
473      CORE_FEATURE(shaderSharedInt64Atomics);
474      return true;
475   }
476
477   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR: {
478      VkPhysicalDeviceShaderSubgroupExtendedTypesFeaturesKHR *features = (void *)ext;
479      CORE_FEATURE(shaderSubgroupExtendedTypes);
480      return true;
481   }
482
483   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR: {
484      VkPhysicalDeviceTimelineSemaphoreFeaturesKHR *features = (void *) ext;
485      CORE_FEATURE(timelineSemaphore);
486      return true;
487   }
488
489   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES_KHR: {
490      VkPhysicalDeviceUniformBufferStandardLayoutFeaturesKHR *features = (void *)ext;
491      CORE_FEATURE(uniformBufferStandardLayout);
492      return true;
493   }
494
495   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR: {
496      VkPhysicalDeviceVulkanMemoryModelFeaturesKHR *features = (void *)ext;
497      CORE_FEATURE(vulkanMemoryModel);
498      CORE_FEATURE(vulkanMemoryModelDeviceScope);
499      CORE_FEATURE(vulkanMemoryModelAvailabilityVisibilityChains);
500      return true;
501   }
502
503   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES:
504      copy_vk_struct_guts(ext, (void *)core, sizeof(*core));
505      return true;
506
507   default:
508      return false;
509   }
510}
511
512#undef CORE_FEATURE
513
514#define CORE_RENAMED_PROPERTY(ext_property, core_property) \
515   memcpy(&properties->ext_property, &core->core_property, sizeof(core->core_property))
516
517#define CORE_PROPERTY(property) CORE_RENAMED_PROPERTY(property, property)
518
519bool
520vk_get_physical_device_core_1_1_property_ext(struct VkBaseOutStructure *ext,
521                                             const VkPhysicalDeviceVulkan11Properties *core)
522{
523   switch (ext->sType) {
524   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES: {
525      VkPhysicalDeviceIDProperties *properties = (void *)ext;
526      CORE_PROPERTY(deviceUUID);
527      CORE_PROPERTY(driverUUID);
528      CORE_PROPERTY(deviceLUID);
529      CORE_PROPERTY(deviceLUIDValid);
530      return true;
531   }
532
533   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES: {
534      VkPhysicalDeviceMaintenance3Properties *properties = (void *)ext;
535      CORE_PROPERTY(maxPerSetDescriptors);
536      CORE_PROPERTY(maxMemoryAllocationSize);
537      return true;
538   }
539
540   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES: {
541      VkPhysicalDeviceMultiviewProperties *properties = (void *)ext;
542      CORE_PROPERTY(maxMultiviewViewCount);
543      CORE_PROPERTY(maxMultiviewInstanceIndex);
544      return true;
545   }
546
547   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES: {
548      VkPhysicalDevicePointClippingProperties *properties = (void *) ext;
549      CORE_PROPERTY(pointClippingBehavior);
550      return true;
551   }
552
553   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES: {
554      VkPhysicalDeviceProtectedMemoryProperties *properties = (void *)ext;
555      CORE_PROPERTY(protectedNoFault);
556      return true;
557   }
558
559   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES: {
560      VkPhysicalDeviceSubgroupProperties *properties = (void *)ext;
561      CORE_PROPERTY(subgroupSize);
562      CORE_RENAMED_PROPERTY(supportedStages,
563                                    subgroupSupportedStages);
564      CORE_RENAMED_PROPERTY(supportedOperations,
565                                    subgroupSupportedOperations);
566      CORE_RENAMED_PROPERTY(quadOperationsInAllStages,
567                                    subgroupQuadOperationsInAllStages);
568      return true;
569   }
570
571   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES:
572      copy_vk_struct_guts(ext, (void *)core, sizeof(*core));
573      return true;
574
575   default:
576      return false;
577   }
578}
579
580bool
581vk_get_physical_device_core_1_2_property_ext(struct VkBaseOutStructure *ext,
582                                             const VkPhysicalDeviceVulkan12Properties *core)
583{
584   switch (ext->sType) {
585   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR: {
586      VkPhysicalDeviceDepthStencilResolvePropertiesKHR *properties = (void *)ext;
587      CORE_PROPERTY(supportedDepthResolveModes);
588      CORE_PROPERTY(supportedStencilResolveModes);
589      CORE_PROPERTY(independentResolveNone);
590      CORE_PROPERTY(independentResolve);
591      return true;
592   }
593
594   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT: {
595      VkPhysicalDeviceDescriptorIndexingPropertiesEXT *properties = (void *)ext;
596      CORE_PROPERTY(maxUpdateAfterBindDescriptorsInAllPools);
597      CORE_PROPERTY(shaderUniformBufferArrayNonUniformIndexingNative);
598      CORE_PROPERTY(shaderSampledImageArrayNonUniformIndexingNative);
599      CORE_PROPERTY(shaderStorageBufferArrayNonUniformIndexingNative);
600      CORE_PROPERTY(shaderStorageImageArrayNonUniformIndexingNative);
601      CORE_PROPERTY(shaderInputAttachmentArrayNonUniformIndexingNative);
602      CORE_PROPERTY(robustBufferAccessUpdateAfterBind);
603      CORE_PROPERTY(quadDivergentImplicitLod);
604      CORE_PROPERTY(maxPerStageDescriptorUpdateAfterBindSamplers);
605      CORE_PROPERTY(maxPerStageDescriptorUpdateAfterBindUniformBuffers);
606      CORE_PROPERTY(maxPerStageDescriptorUpdateAfterBindStorageBuffers);
607      CORE_PROPERTY(maxPerStageDescriptorUpdateAfterBindSampledImages);
608      CORE_PROPERTY(maxPerStageDescriptorUpdateAfterBindStorageImages);
609      CORE_PROPERTY(maxPerStageDescriptorUpdateAfterBindInputAttachments);
610      CORE_PROPERTY(maxPerStageUpdateAfterBindResources);
611      CORE_PROPERTY(maxDescriptorSetUpdateAfterBindSamplers);
612      CORE_PROPERTY(maxDescriptorSetUpdateAfterBindUniformBuffers);
613      CORE_PROPERTY(maxDescriptorSetUpdateAfterBindUniformBuffersDynamic);
614      CORE_PROPERTY(maxDescriptorSetUpdateAfterBindStorageBuffers);
615      CORE_PROPERTY(maxDescriptorSetUpdateAfterBindStorageBuffersDynamic);
616      CORE_PROPERTY(maxDescriptorSetUpdateAfterBindSampledImages);
617      CORE_PROPERTY(maxDescriptorSetUpdateAfterBindStorageImages);
618      CORE_PROPERTY(maxDescriptorSetUpdateAfterBindInputAttachments);
619      return true;
620   }
621
622   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR: {
623      VkPhysicalDeviceDriverPropertiesKHR *properties = (void *) ext;
624      CORE_PROPERTY(driverID);
625      CORE_PROPERTY(driverName);
626      CORE_PROPERTY(driverInfo);
627      CORE_PROPERTY(conformanceVersion);
628      return true;
629   }
630
631   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT: {
632      VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *properties = (void *)ext;
633      CORE_PROPERTY(filterMinmaxImageComponentMapping);
634      CORE_PROPERTY(filterMinmaxSingleComponentFormats);
635      return true;
636   }
637
638   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR : {
639      VkPhysicalDeviceFloatControlsPropertiesKHR *properties = (void *)ext;
640      CORE_PROPERTY(denormBehaviorIndependence);
641      CORE_PROPERTY(roundingModeIndependence);
642      CORE_PROPERTY(shaderDenormFlushToZeroFloat16);
643      CORE_PROPERTY(shaderDenormPreserveFloat16);
644      CORE_PROPERTY(shaderRoundingModeRTEFloat16);
645      CORE_PROPERTY(shaderRoundingModeRTZFloat16);
646      CORE_PROPERTY(shaderSignedZeroInfNanPreserveFloat16);
647      CORE_PROPERTY(shaderDenormFlushToZeroFloat32);
648      CORE_PROPERTY(shaderDenormPreserveFloat32);
649      CORE_PROPERTY(shaderRoundingModeRTEFloat32);
650      CORE_PROPERTY(shaderRoundingModeRTZFloat32);
651      CORE_PROPERTY(shaderSignedZeroInfNanPreserveFloat32);
652      CORE_PROPERTY(shaderDenormFlushToZeroFloat64);
653      CORE_PROPERTY(shaderDenormPreserveFloat64);
654      CORE_PROPERTY(shaderRoundingModeRTEFloat64);
655      CORE_PROPERTY(shaderRoundingModeRTZFloat64);
656      CORE_PROPERTY(shaderSignedZeroInfNanPreserveFloat64);
657      return true;
658   }
659
660   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES_KHR: {
661      VkPhysicalDeviceTimelineSemaphorePropertiesKHR *properties = (void *) ext;
662      CORE_PROPERTY(maxTimelineSemaphoreValueDifference);
663      return true;
664   }
665
666   case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES:
667      copy_vk_struct_guts(ext, (void *)core, sizeof(*core));
668      return true;
669
670   default:
671      return false;
672   }
673}
674
675#undef CORE_RENAMED_PROPERTY
676#undef CORE_PROPERTY
677
678