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

This commit is contained in:
Sam Lantinga 2024-02-28 16:55:47 -08:00
parent a241cca9e6
commit 4513c32bb3

View file

@ -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 */ /* Create samplerYcbcrConversion which will be used on the VkImageView and VkSampler */
samplerYcbcrConversionCreateInfo.format = textureFormat; samplerYcbcrConversionCreateInfo.format = textureFormat;
switch (SDL_COLORSPACEPRIMARIES(texture->colorspace)) { switch (SDL_COLORSPACEMATRIX(texture->colorspace)) {
case SDL_COLOR_PRIMARIES_BT709: case SDL_MATRIX_COEFFICIENTS_BT601:
samplerYcbcrConversionCreateInfo.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR;
break;
case SDL_COLOR_PRIMARIES_BT601:
samplerYcbcrConversionCreateInfo.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR; samplerYcbcrConversionCreateInfo.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR;
break; 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; samplerYcbcrConversionCreateInfo.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR;
default: default:
VULKAN_DestroyTexture(renderer, texture); VULKAN_DestroyTexture(renderer, texture);