Browse Source

vulkan: enable samplerYcbcrConversion when creating the device

Sam Lantinga 1 year ago
parent
commit
759ade8c90
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/render/vulkan/SDL_render_vulkan.c

+ 9 - 1
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));