SDL: vulkan: enable samplerYcbcrConversion when creating the device

From 759ade8c90ecc35638ba370c709f1fc7a94a1c6e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 4 Mar 2024 10:26:28 -0800
Subject: [PATCH] vulkan: enable samplerYcbcrConversion when creating the
 device

---
 src/render/vulkan/SDL_render_vulkan.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/render/vulkan/SDL_render_vulkan.c b/src/render/vulkan/SDL_render_vulkan.c
index b80d130dfebd..7f9490b7bb0d 100644
--- a/src/render/vulkan/SDL_render_vulkan.c
+++ b/src/render/vulkan/SDL_render_vulkan.c
@@ -1782,10 +1782,11 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
     if (rendererData->device) {
         rendererData->device_external = SDL_TRUE;
     } else {
+        VkPhysicalDeviceSamplerYcbcrConversionFeatures deviceSamplerYcbcrConversionFeatures = { 0 };
         VkDeviceQueueCreateInfo deviceQueueCreateInfo[2] = { { 0 }, { 0 } };
         static const float queuePriority[] = { 1.0f };
-        VkDeviceCreateInfo deviceCreateInfo = { 0 };
 
+        VkDeviceCreateInfo deviceCreateInfo = { 0 };
         deviceCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
         deviceCreateInfo.queueCreateInfoCount = 0;
         deviceCreateInfo.pQueueCreateInfos = deviceQueueCreateInfo;
@@ -1807,6 +1808,13 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
             ++deviceCreateInfo.queueCreateInfoCount;
         }
 
+        if (rendererData->supportsKHRSamplerYCbCrConversion) {
+            deviceSamplerYcbcrConversionFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES;
+            deviceSamplerYcbcrConversionFeatures.samplerYcbcrConversion = VK_TRUE;
+            deviceSamplerYcbcrConversionFeatures.pNext = (void *)deviceCreateInfo.pNext;
+            deviceCreateInfo.pNext = &deviceSamplerYcbcrConversionFeatures;
+        }
+
         result = vkCreateDevice(rendererData->physicalDevice, &deviceCreateInfo, NULL, &rendererData->device);
         if (result != VK_SUCCESS) {
             SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkCreateDevice(): %s\n", SDL_Vulkan_GetResultString(result));