vulkan: fix C2099 error with VS2019

As VK_FORMAT_FEATURE_2_xxx are defined as static const variable, the
vscoce C compiler prevents the initialization of the  vk_usage_map
structure with error "C2099: initializer is not a constant".

Init the structure separately.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4904>
This commit is contained in:
Stéphane Cerveau 2023-06-20 14:33:48 +01:00 committed by GStreamer Marge Bot
parent 759857c203
commit 6920166af4

View file

@ -509,32 +509,40 @@ gst_vulkan_format_from_video_info (GstVideoInfo * v_info, guint plane)
}
#if (defined(VK_VERSION_1_3) || defined(VK_VERSION_1_2) && VK_HEADER_VERSION >= 195)
/* *INDENT-OFF* */
const static struct {
VkFormatFeatureFlagBits2KHR feature;
struct vkUsage
{
const VkFormatFeatureFlagBits2 feature;
VkImageUsageFlags usage;
} vk_usage_map[] = {
{ VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT_KHR, VK_IMAGE_USAGE_SAMPLED_BIT },
{ VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT_KHR, VK_IMAGE_USAGE_TRANSFER_SRC_BIT },
{ VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT_KHR, VK_IMAGE_USAGE_TRANSFER_DST_BIT },
{ VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT_KHR, VK_IMAGE_USAGE_STORAGE_BIT },
{ VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT_KHR, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT },
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
{ VK_FORMAT_FEATURE_2_VIDEO_DECODE_OUTPUT_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR },
{ VK_FORMAT_FEATURE_2_VIDEO_DECODE_DPB_BIT_KHR, VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR },
#ifdef VK_ENABLE_BETA_EXTENSIONS
{ VK_FORMAT_FEATURE_2_VIDEO_ENCODE_DPB_BIT_KHR, VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR },
{ VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR, VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR },
#endif
#endif
};
/* *INDENT-ON* */
static VkImageUsageFlags
_get_usage (guint64 feature)
{
int i;
VkImageUsageFlags usage = 0;
/* *INDENT-OFF* */
const struct vkUsage vk_usage_map[] = {
{VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT_KHR, VK_IMAGE_USAGE_SAMPLED_BIT},
{VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT_KHR, VK_IMAGE_USAGE_TRANSFER_SRC_BIT},
{VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT_KHR, VK_IMAGE_USAGE_TRANSFER_DST_BIT},
{VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT_KHR, VK_IMAGE_USAGE_STORAGE_BIT},
{VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT_KHR,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT},
#if GST_VULKAN_HAVE_VIDEO_EXTENSIONS
{VK_FORMAT_FEATURE_2_VIDEO_DECODE_OUTPUT_BIT_KHR,
VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR},
{VK_FORMAT_FEATURE_2_VIDEO_DECODE_DPB_BIT_KHR,
VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR},
#ifdef VK_ENABLE_BETA_EXTENSIONS
{VK_FORMAT_FEATURE_2_VIDEO_ENCODE_DPB_BIT_KHR,
VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR},
{VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR,
VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR},
#endif
#endif
};
/* *INDENT-ON* */
for (i = 0; i < G_N_ELEMENTS (vk_usage_map); i++) {
if (vk_usage_map[i].feature & feature)