vkphysicaldevice: enable sampler ycbcr, sync2 and timeline semaphore features

For the features VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR,
VkPhysicalDeviceSynchronization2Features and
VkPhisicalDeviceTimelineSemaphoreFeatures

The Vulkan specification states:

  If the `VkPhysicalDeviceXXXFeatures` structure is included in the `pNext`
  chain of the `VkPhysicalDeviceFeatures2` structure passed to
  `vkGetPhysicalDeviceFeatures2`, it is filled in to indicate whether each
  corresponding feature is supported. If the application wishes to use a
  `VkDevice` with any features described by `VkPhysicalDeviceXXXFeatures`,
  it **must** add an instance of the structure, with the desired feature members
  set to `VK_TRUE`, to the `pNext` chain of `VkDeviceCreateInfo` when creating
  the `VkDevice`.

And that was missing in the code.

Strangely, that functionality doesn't have a Valid-Usage ID assigned, so it
isn't caught by the validation layer.

This patch adds the structures in the physical devices to get them and later set
them in the device creation.

In order to link these features, videomaintenance1, and others to come, without
knowing if Vulkan 1.3 features are chained in the device properties structure, a
static and inlined function was added in gstvkphysicaldevice-private.h. It was
added in a header file to avoid compiler warnings if it's not used because of
old Vulkan headers.

Also the value dump videomaintenance1 was moved to another function to pack
there all these queried features.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9483>
This commit is contained in:
Víctor Manuel Jáquez Leal 2025-08-01 14:55:12 +02:00 committed by GStreamer Marge Bot
parent e653acc200
commit 829de89122
2 changed files with 75 additions and 19 deletions

View File

@ -28,6 +28,17 @@ G_BEGIN_DECLS
const
VkPhysicalDeviceFeatures2 * gst_vulkan_physical_device_get_features (GstVulkanPhysicalDevice * device);
static inline void
vk_link_struct (gpointer chain, gconstpointer in)
{
VkBaseOutStructure *out = chain;
while (out->pNext)
out = out->pNext;
out->pNext = (void *) in;
}
G_END_DECLS
#endif /* __GST_VULKAN_PHYSICAL_DEVICE_PRIVATE_H__ */

View File

@ -70,10 +70,19 @@ struct _GstVulkanPhysicalDevicePrivate
#if defined (VK_API_VERSION_1_3)
VkPhysicalDeviceVulkan13Features features13;
VkPhysicalDeviceVulkan13Properties properties13;
#endif
#if defined (VK_KHR_sampler_ycbcr_conversion)
VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR sampler_ycbcr_conversion;
#endif
#if defined (VK_KHR_synchronization2)
VkPhysicalDeviceSynchronization2FeaturesKHR synchronization2;
#endif
#if defined (VK_KHR_timeline_semaphore)
VkPhysicalDeviceTimelineSemaphoreFeaturesKHR timeline_semaphore;
#endif
#if defined (VK_KHR_video_maintenance1)
VkPhysicalDeviceVideoMaintenance1FeaturesKHR videomaintenance1;
#endif
#endif
};
static void
@ -204,11 +213,26 @@ gst_vulkan_physical_device_init (GstVulkanPhysicalDevice * device)
priv->features13.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
priv->features12.pNext = &priv->features13;
#endif
#if defined (VK_KHR_sampler_ycbcr_conversion)
priv->sampler_ycbcr_conversion.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR;
vk_link_struct (&priv->features12, &priv->sampler_ycbcr_conversion);
#endif
#if defined (VK_KHR_synchronization2)
priv->synchronization2.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR;
vk_link_struct (&priv->features12, &priv->synchronization2);
#endif
#if defined (VK_KHR_timeline_semaphore)
priv->timeline_semaphore.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR;
vk_link_struct (&priv->features12, &priv->timeline_semaphore);
#endif
#if defined (VK_KHR_video_maintenance1)
priv->videomaintenance1.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_MAINTENANCE_1_FEATURES_KHR;
priv->features13.pNext = &priv->videomaintenance1;
#endif
vk_link_struct (&priv->features12, &priv->videomaintenance1);
#endif
}
@ -487,17 +511,43 @@ dump_features13 (GstVulkanPhysicalDevice * device,
DEBUG_BOOL_STRUCT ("support for (1.3)", features, maintenance4);
/* *INDENT-ON* */
}
#if defined(VK_KHR_video_maintenance1)
static void
dump_videomaintenance1 (GstVulkanPhysicalDevice * device,
VkPhysicalDeviceVideoMaintenance1FeaturesKHR * features)
{
DEBUG_BOOL_STRUCT ("support for (1.3)", features, videoMaintenance1);
}
#endif
#endif /* defined (VK_API_VERSION_1_3) */
static void
dump_extras (GstVulkanPhysicalDevice * device, VkBaseOutStructure * chain)
{
GstVulkanPhysicalDevicePrivate *priv = GET_PRIV (device);
#if defined (VK_KHR_sampler_ycbcr_conversion)
if (chain->sType ==
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR) {
DEBUG_BOOL_STRUCT ("support for", &priv->sampler_ycbcr_conversion,
samplerYcbcrConversion);
}
#endif
#if defined (VK_KHR_synchronization2)
if (chain->sType ==
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR) {
DEBUG_BOOL_STRUCT ("support for", &priv->synchronization2,
synchronization2);
}
#endif
#if defined (VK_KHR_timeline_semaphore)
if (chain->sType ==
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR) {
DEBUG_BOOL_STRUCT ("support for", &priv->timeline_semaphore,
timelineSemaphore);
}
#endif
#if defined (VK_KHR_video_maintenance1)
if (chain->sType ==
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_MAINTENANCE_1_FEATURES_KHR) {
DEBUG_BOOL_STRUCT ("support for", &priv->videomaintenance1,
videoMaintenance1);
}
#endif
}
static gboolean
dump_features (GstVulkanPhysicalDevice * device, GError ** error)
{
@ -522,14 +572,9 @@ dump_features (GstVulkanPhysicalDevice * device, GError ** error)
&& iter->sType ==
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES)
dump_features13 (device, (VkPhysicalDeviceVulkan13Features *) iter);
#if defined(VK_KHR_video_maintenance1)
else if (gst_vulkan_physical_device_check_api_version (device, 1, 3, 283)
&& iter->sType ==
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_MAINTENANCE_1_FEATURES_KHR)
dump_videomaintenance1 (device,
(VkPhysicalDeviceVideoMaintenance1FeaturesKHR *) iter);
#endif
#endif
else
dump_extras (device, iter);
}
} else
#endif