SDL: The ycbcrModel should be based on the transfer matrix, not the color primaries

From 4513c32bb398238f7b9b022e4611c4e33e2a9398 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 28 Feb 2024 16:55:47 -0800
Subject: [PATCH] The ycbcrModel should be based on the transfer matrix, not
 the color primaries

---
 src/render/vulkan/SDL_render_vulkan.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/render/vulkan/SDL_render_vulkan.c b/src/render/vulkan/SDL_render_vulkan.c
index e2f5ce38fef9..296c805b8273 100644
--- a/src/render/vulkan/SDL_render_vulkan.c
+++ b/src/render/vulkan/SDL_render_vulkan.c
@@ -2456,14 +2456,16 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
 
         /* Create samplerYcbcrConversion which will be used on the VkImageView and VkSampler */
         samplerYcbcrConversionCreateInfo.format = textureFormat;
-        switch (SDL_COLORSPACEPRIMARIES(texture->colorspace)) {
-        case SDL_COLOR_PRIMARIES_BT709:
-            samplerYcbcrConversionCreateInfo.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR;
-            break;
-        case SDL_COLOR_PRIMARIES_BT601:
+        switch (SDL_COLORSPACEMATRIX(texture->colorspace)) {
+        case SDL_MATRIX_COEFFICIENTS_BT601:
             samplerYcbcrConversionCreateInfo.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR;
             break;
-        case SDL_COLOR_PRIMARIES_BT2020:
+        case SDL_MATRIX_COEFFICIENTS_BT709:
+            samplerYcbcrConversionCreateInfo.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR;
+            break;
+        /* FIXME: Are these the same? */
+        case SDL_MATRIX_COEFFICIENTS_BT2020_NCL:
+        case SDL_MATRIX_COEFFICIENTS_BT2020_CL:
             samplerYcbcrConversionCreateInfo.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR;
         default:
             VULKAN_DestroyTexture(renderer, texture);