3 * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
25 #include "gstvkphysicaldevice.h"
27 #include "gstvkdebug.h"
32 * SECTION:vkphysicaldevice
33 * @title: GstVulkanPhysicalDevice
34 * @short_description: Vulkan physical device
35 * @see_also: #GstVulkanInstance, #GstVulkanDevice
37 * A #GstVulkanPhysicalDevice encapsulates a VkPhysicalDevice
40 #define GST_CAT_DEFAULT gst_vulkan_physical_device_debug
41 GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
51 static void gst_vulkan_physical_device_finalize (GObject * object);
53 struct _GstVulkanPhysicalDevicePrivate
55 guint32 n_available_layers;
56 VkLayerProperties *available_layers;
58 guint32 n_available_extensions;
59 VkExtensionProperties *available_extensions;
61 #if defined (VK_API_VERSION_1_2)
62 VkPhysicalDeviceFeatures2 features10;
63 VkPhysicalDeviceProperties2 properties10;
64 VkPhysicalDeviceVulkan11Features features11;
65 VkPhysicalDeviceVulkan11Properties properties11;
66 VkPhysicalDeviceVulkan12Features features12;
67 VkPhysicalDeviceVulkan12Properties properties12;
76 if (g_once_init_enter (&init)) {
77 GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "vulkandevice", 0,
79 g_once_init_leave (&init, 1);
83 #define GET_PRIV(device) gst_vulkan_physical_device_get_instance_private (device)
85 #define gst_vulkan_physical_device_parent_class parent_class
86 G_DEFINE_TYPE_WITH_CODE (GstVulkanPhysicalDevice, gst_vulkan_physical_device,
87 GST_TYPE_OBJECT, G_ADD_PRIVATE (GstVulkanPhysicalDevice);
90 static gboolean gst_vulkan_physical_device_fill_info (GstVulkanPhysicalDevice *
91 device, GError ** error);
94 * gst_vulkan_physical_device_new:
95 * @instance: the parent #GstVulkanInstance
97 * Returns: (transfer full): a new #GstVulkanPhysicalDevice
101 GstVulkanPhysicalDevice *
102 gst_vulkan_physical_device_new (GstVulkanInstance * instance,
105 GstVulkanPhysicalDevice *device;
107 g_return_val_if_fail (GST_IS_VULKAN_INSTANCE (instance), NULL);
109 device = g_object_new (GST_TYPE_VULKAN_PHYSICAL_DEVICE, "instance", instance,
110 "device-index", device_index, NULL);
111 gst_object_ref_sink (device);
117 gst_vulkan_physical_device_set_property (GObject * object, guint prop_id,
118 const GValue * value, GParamSpec * pspec)
120 GstVulkanPhysicalDevice *device = GST_VULKAN_PHYSICAL_DEVICE (object);
124 device->instance = g_value_dup_object (value);
126 case PROP_DEVICE_ID:{
127 guint device_id = g_value_get_uint (value);
128 if (device->instance == VK_NULL_HANDLE
129 || device_id >= device->instance->n_physical_devices) {
130 g_critical ("%s: Cannot set device-index larger than the "
131 "number of physical devices", GST_OBJECT_NAME (device));
133 device->device_index = device_id;
138 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
144 gst_vulkan_physical_device_get_property (GObject * object, guint prop_id,
145 GValue * value, GParamSpec * pspec)
147 GstVulkanPhysicalDevice *device = GST_VULKAN_PHYSICAL_DEVICE (object);
151 g_value_set_object (value, device->instance);
154 g_value_set_uint (value, device->device_index);
157 g_value_set_string (value, device->properties.deviceName);
160 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
166 gst_vulkan_physical_device_init (GstVulkanPhysicalDevice * device)
168 GstVulkanPhysicalDevicePrivate *priv = GET_PRIV (device);
170 priv->n_available_layers = 0;
171 priv->n_available_extensions = 0;
173 #if defined (VK_API_VERSION_1_2)
174 priv->properties10.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
175 priv->properties11.sType =
176 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES;
177 priv->properties12.sType =
178 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES;
179 priv->properties10.pNext = &priv->properties11;
180 priv->properties11.pNext = &priv->properties12;
182 priv->features10.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
183 priv->features11.sType =
184 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
185 priv->features12.sType =
186 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
187 priv->features10.pNext = &priv->features11;
188 priv->features11.pNext = &priv->features12;
193 gst_vulkan_physical_device_constructed (GObject * object)
195 GstVulkanPhysicalDevice *device = GST_VULKAN_PHYSICAL_DEVICE (object);
196 GError *error = NULL;
198 if (device->instance == VK_NULL_HANDLE) {
199 GST_ERROR_OBJECT (object, "Constructed without any instance set");
203 device->device = device->instance->physical_devices[device->device_index];
205 if (!gst_vulkan_physical_device_fill_info (device, &error)) {
206 GST_ERROR_OBJECT (object, "%s", error->message);
207 g_clear_error (&error);
212 gst_vulkan_physical_device_class_init (GstVulkanPhysicalDeviceClass *
215 GObjectClass *gobject_class = (GObjectClass *) device_class;
217 gobject_class->set_property = gst_vulkan_physical_device_set_property;
218 gobject_class->get_property = gst_vulkan_physical_device_get_property;
219 gobject_class->finalize = gst_vulkan_physical_device_finalize;
220 gobject_class->constructed = gst_vulkan_physical_device_constructed;
222 g_object_class_install_property (gobject_class, PROP_INSTANCE,
223 g_param_spec_object ("instance", "Instance",
224 "Associated Vulkan Instance",
225 GST_TYPE_VULKAN_INSTANCE,
226 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
228 g_object_class_install_property (gobject_class, PROP_DEVICE_ID,
229 g_param_spec_uint ("device-index", "Device Index", "Device Index", 0,
231 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
233 g_object_class_install_property (gobject_class, PROP_NAME,
234 g_param_spec_string ("name", "Name", "Device Name", NULL,
235 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
239 gst_vulkan_physical_device_finalize (GObject * object)
241 GstVulkanPhysicalDevice *device = GST_VULKAN_PHYSICAL_DEVICE (object);
242 GstVulkanPhysicalDevicePrivate *priv = GET_PRIV (device);
244 g_free (priv->available_layers);
245 priv->available_layers = NULL;
247 g_free (priv->available_extensions);
248 priv->available_extensions = NULL;
250 g_free (device->queue_family_props);
251 device->queue_family_props = NULL;
253 if (device->instance)
254 gst_object_unref (device->instance);
255 device->instance = VK_NULL_HANDLE;
257 G_OBJECT_CLASS (parent_class)->finalize (object);
260 #define DEBUG_BOOL(prefix, name, value) \
261 GST_DEBUG_OBJECT (device, prefix " " G_STRINGIFY(name) ": %s", \
262 value ? "YES" : "NO")
263 #define DEBUG_1(prefix, s, name, format, type) \
264 GST_DEBUG_OBJECT (device, prefix " " G_STRINGIFY(name) ": %" format, \
266 #define DEBUG_2(prefix, s, name, format, type) \
267 GST_DEBUG_OBJECT (device, prefix " " G_STRINGIFY(name) \
268 ": %" format ", %" format, \
269 (type) (s)->name[0], \
271 #define DEBUG_3(prefix, s, name, format, type) \
272 GST_DEBUG_OBJECT (device, prefix " " G_STRINGIFY(limit) \
273 ": %" format ", %" format ", %" format, \
274 (type) (s)->name[0], \
275 (type) (s)->name[1], \
278 #define DEBUG_UINT32(prefix, s, var) DEBUG_1(prefix, s, var, G_GUINT32_FORMAT, guint32)
279 #define DEBUG_UINT32_2(prefix, s, var) DEBUG_2(prefix, s, var, G_GUINT32_FORMAT, guint32)
280 #define DEBUG_UINT32_3(prefix, s, var) DEBUG_3(prefix, s, var, G_GUINT32_FORMAT, guint32)
282 #define DEBUG_UINT64(prefix, s, var) DEBUG_1(prefix, s, var, G_GUINT64_FORMAT, guint64)
284 #define DEBUG_INT32(prefix, s, var) DEBUG_1(prefix, s, var, G_GINT32_FORMAT, gint32)
286 #define DEBUG_FLOAT(prefix, s, var) DEBUG_1(prefix, s, var, "f", gfloat)
287 #define DEBUG_FLOAT_2(prefix, s, var) DEBUG_2(prefix, s, var, "f", gfloat)
289 #define DEBUG_SIZE(prefix, s, var) DEBUG_1(prefix, s, var, G_GSIZE_FORMAT, gsize)
290 #define DEBUG_FLAGS(prefix, s, limit, under_name_type) \
292 gchar *str = G_PASTE(G_PASTE(gst_vulkan_,under_name_type),_flags_to_string) ((s)->limit); \
293 GST_DEBUG_OBJECT (device, prefix " " G_STRINGIFY(limit) ": (0x%x) %s", \
298 #define DEBUG_BOOL_STRUCT(prefix, s, name) DEBUG_BOOL(prefix, name, (s)->name)
300 #define DEBUG_STRING(prefix, s, str) DEBUG_1(prefix, s, str, "s", gchar *);
303 dump_features10 (GstVulkanPhysicalDevice * device,
304 VkPhysicalDeviceFeatures * features)
307 DEBUG_BOOL_STRUCT ("support for", features, robustBufferAccess);
308 DEBUG_BOOL_STRUCT ("support for", features, fullDrawIndexUint32);
309 DEBUG_BOOL_STRUCT ("support for", features, imageCubeArray);
310 DEBUG_BOOL_STRUCT ("support for", features, independentBlend);
311 DEBUG_BOOL_STRUCT ("support for", features, geometryShader);
312 DEBUG_BOOL_STRUCT ("support for", features, tessellationShader);
313 DEBUG_BOOL_STRUCT ("support for", features, sampleRateShading);
314 DEBUG_BOOL_STRUCT ("support for", features, sampleRateShading);
315 DEBUG_BOOL_STRUCT ("support for", features, dualSrcBlend);
316 DEBUG_BOOL_STRUCT ("support for", features, logicOp);
317 DEBUG_BOOL_STRUCT ("support for", features, multiDrawIndirect);
318 DEBUG_BOOL_STRUCT ("support for", features, drawIndirectFirstInstance);
319 DEBUG_BOOL_STRUCT ("support for", features, depthClamp);
320 DEBUG_BOOL_STRUCT ("support for", features, depthBiasClamp);
321 DEBUG_BOOL_STRUCT ("support for", features, fillModeNonSolid);
322 DEBUG_BOOL_STRUCT ("support for", features, depthBounds);
323 DEBUG_BOOL_STRUCT ("support for", features, wideLines);
324 DEBUG_BOOL_STRUCT ("support for", features, largePoints);
325 DEBUG_BOOL_STRUCT ("support for", features, alphaToOne);
326 DEBUG_BOOL_STRUCT ("support for", features, multiViewport);
327 DEBUG_BOOL_STRUCT ("support for", features, samplerAnisotropy);
328 DEBUG_BOOL_STRUCT ("support for", features, textureCompressionETC2);
329 DEBUG_BOOL_STRUCT ("support for", features, textureCompressionASTC_LDR);
330 DEBUG_BOOL_STRUCT ("support for", features, textureCompressionBC);
331 DEBUG_BOOL_STRUCT ("support for", features, occlusionQueryPrecise);
332 DEBUG_BOOL_STRUCT ("support for", features, pipelineStatisticsQuery);
333 DEBUG_BOOL_STRUCT ("support for", features, vertexPipelineStoresAndAtomics);
334 DEBUG_BOOL_STRUCT ("support for", features, fragmentStoresAndAtomics);
335 DEBUG_BOOL_STRUCT ("support for", features, shaderTessellationAndGeometryPointSize);
336 DEBUG_BOOL_STRUCT ("support for", features, shaderImageGatherExtended);
337 DEBUG_BOOL_STRUCT ("support for", features, shaderStorageImageExtendedFormats);
338 DEBUG_BOOL_STRUCT ("support for", features, shaderStorageImageMultisample);
339 DEBUG_BOOL_STRUCT ("support for", features, shaderStorageImageReadWithoutFormat);
340 DEBUG_BOOL_STRUCT ("support for", features, shaderStorageImageWriteWithoutFormat);
341 DEBUG_BOOL_STRUCT ("support for", features, shaderUniformBufferArrayDynamicIndexing);
342 DEBUG_BOOL_STRUCT ("support for", features, shaderSampledImageArrayDynamicIndexing);
343 DEBUG_BOOL_STRUCT ("support for", features, shaderStorageBufferArrayDynamicIndexing);
344 DEBUG_BOOL_STRUCT ("support for", features, shaderStorageImageArrayDynamicIndexing);
345 DEBUG_BOOL_STRUCT ("support for", features, shaderClipDistance);
346 DEBUG_BOOL_STRUCT ("support for", features, shaderCullDistance);
347 DEBUG_BOOL_STRUCT ("support for", features, shaderFloat64);
348 DEBUG_BOOL_STRUCT ("support for", features, shaderInt64);
349 DEBUG_BOOL_STRUCT ("support for", features, shaderInt16);
350 DEBUG_BOOL_STRUCT ("support for", features, shaderResourceResidency);
351 DEBUG_BOOL_STRUCT ("support for", features, shaderResourceMinLod);
352 DEBUG_BOOL_STRUCT ("support for", features, sparseBinding);
353 DEBUG_BOOL_STRUCT ("support for", features, sparseResidencyBuffer);
354 DEBUG_BOOL_STRUCT ("support for", features, sparseResidencyImage2D);
355 DEBUG_BOOL_STRUCT ("support for", features, sparseResidencyImage3D);
356 DEBUG_BOOL_STRUCT ("support for", features, sparseResidency2Samples);
357 DEBUG_BOOL_STRUCT ("support for", features, sparseResidency4Samples);
358 DEBUG_BOOL_STRUCT ("support for", features, sparseResidency8Samples);
359 DEBUG_BOOL_STRUCT ("support for", features, sparseResidency16Samples);
360 DEBUG_BOOL_STRUCT ("support for", features, sparseResidencyAliased);
361 DEBUG_BOOL_STRUCT ("support for", features, variableMultisampleRate);
362 DEBUG_BOOL_STRUCT ("support for", features, inheritedQueries);
366 #if defined (VK_API_VERSION_1_2)
368 dump_features11 (GstVulkanPhysicalDevice * device,
369 VkPhysicalDeviceVulkan11Features * features)
372 DEBUG_BOOL_STRUCT ("support for (1.1)", features, storageBuffer16BitAccess);
373 DEBUG_BOOL_STRUCT ("support for (1.1)", features, uniformAndStorageBuffer16BitAccess);
374 DEBUG_BOOL_STRUCT ("support for (1.1)", features, storagePushConstant16);
375 DEBUG_BOOL_STRUCT ("support for (1.1)", features, storageInputOutput16);
376 DEBUG_BOOL_STRUCT ("support for (1.1)", features, multiview);
377 DEBUG_BOOL_STRUCT ("support for (1.1)", features, multiviewGeometryShader);
378 DEBUG_BOOL_STRUCT ("support for (1.1)", features, multiviewTessellationShader);
379 DEBUG_BOOL_STRUCT ("support for (1.1)", features, variablePointersStorageBuffer);
380 DEBUG_BOOL_STRUCT ("support for (1.1)", features, variablePointers);
381 DEBUG_BOOL_STRUCT ("support for (1.1)", features, protectedMemory);
382 DEBUG_BOOL_STRUCT ("support for (1.1)", features, samplerYcbcrConversion);
383 DEBUG_BOOL_STRUCT ("support for (1.1)", features, shaderDrawParameters);
388 dump_features12 (GstVulkanPhysicalDevice * device,
389 VkPhysicalDeviceVulkan12Features * features)
392 DEBUG_BOOL_STRUCT ("support for (1.2)", features, samplerMirrorClampToEdge);
393 DEBUG_BOOL_STRUCT ("support for (1.2)", features, drawIndirectCount);
394 DEBUG_BOOL_STRUCT ("support for (1.2)", features, storageBuffer8BitAccess);
395 DEBUG_BOOL_STRUCT ("support for (1.2)", features, uniformAndStorageBuffer8BitAccess);
396 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderBufferInt64Atomics);
397 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderSharedInt64Atomics);
398 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderFloat16);
399 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderInt8);
400 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorIndexing);
401 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderInputAttachmentArrayDynamicIndexing);
402 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderUniformTexelBufferArrayDynamicIndexing);
403 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderStorageTexelBufferArrayDynamicIndexing);
404 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderUniformBufferArrayNonUniformIndexing);
405 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderSampledImageArrayNonUniformIndexing);
406 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderStorageBufferArrayNonUniformIndexing);
407 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderStorageImageArrayNonUniformIndexing);
408 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderInputAttachmentArrayNonUniformIndexing);
409 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderUniformTexelBufferArrayNonUniformIndexing);
410 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorBindingUniformBufferUpdateAfterBind);
411 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorBindingSampledImageUpdateAfterBind);
412 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorBindingStorageImageUpdateAfterBind);
413 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorBindingStorageBufferUpdateAfterBind);
414 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorBindingUniformTexelBufferUpdateAfterBind);
415 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorBindingStorageTexelBufferUpdateAfterBind);
416 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorBindingUpdateUnusedWhilePending);
417 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorBindingPartiallyBound);
418 DEBUG_BOOL_STRUCT ("support for (1.2)", features, descriptorBindingVariableDescriptorCount);
419 DEBUG_BOOL_STRUCT ("support for (1.2)", features, runtimeDescriptorArray);
420 DEBUG_BOOL_STRUCT ("support for (1.2)", features, samplerFilterMinmax);
421 DEBUG_BOOL_STRUCT ("support for (1.2)", features, scalarBlockLayout);
422 DEBUG_BOOL_STRUCT ("support for (1.2)", features, imagelessFramebuffer);
423 DEBUG_BOOL_STRUCT ("support for (1.2)", features, uniformBufferStandardLayout);
424 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderSubgroupExtendedTypes);
425 DEBUG_BOOL_STRUCT ("support for (1.2)", features, separateDepthStencilLayouts);
426 DEBUG_BOOL_STRUCT ("support for (1.2)", features, hostQueryReset);
427 DEBUG_BOOL_STRUCT ("support for (1.2)", features, timelineSemaphore);
428 DEBUG_BOOL_STRUCT ("support for (1.2)", features, bufferDeviceAddress);
429 DEBUG_BOOL_STRUCT ("support for (1.2)", features, bufferDeviceAddressCaptureReplay);
430 DEBUG_BOOL_STRUCT ("support for (1.2)", features, bufferDeviceAddressMultiDevice);
431 DEBUG_BOOL_STRUCT ("support for (1.2)", features, vulkanMemoryModel);
432 DEBUG_BOOL_STRUCT ("support for (1.2)", features, vulkanMemoryModelDeviceScope);
433 DEBUG_BOOL_STRUCT ("support for (1.2)", features, vulkanMemoryModelAvailabilityVisibilityChains);
434 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderOutputViewportIndex);
435 DEBUG_BOOL_STRUCT ("support for (1.2)", features, shaderOutputLayer);
436 DEBUG_BOOL_STRUCT ("support for (1.2)", features, subgroupBroadcastDynamicId);
441 dump_features (GstVulkanPhysicalDevice * device, GError ** error)
443 #if defined (VK_API_VERSION_1_2)
444 GstVulkanPhysicalDevicePrivate *priv = GET_PRIV (device);
445 VkBaseOutStructure *iter;
447 if (gst_vulkan_instance_check_version (device->instance, 1, 2, 0)) {
448 for (iter = (VkBaseOutStructure *) & priv->features10; iter;
449 iter = iter->pNext) {
450 if (iter->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2)
451 dump_features10 (device,
452 &((VkPhysicalDeviceFeatures2 *) iter)->features);
453 else if (iter->sType ==
454 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES)
455 dump_features11 (device, (VkPhysicalDeviceVulkan11Features *) iter);
456 else if (iter->sType ==
457 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES)
458 dump_features12 (device, (VkPhysicalDeviceVulkan12Features *) iter);
463 dump_features10 (device, &device->features);
470 dump_memory_properties (GstVulkanPhysicalDevice * device, GError ** error)
474 GST_DEBUG_OBJECT (device, "found %" G_GUINT32_FORMAT " memory heaps",
475 device->memory_properties.memoryHeapCount);
476 for (i = 0; i < device->memory_properties.memoryHeapCount; i++) {
477 gchar *prop_flags_str =
478 gst_vulkan_memory_heap_flags_to_string (device->
479 memory_properties.memoryHeaps[i].flags);
480 GST_LOG_OBJECT (device,
481 "memory heap at index %i has size %" G_GUINT64_FORMAT
482 " and flags (0x%x) \'%s\'", i,
483 (guint64) device->memory_properties.memoryHeaps[i].size,
484 device->memory_properties.memoryHeaps[i].flags, prop_flags_str);
485 g_free (prop_flags_str);
487 GST_DEBUG_OBJECT (device, "found %" G_GUINT32_FORMAT " memory types",
488 device->memory_properties.memoryTypeCount);
489 for (i = 0; i < device->memory_properties.memoryTypeCount; i++) {
490 gchar *prop_flags_str =
491 gst_vulkan_memory_property_flags_to_string (device->memory_properties.
492 memoryTypes[i].propertyFlags);
493 GST_LOG_OBJECT (device,
494 "memory type at index %i is allocatable from "
495 "heap %i with flags (0x%x) \'%s\'", i,
496 device->memory_properties.memoryTypes[i].heapIndex,
497 device->memory_properties.memoryTypes[i].propertyFlags, prop_flags_str);
498 g_free (prop_flags_str);
505 dump_queue_properties (GstVulkanPhysicalDevice * device, GError ** error)
509 GST_DEBUG_OBJECT (device, "found %" G_GUINT32_FORMAT " queue families",
510 device->n_queue_families);
511 for (i = 0; i < device->n_queue_families; i++) {
512 gchar *queue_flags_str =
513 gst_vulkan_queue_flags_to_string (device->
514 queue_family_props[i].queueFlags);
515 GST_LOG_OBJECT (device,
516 "queue family at index %i supports %i queues "
517 "with flags (0x%x) \'%s\', %" G_GUINT32_FORMAT " timestamp bits and "
518 "a minimum image transfer granuality of %" GST_VULKAN_EXTENT3D_FORMAT,
519 i, device->queue_family_props[i].queueCount,
520 device->queue_family_props[i].queueFlags, queue_flags_str,
521 device->queue_family_props[i].timestampValidBits,
522 GST_VULKAN_EXTENT3D_ARGS (device->
523 queue_family_props[i].minImageTransferGranularity));
524 g_free (queue_flags_str);
531 dump_limits (GstVulkanPhysicalDevice * device, GError ** error)
533 VkPhysicalDeviceLimits *limits = &device->properties.limits;
536 DEBUG_UINT32 ("limit", limits, maxImageDimension1D);
537 DEBUG_UINT32 ("limit", limits, maxImageDimension2D);
538 DEBUG_UINT32 ("limit", limits, maxImageDimension3D);
539 DEBUG_UINT32 ("limit", limits, maxImageDimensionCube);
540 DEBUG_UINT32 ("limit", limits, maxImageArrayLayers);
541 DEBUG_UINT32 ("limit", limits, maxTexelBufferElements);
542 DEBUG_UINT32 ("limit", limits, maxUniformBufferRange);
543 DEBUG_UINT32 ("limit", limits, maxStorageBufferRange);
544 DEBUG_UINT32 ("limit", limits, maxPushConstantsSize);
545 DEBUG_UINT32 ("limit", limits, maxMemoryAllocationCount);
546 DEBUG_UINT32 ("limit", limits, maxSamplerAllocationCount);
547 DEBUG_UINT64 ("limit", limits, bufferImageGranularity);
548 DEBUG_UINT64 ("limit", limits, sparseAddressSpaceSize);
549 DEBUG_UINT32 ("limit", limits, maxBoundDescriptorSets);
550 DEBUG_UINT32 ("limit", limits, maxPerStageDescriptorSamplers);
551 DEBUG_UINT32 ("limit", limits, maxPerStageDescriptorUniformBuffers);
552 DEBUG_UINT32 ("limit", limits, maxPerStageDescriptorStorageBuffers);
553 DEBUG_UINT32 ("limit", limits, maxPerStageDescriptorSampledImages);
554 DEBUG_UINT32 ("limit", limits, maxPerStageDescriptorStorageImages);
555 DEBUG_UINT32 ("limit", limits, maxPerStageDescriptorInputAttachments);
556 DEBUG_UINT32 ("limit", limits, maxPerStageResources);
557 DEBUG_UINT32 ("limit", limits, maxDescriptorSetSamplers);
558 DEBUG_UINT32 ("limit", limits, maxDescriptorSetUniformBuffers);
559 DEBUG_UINT32 ("limit", limits, maxDescriptorSetUniformBuffersDynamic);
560 DEBUG_UINT32 ("limit", limits, maxDescriptorSetStorageBuffers);
561 DEBUG_UINT32 ("limit", limits, maxDescriptorSetStorageBuffersDynamic);
562 DEBUG_UINT32 ("limit", limits, maxDescriptorSetSampledImages);
563 DEBUG_UINT32 ("limit", limits, maxDescriptorSetStorageImages);
564 DEBUG_UINT32 ("limit", limits, maxDescriptorSetInputAttachments);
565 DEBUG_UINT32 ("limit", limits, maxVertexInputAttributes);
566 DEBUG_UINT32 ("limit", limits, maxVertexInputBindings);
567 DEBUG_UINT32 ("limit", limits, maxVertexInputBindings);
568 DEBUG_UINT32 ("limit", limits, maxVertexInputAttributeOffset);
569 DEBUG_UINT32 ("limit", limits, maxVertexInputBindingStride);
570 DEBUG_UINT32 ("limit", limits, maxVertexOutputComponents);
571 DEBUG_UINT32 ("limit", limits, maxTessellationGenerationLevel);
572 DEBUG_UINT32 ("limit", limits, maxTessellationPatchSize);
573 DEBUG_UINT32 ("limit", limits, maxTessellationControlPerVertexInputComponents);
574 DEBUG_UINT32 ("limit", limits, maxTessellationControlPerVertexOutputComponents);
575 DEBUG_UINT32 ("limit", limits, maxTessellationControlPerPatchOutputComponents);
576 DEBUG_UINT32 ("limit", limits, maxTessellationControlTotalOutputComponents);
577 DEBUG_UINT32 ("limit", limits, maxTessellationControlTotalOutputComponents);
578 DEBUG_UINT32 ("limit", limits, maxTessellationEvaluationInputComponents);
579 DEBUG_UINT32 ("limit", limits, maxTessellationEvaluationOutputComponents);
580 DEBUG_UINT32 ("limit", limits, maxGeometryShaderInvocations);
581 DEBUG_UINT32 ("limit", limits, maxGeometryInputComponents);
582 DEBUG_UINT32 ("limit", limits, maxGeometryOutputComponents);
583 DEBUG_UINT32 ("limit", limits, maxGeometryOutputVertices);
584 DEBUG_UINT32 ("limit", limits, maxGeometryTotalOutputComponents);
585 DEBUG_UINT32 ("limit", limits, maxFragmentInputComponents);
586 DEBUG_UINT32 ("limit", limits, maxFragmentOutputAttachments);
587 DEBUG_UINT32 ("limit", limits, maxFragmentDualSrcAttachments);
588 DEBUG_UINT32 ("limit", limits, maxFragmentCombinedOutputResources);
589 DEBUG_UINT32 ("limit", limits, maxComputeSharedMemorySize);
590 DEBUG_UINT32_3 ("limit", limits, maxComputeWorkGroupCount);
591 DEBUG_UINT32 ("limit", limits, maxComputeWorkGroupInvocations);
592 DEBUG_UINT32_3 ("limit", limits, maxComputeWorkGroupSize);
593 DEBUG_UINT32 ("limit", limits, subPixelPrecisionBits);
594 DEBUG_UINT32 ("limit", limits, subTexelPrecisionBits);
595 DEBUG_UINT32 ("limit", limits, mipmapPrecisionBits);
596 DEBUG_UINT32 ("limit", limits, maxDrawIndexedIndexValue);
597 DEBUG_UINT32 ("limit", limits, maxDrawIndirectCount);
598 DEBUG_FLOAT ("limit", limits, maxSamplerLodBias);
599 DEBUG_FLOAT ("limit", limits, maxSamplerAnisotropy);
600 DEBUG_UINT32 ("limit", limits, maxViewports);
601 DEBUG_UINT32_2 ("limit", limits, maxViewportDimensions);
602 DEBUG_FLOAT_2 ("limit", limits, viewportBoundsRange);
603 DEBUG_UINT32 ("limit", limits, viewportSubPixelBits);
604 DEBUG_SIZE ("limit", limits, minMemoryMapAlignment);
605 DEBUG_UINT64 ("limit", limits, minTexelBufferOffsetAlignment);
606 DEBUG_UINT64 ("limit", limits, minUniformBufferOffsetAlignment);
607 DEBUG_UINT64 ("limit", limits, minStorageBufferOffsetAlignment);
608 DEBUG_INT32 ("limit", limits, minTexelOffset);
609 DEBUG_UINT32 ("limit", limits, maxTexelOffset);
610 DEBUG_INT32 ("limit", limits, minTexelGatherOffset);
611 DEBUG_UINT32 ("limit", limits, maxTexelGatherOffset);
612 DEBUG_FLOAT ("limit", limits, minInterpolationOffset);
613 DEBUG_FLOAT ("limit", limits, maxInterpolationOffset);
614 DEBUG_UINT32 ("limit", limits, subPixelInterpolationOffsetBits);
615 DEBUG_UINT32 ("limit", limits, maxFramebufferWidth);
616 DEBUG_UINT32 ("limit", limits, maxFramebufferHeight);
617 DEBUG_UINT32 ("limit", limits, maxFramebufferLayers);
618 DEBUG_FLAGS ("limit", limits, framebufferColorSampleCounts, sample_count);
619 DEBUG_FLAGS ("limit", limits, framebufferDepthSampleCounts, sample_count);
620 DEBUG_FLAGS ("limit", limits, framebufferStencilSampleCounts, sample_count);
621 DEBUG_FLAGS ("limit", limits, framebufferNoAttachmentsSampleCounts, sample_count);
622 DEBUG_UINT32 ("limit", limits, maxColorAttachments);
623 DEBUG_FLAGS ("limit", limits, sampledImageColorSampleCounts, sample_count);
624 DEBUG_FLAGS ("limit", limits, sampledImageIntegerSampleCounts, sample_count);
625 DEBUG_FLAGS ("limit", limits, sampledImageDepthSampleCounts, sample_count);
626 DEBUG_FLAGS ("limit", limits, sampledImageStencilSampleCounts, sample_count);
627 DEBUG_FLAGS ("limit", limits, storageImageSampleCounts, sample_count);
628 DEBUG_BOOL_STRUCT ("limit", limits, timestampComputeAndGraphics);
629 DEBUG_FLOAT ("limit", limits, timestampPeriod);
630 DEBUG_UINT32 ("limit", limits, maxClipDistances);
631 DEBUG_UINT32 ("limit", limits, maxCullDistances);
632 DEBUG_UINT32 ("limit", limits, maxCombinedClipAndCullDistances);
633 DEBUG_UINT32 ("limit", limits, discreteQueuePriorities);
634 DEBUG_FLOAT_2 ("limit", limits, pointSizeRange);
635 DEBUG_FLOAT_2 ("limit", limits, lineWidthRange);
636 DEBUG_FLOAT ("limit", limits, pointSizeGranularity);
637 DEBUG_FLOAT ("limit", limits, lineWidthGranularity);
638 DEBUG_BOOL_STRUCT ("limit", limits, strictLines);
639 DEBUG_BOOL_STRUCT ("limit", limits, standardSampleLocations);
640 DEBUG_UINT64 ("limit", limits, optimalBufferCopyOffsetAlignment);
641 DEBUG_UINT64 ("limit", limits, optimalBufferCopyRowPitchAlignment);
642 DEBUG_UINT64 ("limit", limits, nonCoherentAtomSize);
649 dump_sparse_properties (GstVulkanPhysicalDevice * device, GError ** error)
651 VkPhysicalDeviceSparseProperties *props =
652 &device->properties.sparseProperties;
655 DEBUG_BOOL_STRUCT ("sparse property", props, residencyStandard2DBlockShape);
656 DEBUG_BOOL_STRUCT ("sparse property", props, residencyStandard2DMultisampleBlockShape);
657 DEBUG_BOOL_STRUCT ("sparse property", props, residencyStandard3DBlockShape);
658 DEBUG_BOOL_STRUCT ("sparse property", props, residencyAlignedMipSize);
659 DEBUG_BOOL_STRUCT ("sparse property", props, residencyNonResidentStrict);
665 #if defined (VK_API_VERSION_1_2)
667 dump_properties11 (GstVulkanPhysicalDevice * device,
668 VkPhysicalDeviceVulkan11Properties * properties)
671 /* uint8_t deviceUUID[VK_UUID_SIZE];
672 uint8_t driverUUID[VK_UUID_SIZE];
673 uint8_t deviceLUID[VK_LUID_SIZE];*/
674 DEBUG_UINT32 ("properties (1.1)", properties, deviceNodeMask);
675 /* VkBool32 deviceLUIDValid;*/
676 DEBUG_UINT32 ("properties (1.1)", properties, subgroupSize);
677 /* VkShaderStageFlags subgroupSupportedStages;
678 VkSubgroupFeatureFlags subgroupSupportedOperations;*/
679 DEBUG_BOOL_STRUCT ("properties (1.1)", properties, subgroupQuadOperationsInAllStages);
680 /* VkPointClippingBehavior pointClippingBehavior;*/
681 DEBUG_UINT32 ("properties (1.1)", properties, maxMultiviewViewCount);
682 DEBUG_UINT32 ("properties (1.1)", properties, maxMultiviewInstanceIndex);
683 DEBUG_BOOL_STRUCT ("properties (1.1)", properties, protectedNoFault);
684 DEBUG_UINT32 ("properties (1.1)", properties, maxPerSetDescriptors);
685 DEBUG_SIZE ("properties (1.1)", properties, maxMemoryAllocationSize);
690 dump_properties12 (GstVulkanPhysicalDevice * device,
691 VkPhysicalDeviceVulkan12Properties * properties)
694 /* VkDriverId driverID;*/
695 DEBUG_STRING ("properties (1.2)", properties, driverName);
696 DEBUG_STRING ("properties (1.2)", properties, driverInfo);
697 /* VkConformanceVersion conformanceVersion;
698 VkShaderFloatControlsIndependence denormBehaviorIndependence;
699 VkShaderFloatControlsIndependence roundingModeIndependence;*/
700 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderSignedZeroInfNanPreserveFloat16);
701 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderSignedZeroInfNanPreserveFloat32);
702 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderSignedZeroInfNanPreserveFloat64);
703 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderDenormPreserveFloat16);
704 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderDenormPreserveFloat32);
705 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderDenormPreserveFloat64);
706 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderDenormFlushToZeroFloat16);
707 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderDenormFlushToZeroFloat16);
708 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderDenormFlushToZeroFloat32);
709 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderRoundingModeRTEFloat16);
710 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderRoundingModeRTEFloat32);
711 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderRoundingModeRTEFloat64);
712 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderRoundingModeRTZFloat16);
713 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderRoundingModeRTZFloat32);
714 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderRoundingModeRTZFloat64);
715 DEBUG_UINT32 ("properties (1.2)", properties, maxUpdateAfterBindDescriptorsInAllPools);
716 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderUniformBufferArrayNonUniformIndexingNative);
717 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderSampledImageArrayNonUniformIndexingNative);
718 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderSampledImageArrayNonUniformIndexingNative);
719 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderStorageBufferArrayNonUniformIndexingNative);
720 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderStorageImageArrayNonUniformIndexingNative);
721 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, shaderInputAttachmentArrayNonUniformIndexingNative);
722 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, robustBufferAccessUpdateAfterBind);
723 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, quadDivergentImplicitLod);
724 DEBUG_UINT32 ("properties (1.2)", properties, maxPerStageDescriptorUpdateAfterBindSamplers);
725 DEBUG_UINT32 ("properties (1.2)", properties, maxPerStageDescriptorUpdateAfterBindUniformBuffers);
726 DEBUG_UINT32 ("properties (1.2)", properties, maxPerStageDescriptorUpdateAfterBindStorageBuffers);
727 DEBUG_UINT32 ("properties (1.2)", properties, maxPerStageDescriptorUpdateAfterBindSampledImages);
728 DEBUG_UINT32 ("properties (1.2)", properties, maxPerStageDescriptorUpdateAfterBindStorageImages);
729 DEBUG_UINT32 ("properties (1.2)", properties, maxPerStageDescriptorUpdateAfterBindInputAttachments);
730 DEBUG_UINT32 ("properties (1.2)", properties, maxPerStageUpdateAfterBindResources);
731 DEBUG_UINT32 ("properties (1.2)", properties, maxDescriptorSetUpdateAfterBindSamplers);
732 DEBUG_UINT32 ("properties (1.2)", properties, maxDescriptorSetUpdateAfterBindUniformBuffers);
733 DEBUG_UINT32 ("properties (1.2)", properties, maxDescriptorSetUpdateAfterBindUniformBuffersDynamic);
734 DEBUG_UINT32 ("properties (1.2)", properties, maxDescriptorSetUpdateAfterBindStorageBuffers);
735 DEBUG_UINT32 ("properties (1.2)", properties, maxDescriptorSetUpdateAfterBindStorageBuffersDynamic);
736 DEBUG_UINT32 ("properties (1.2)", properties, maxDescriptorSetUpdateAfterBindSampledImages);
737 DEBUG_UINT32 ("properties (1.2)", properties, maxDescriptorSetUpdateAfterBindStorageImages);
738 DEBUG_UINT32 ("properties (1.2)", properties, maxDescriptorSetUpdateAfterBindInputAttachments);
739 /* VkResolveModeFlags supportedDepthResolveModes;
740 VkResolveModeFlags supportedStencilResolveModes;*/
741 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, independentResolveNone);
742 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, independentResolve);
743 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, filterMinmaxSingleComponentFormats);
744 DEBUG_BOOL_STRUCT ("properties (1.2)", properties, filterMinmaxImageComponentMapping);
745 DEBUG_UINT64 ("properties (1.2)", properties, maxTimelineSemaphoreValueDifference);
746 DEBUG_FLAGS ("properties (1.2)", properties, framebufferIntegerColorSampleCounts, sample_count);
752 physical_device_info (GstVulkanPhysicalDevice * device, GError ** error)
754 #if defined (VK_API_VERSION_1_2)
755 GstVulkanPhysicalDevicePrivate *priv = GET_PRIV (device);
756 VkBaseOutStructure *iter;
759 GST_INFO_OBJECT (device, "physical device %i name \'%s\' type \'%s\' "
760 "api version %u.%u.%u, driver version %u.%u.%u vendor ID 0x%x, "
761 "device ID 0x%x", device->device_index, device->properties.deviceName,
762 gst_vulkan_physical_device_type_to_string (device->properties.deviceType),
763 VK_VERSION_MAJOR (device->properties.apiVersion),
764 VK_VERSION_MINOR (device->properties.apiVersion),
765 VK_VERSION_PATCH (device->properties.apiVersion),
766 VK_VERSION_MAJOR (device->properties.driverVersion),
767 VK_VERSION_MINOR (device->properties.driverVersion),
768 VK_VERSION_PATCH (device->properties.driverVersion),
769 device->properties.vendorID, device->properties.deviceID);
771 if (!dump_queue_properties (device, error))
773 if (!dump_memory_properties (device, error))
775 if (!dump_features (device, error))
777 if (!dump_limits (device, error))
779 if (!dump_sparse_properties (device, error))
782 #if defined (VK_API_VERSION_1_2)
783 if (gst_vulkan_instance_check_version (device->instance, 1, 2, 0)) {
784 for (iter = (VkBaseOutStructure *) & priv->properties10; iter;
785 iter = iter->pNext) {
787 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES)
788 dump_properties11 (device, (VkPhysicalDeviceVulkan11Properties *) iter);
789 else if (iter->sType ==
790 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES)
791 dump_properties12 (device, (VkPhysicalDeviceVulkan12Properties *) iter);
800 gst_vulkan_physical_device_fill_info (GstVulkanPhysicalDevice * device,
803 GstVulkanPhysicalDevicePrivate *priv = GET_PRIV (device);
807 device->device = gst_vulkan_physical_device_get_handle (device);
808 if (!device->device) {
809 g_set_error (error, GST_VULKAN_ERROR, VK_ERROR_INITIALIZATION_FAILED,
810 "Failed to retrieve physical device");
815 vkEnumerateDeviceLayerProperties (device->device,
816 &priv->n_available_layers, NULL);
817 if (gst_vulkan_error_to_g_error (err, error,
818 "vkEnumerateDeviceLayerProperties") < 0)
821 priv->available_layers = g_new0 (VkLayerProperties, priv->n_available_layers);
823 vkEnumerateDeviceLayerProperties (device->device,
824 &priv->n_available_layers, priv->available_layers);
825 if (gst_vulkan_error_to_g_error (err, error,
826 "vkEnumerateDeviceLayerProperties") < 0) {
831 vkEnumerateDeviceExtensionProperties (device->device, NULL,
832 &priv->n_available_extensions, NULL);
833 if (gst_vulkan_error_to_g_error (err, error,
834 "vkEnumerateDeviceExtensionProperties") < 0) {
838 priv->available_extensions =
839 g_new0 (VkExtensionProperties, priv->n_available_extensions);
841 vkEnumerateDeviceExtensionProperties (device->device, NULL,
842 &priv->n_available_extensions, priv->available_extensions);
843 if (gst_vulkan_error_to_g_error (err, error,
844 "vkEnumerateDeviceExtensionProperties") < 0) {
848 GST_INFO_OBJECT (device, "found %u layers and %u extensions",
849 priv->n_available_layers, priv->n_available_extensions);
851 for (i = 0; i < priv->n_available_layers; i++)
852 GST_DEBUG_OBJECT (device, "available layer %u: %s", i,
853 priv->available_layers[i].layerName);
854 for (i = 0; i < priv->n_available_extensions; i++)
855 GST_DEBUG_OBJECT (device, "available extension %u: %s", i,
856 priv->available_extensions[i].extensionName);
858 vkGetPhysicalDeviceProperties (device->device, &device->properties);
859 #if defined (VK_API_VERSION_1_2)
860 if (gst_vulkan_instance_check_version (device->instance, 1, 2, 0)) {
861 PFN_vkGetPhysicalDeviceProperties2 get_props2;
862 PFN_vkGetPhysicalDeviceMemoryProperties2 get_mem_props2;
863 PFN_vkGetPhysicalDeviceFeatures2 get_features2;
864 PFN_vkGetPhysicalDeviceQueueFamilyProperties2 get_queue_props2;
865 VkPhysicalDeviceMemoryProperties2 mem_properties10;
868 mem_properties10 = (VkPhysicalDeviceMemoryProperties2) {
869 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2,
874 get_props2 = (PFN_vkGetPhysicalDeviceProperties2)
875 gst_vulkan_instance_get_proc_address (device->instance,
876 "vkGetPhysicalDeviceProperties2");
877 get_props2 (device->device, &priv->properties10);
879 get_mem_props2 = (PFN_vkGetPhysicalDeviceMemoryProperties2)
880 gst_vulkan_instance_get_proc_address (device->instance,
881 "vkGetPhysicalDeviceMemoryProperties2");
882 get_mem_props2 (device->device, &mem_properties10);
883 memcpy (&device->memory_properties, &mem_properties10.memoryProperties,
884 sizeof (device->memory_properties));
886 get_features2 = (PFN_vkGetPhysicalDeviceFeatures2)
887 gst_vulkan_instance_get_proc_address (device->instance,
888 "vkGetPhysicalDeviceFeatures2");
889 get_features2 (device->device, &priv->features10);
890 memcpy (&device->features, &priv->features10.features,
891 sizeof (device->features));
893 get_queue_props2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2)
894 gst_vulkan_instance_get_proc_address (device->instance,
895 "vkGetPhysicalDeviceQueueFamilyProperties2");
896 get_queue_props2 (device->device, &device->n_queue_families, NULL);
897 if (device->n_queue_families > 0) {
898 VkQueueFamilyProperties2 *props;
901 props = g_new0 (VkQueueFamilyProperties2, device->n_queue_families);
902 for (i = 0; i < device->n_queue_families; i++) {
903 props[i].sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2;
904 props[i].pNext = NULL;
907 get_queue_props2 (device->device, &device->n_queue_families, props);
909 device->queue_family_props =
910 g_new0 (VkQueueFamilyProperties, device->n_queue_families);
911 for (i = 0; i < device->n_queue_families; i++) {
912 memcpy (&device->queue_family_props[i], &props[i].queueFamilyProperties,
913 sizeof (device->queue_family_props[i]));
920 vkGetPhysicalDeviceMemoryProperties (device->device,
921 &device->memory_properties);
922 vkGetPhysicalDeviceFeatures (device->device, &device->features);
923 vkGetPhysicalDeviceQueueFamilyProperties (device->device,
924 &device->n_queue_families, NULL);
925 if (device->n_queue_families > 0) {
926 device->queue_family_props =
927 g_new0 (VkQueueFamilyProperties, device->n_queue_families);
928 vkGetPhysicalDeviceQueueFamilyProperties (device->device,
929 &device->n_queue_families, device->queue_family_props);
933 if (!physical_device_info (device, error))
943 * gst_vulkan_physical_device_get_handle: (skip)
944 * @device: a #GstVulkanPhysicalDevice
946 * Returns: The associated `VkPhysicalDevice` handle
951 gst_vulkan_physical_device_get_handle (GstVulkanPhysicalDevice * device)
953 g_return_val_if_fail (GST_IS_VULKAN_PHYSICAL_DEVICE (device), NULL);
955 return device->device;
959 * gst_vulkan_physical_device_get_instance:
960 * @device: a #GstVulkanPhysicalDevice
962 * Returns: (transfer full): The #GstVulkanInstance associated with this physical device
967 gst_vulkan_physical_device_get_instance (GstVulkanPhysicalDevice * device)
969 g_return_val_if_fail (GST_IS_VULKAN_PHYSICAL_DEVICE (device), NULL);
971 return device->instance ? gst_object_ref (device->instance) : NULL;
975 gst_vulkan_physical_device_get_layer_info_unlocked (GstVulkanPhysicalDevice *
976 device, const gchar * name, gchar ** description, guint32 * spec_version,
977 guint32 * implementation_version)
979 GstVulkanPhysicalDevicePrivate *priv;
982 priv = GET_PRIV (device);
984 for (i = 0; i < priv->n_available_layers; i++) {
985 if (g_strcmp0 (name, priv->available_layers[i].layerName) == 0) {
987 *description = g_strdup (priv->available_layers[i].description);
989 *spec_version = priv->available_layers[i].specVersion;
990 if (implementation_version)
991 *spec_version = priv->available_layers[i].implementationVersion;
1000 * gst_vulkan_physical_device_get_layer_info:
1001 * @device: a #GstVulkanPhysicalDevice
1002 * @name: the layer name to look for
1003 * @description: (out) (nullable): return value for the layer description or %NULL
1004 * @spec_version: (out) (nullable): return value for the layer specification version
1005 * @implementation_version: (out) (nullable): return value for the layer implementation version
1007 * Retrieves information about a layer.
1009 * Will not find any layers before gst_vulkan_instance_fill_info() has been
1012 * Returns: whether layer @name is available
1017 gst_vulkan_physical_device_get_layer_info (GstVulkanPhysicalDevice * device,
1018 const gchar * name, gchar ** description, guint32 * spec_version,
1019 guint32 * implementation_version)
1023 g_return_val_if_fail (GST_IS_VULKAN_PHYSICAL_DEVICE (device), FALSE);
1024 g_return_val_if_fail (name != NULL, FALSE);
1026 GST_OBJECT_LOCK (device);
1028 gst_vulkan_physical_device_get_layer_info_unlocked (device, name,
1029 description, spec_version, implementation_version);
1030 GST_OBJECT_UNLOCK (device);
1036 gst_vulkan_physical_device_get_extension_info_unlocked (GstVulkanPhysicalDevice
1037 * device, const gchar * name, guint32 * spec_version)
1039 GstVulkanPhysicalDevicePrivate *priv;
1042 priv = GET_PRIV (device);
1044 for (i = 0; i < priv->n_available_extensions; i++) {
1045 if (g_strcmp0 (name, priv->available_extensions[i].extensionName) == 0) {
1047 *spec_version = priv->available_extensions[i].specVersion;
1056 * gst_vulkan_physical_device_get_extension_info:
1057 * @device: a #GstVulkanPhysicalDevice
1058 * @name: the extension name to look for
1059 * @spec_version: (out) (nullable): return value for the exteion specification version
1061 * Retrieves information about a device extension.
1063 * Will not find any extensions before gst_vulkan_instance_fill_info() has been
1066 * Returns: whether extension @name is available
1071 gst_vulkan_physical_device_get_extension_info (GstVulkanPhysicalDevice * device,
1072 const gchar * name, guint32 * spec_version)
1076 g_return_val_if_fail (GST_IS_VULKAN_PHYSICAL_DEVICE (device), FALSE);
1077 g_return_val_if_fail (name != NULL, FALSE);
1079 GST_OBJECT_LOCK (device);
1081 gst_vulkan_physical_device_get_extension_info_unlocked (device, name,
1083 GST_OBJECT_UNLOCK (device);