From 4229b5778367364c46c35d5c5420dd16dac1b455 Mon Sep 17 00:00:00 2001 From: Aitor Camacho Date: Mon, 9 Feb 2026 21:51:48 +0900 Subject: [PATCH] wsi/metal: Expose additional color spaces if instance extension enabled Caught through VVL test NegativeWsi.SwapchainImageFormatList. The test would try to create a swapchain with a color space from VK_EXT_swapchain_colorspace without enabling the extension. This is because wsi would expose those color spaces even when the extension was not enabled. Fixes: fd045ac99ce ("wsi/metal: add support for color spaces") Reviewed-by: Yiwei Zhang Signed-off-by: Aitor Camacho (cherry picked from commit e6f118f12b9405d0562343e34a286842fc9ffc69) Part-of: --- .pick_status.json | 2 +- src/vulkan/wsi/wsi_common_metal.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 2b693261a32..d70087c3fc2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5404,7 +5404,7 @@ "description": "wsi/metal: Expose additional color spaces if instance extension enabled", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "fd045ac99cea5bea1e9e55c4381c37ad0e824352", "notes": null diff --git a/src/vulkan/wsi/wsi_common_metal.c b/src/vulkan/wsi/wsi_common_metal.c index 857de8959e1..5deaaa2a765 100644 --- a/src/vulkan/wsi/wsi_common_metal.c +++ b/src/vulkan/wsi/wsi_common_metal.c @@ -192,13 +192,18 @@ wsi_metal_surface_get_formats(VkIcdSurfaceBase *icd_surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats) { + VK_FROM_HANDLE(vk_physical_device, pdev, wsi_device->pdevice); VK_OUTARRAY_MAKE_TYPED(VkSurfaceFormatKHR, out, pSurfaceFormats, pSurfaceFormatCount); VkFormat sorted_formats[ARRAY_SIZE(available_surface_formats)]; get_sorted_vk_formats(wsi_device->force_bgra8_unorm_first, sorted_formats); + unsigned color_space_count = + pdev->instance->enabled_extensions.EXT_swapchain_colorspace + ? ARRAY_SIZE(available_surface_color_spaces) + : 1u; for (unsigned i = 0; i < ARRAY_SIZE(sorted_formats); i++) { - for (unsigned j = 0; j < ARRAY_SIZE(available_surface_color_spaces); j++) { + for (unsigned j = 0; j < color_space_count; j++) { vk_outarray_append_typed(VkSurfaceFormatKHR, &out, f) { f->format = sorted_formats[i]; f->colorSpace = available_surface_color_spaces[j]; @@ -216,13 +221,18 @@ wsi_metal_surface_get_formats2(VkIcdSurfaceBase *icd_surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormat2KHR* pSurfaceFormats) { + VK_FROM_HANDLE(vk_physical_device, pdev, wsi_device->pdevice); VK_OUTARRAY_MAKE_TYPED(VkSurfaceFormat2KHR, out, pSurfaceFormats, pSurfaceFormatCount); VkFormat sorted_formats[ARRAY_SIZE(available_surface_formats)]; get_sorted_vk_formats(wsi_device->force_bgra8_unorm_first, sorted_formats); + unsigned color_space_count = + pdev->instance->enabled_extensions.EXT_swapchain_colorspace + ? ARRAY_SIZE(available_surface_color_spaces) + : 1u; for (unsigned i = 0; i < ARRAY_SIZE(sorted_formats); i++) { - for (unsigned j = 0; j < ARRAY_SIZE(available_surface_color_spaces); j++) { + for (unsigned j = 0; j < color_space_count; j++) { vk_outarray_append_typed(VkSurfaceFormat2KHR, &out, f) { assert(f->sType == VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR); f->surfaceFormat.format = sorted_formats[i];