mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 07:08:23 +00:00
vkformat: fetch correctly feature flags2
Feature flags2 are fetch through VkFormatProperties3KHR and needs more guards checking. Moved out all the feature flags fetching to another function for clarity. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6014>
This commit is contained in:
parent
c24b47ecee
commit
c760c72f7a
1 changed files with 50 additions and 34 deletions
|
@ -557,6 +557,46 @@ _get_usage (guint64 feature)
|
|||
return usage;
|
||||
}
|
||||
|
||||
static guint64
|
||||
_get_feature_flags (VkPhysicalDevice gpu, gpointer func, VkFormat format,
|
||||
VkImageTiling tiling)
|
||||
{
|
||||
VkFormatProperties prop = { 0 };
|
||||
#if defined (VK_KHR_get_physical_device_properties2)
|
||||
#if defined (VK_KHR_format_feature_flags2)
|
||||
VkFormatProperties3KHR prop3 = {
|
||||
.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3_KHR,
|
||||
};
|
||||
#endif
|
||||
VkFormatProperties2KHR prop2 = {
|
||||
.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR,
|
||||
#if defined (VK_KHR_format_feature_flags2)
|
||||
.pNext = &prop3,
|
||||
#endif
|
||||
};
|
||||
|
||||
if (func) {
|
||||
PFN_vkGetPhysicalDeviceFormatProperties2KHR
|
||||
gst_vkGetPhysicalDeviceFormatProperties2 = func;
|
||||
|
||||
gst_vkGetPhysicalDeviceFormatProperties2 (gpu, format, &prop2);
|
||||
#if defined (VK_KHR_format_feature_flags2)
|
||||
return tiling == VK_IMAGE_TILING_LINEAR ?
|
||||
prop3.linearTilingFeatures : prop3.optimalTilingFeatures;
|
||||
#else
|
||||
return tiling == VK_IMAGE_TILING_LINEAR ?
|
||||
prop2.formatProperties.linearTilingFeatures :
|
||||
prop2.formatProperties.optimalTilingFeatures;
|
||||
#endif
|
||||
}
|
||||
#endif /* defined (VK_KHR_get_physical_device_properties2) */
|
||||
|
||||
/* fallback */
|
||||
vkGetPhysicalDeviceFormatProperties (gpu, format, &prop);
|
||||
return tiling == VK_IMAGE_TILING_LINEAR ?
|
||||
prop.linearTilingFeatures : prop.optimalTilingFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vulkan_format_from_video_info_2: (skip)
|
||||
* @physical_device: a #GstVulkanPhysicalDevice
|
||||
|
@ -581,9 +621,6 @@ gst_vulkan_format_from_video_info_2 (GstVulkanPhysicalDevice * physical_device,
|
|||
int i;
|
||||
VkPhysicalDevice gpu;
|
||||
#if defined (VK_KHR_get_physical_device_properties2)
|
||||
VkFormatProperties2KHR prop = {
|
||||
.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR,
|
||||
};
|
||||
PFN_vkGetPhysicalDeviceFormatProperties2KHR
|
||||
gst_vkGetPhysicalDeviceFormatProperties2 = NULL;
|
||||
|
||||
|
@ -594,49 +631,28 @@ gst_vulkan_format_from_video_info_2 (GstVulkanPhysicalDevice * physical_device,
|
|||
gst_vkGetPhysicalDeviceFormatProperties2 =
|
||||
gst_vulkan_instance_get_proc_address (physical_device->instance,
|
||||
"vkGetPhysicalDeviceFormatProperties2KHR");
|
||||
#else
|
||||
gpointer gst_vkGetPhysicalDeviceFormatProperties2 = NULL;
|
||||
#endif
|
||||
|
||||
gpu = gst_vulkan_physical_device_get_handle (physical_device);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (vk_formats_map); i++) {
|
||||
guint64 feats_primary = 0, feats_secondary = 0;
|
||||
VkFormatProperties primary_format_props = { 0, };
|
||||
VkFormatProperties secondary_format_props = { 0, };
|
||||
guint64 feats_primary, feats_secondary = 0;
|
||||
VkImageUsageFlags usage = 0;
|
||||
|
||||
if (vk_formats_map[i].format != GST_VIDEO_INFO_FORMAT (info))
|
||||
continue;
|
||||
|
||||
#if defined (VK_KHR_get_physical_device_properties2)
|
||||
if (gst_vkGetPhysicalDeviceFormatProperties2) {
|
||||
gst_vkGetPhysicalDeviceFormatProperties2 (gpu, vk_formats_map[i].vkfrmt,
|
||||
&prop);
|
||||
primary_format_props = prop.formatProperties;
|
||||
feats_primary = _get_feature_flags (gpu,
|
||||
gst_vkGetPhysicalDeviceFormatProperties2, vk_formats_map[i].vkfrmt,
|
||||
tiling);
|
||||
|
||||
if (vk_formats_map[i].vkfrmt != vk_formats_map[i].vkfrmts[0]) {
|
||||
gst_vkGetPhysicalDeviceFormatProperties2 (gpu,
|
||||
vk_formats_map[i].vkfrmts[0], &prop);
|
||||
secondary_format_props = prop.formatProperties;
|
||||
feats_secondary = _get_feature_flags (gpu,
|
||||
gst_vkGetPhysicalDeviceFormatProperties2,
|
||||
vk_formats_map[i].vkfrmts[0], tiling);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
vkGetPhysicalDeviceFormatProperties (gpu, vk_formats_map[i].vkfrmt,
|
||||
&primary_format_props);
|
||||
|
||||
if (vk_formats_map[i].vkfrmt != vk_formats_map[i].vkfrmts[0]) {
|
||||
vkGetPhysicalDeviceFormatProperties (gpu, vk_formats_map[i].vkfrmts[0],
|
||||
&secondary_format_props);
|
||||
}
|
||||
}
|
||||
|
||||
feats_primary = tiling == VK_IMAGE_TILING_LINEAR ?
|
||||
primary_format_props.linearTilingFeatures :
|
||||
primary_format_props.optimalTilingFeatures;
|
||||
|
||||
feats_secondary = tiling == VK_IMAGE_TILING_LINEAR ?
|
||||
secondary_format_props.linearTilingFeatures :
|
||||
secondary_format_props.optimalTilingFeatures;
|
||||
|
||||
if (GST_VIDEO_INFO_IS_RGB (info)) {
|
||||
if ((GST_VIDEO_INFO_COLORIMETRY (info).transfer ==
|
||||
|
|
Loading…
Reference in a new issue