mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +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;
|
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)
|
* gst_vulkan_format_from_video_info_2: (skip)
|
||||||
* @physical_device: a #GstVulkanPhysicalDevice
|
* @physical_device: a #GstVulkanPhysicalDevice
|
||||||
|
@ -581,9 +621,6 @@ gst_vulkan_format_from_video_info_2 (GstVulkanPhysicalDevice * physical_device,
|
||||||
int i;
|
int i;
|
||||||
VkPhysicalDevice gpu;
|
VkPhysicalDevice gpu;
|
||||||
#if defined (VK_KHR_get_physical_device_properties2)
|
#if defined (VK_KHR_get_physical_device_properties2)
|
||||||
VkFormatProperties2KHR prop = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR,
|
|
||||||
};
|
|
||||||
PFN_vkGetPhysicalDeviceFormatProperties2KHR
|
PFN_vkGetPhysicalDeviceFormatProperties2KHR
|
||||||
gst_vkGetPhysicalDeviceFormatProperties2 = NULL;
|
gst_vkGetPhysicalDeviceFormatProperties2 = NULL;
|
||||||
|
|
||||||
|
@ -594,50 +631,29 @@ gst_vulkan_format_from_video_info_2 (GstVulkanPhysicalDevice * physical_device,
|
||||||
gst_vkGetPhysicalDeviceFormatProperties2 =
|
gst_vkGetPhysicalDeviceFormatProperties2 =
|
||||||
gst_vulkan_instance_get_proc_address (physical_device->instance,
|
gst_vulkan_instance_get_proc_address (physical_device->instance,
|
||||||
"vkGetPhysicalDeviceFormatProperties2KHR");
|
"vkGetPhysicalDeviceFormatProperties2KHR");
|
||||||
|
#else
|
||||||
|
gpointer gst_vkGetPhysicalDeviceFormatProperties2 = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gpu = gst_vulkan_physical_device_get_handle (physical_device);
|
gpu = gst_vulkan_physical_device_get_handle (physical_device);
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (vk_formats_map); i++) {
|
for (i = 0; i < G_N_ELEMENTS (vk_formats_map); i++) {
|
||||||
guint64 feats_primary = 0, feats_secondary = 0;
|
guint64 feats_primary, feats_secondary = 0;
|
||||||
VkFormatProperties primary_format_props = { 0, };
|
|
||||||
VkFormatProperties secondary_format_props = { 0, };
|
|
||||||
VkImageUsageFlags usage = 0;
|
VkImageUsageFlags usage = 0;
|
||||||
|
|
||||||
if (vk_formats_map[i].format != GST_VIDEO_INFO_FORMAT (info))
|
if (vk_formats_map[i].format != GST_VIDEO_INFO_FORMAT (info))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if defined (VK_KHR_get_physical_device_properties2)
|
feats_primary = _get_feature_flags (gpu,
|
||||||
if (gst_vkGetPhysicalDeviceFormatProperties2) {
|
gst_vkGetPhysicalDeviceFormatProperties2, vk_formats_map[i].vkfrmt,
|
||||||
gst_vkGetPhysicalDeviceFormatProperties2 (gpu, vk_formats_map[i].vkfrmt,
|
tiling);
|
||||||
&prop);
|
|
||||||
primary_format_props = prop.formatProperties;
|
|
||||||
|
|
||||||
if (vk_formats_map[i].vkfrmt != vk_formats_map[i].vkfrmts[0]) {
|
if (vk_formats_map[i].vkfrmt != vk_formats_map[i].vkfrmts[0]) {
|
||||||
gst_vkGetPhysicalDeviceFormatProperties2 (gpu,
|
feats_secondary = _get_feature_flags (gpu,
|
||||||
vk_formats_map[i].vkfrmts[0], &prop);
|
gst_vkGetPhysicalDeviceFormatProperties2,
|
||||||
secondary_format_props = prop.formatProperties;
|
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_IS_RGB (info)) {
|
||||||
if ((GST_VIDEO_INFO_COLORIMETRY (info).transfer ==
|
if ((GST_VIDEO_INFO_COLORIMETRY (info).transfer ==
|
||||||
GST_VIDEO_TRANSFER_SRGB
|
GST_VIDEO_TRANSFER_SRGB
|
||||||
|
|
Loading…
Reference in a new issue