From 51f410f6217a69e2a54426c629f6084205be2300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Briano?= Date: Wed, 12 Jun 2024 16:49:12 -0700 Subject: [PATCH] vulkan/runtime: pColorAttachmentInputIndices is allowed to be NULL The Vulkan spec says: "If pColorAttachmentInputIndices is NULL, it is equivalent to setting each element to its index within the array." Fix updated dEQP-VK.dynamic_rendering.primary_cmd_buff.local_read.*. v2: Fix it correctly (Samuel) Fixes: 03490ec0195 ("vulkan/runtime: rework VK_KHR_dynamic_rendering_local_read state tracking") Reviewed-by: Samuel Pitoiset Part-of: --- src/vulkan/runtime/vk_graphics_state.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/vulkan/runtime/vk_graphics_state.c b/src/vulkan/runtime/vk_graphics_state.c index ff171dfdbdb..73be9e15a5b 100644 --- a/src/vulkan/runtime/vk_graphics_state.c +++ b/src/vulkan/runtime/vk_graphics_state.c @@ -1045,9 +1045,13 @@ vk_input_attachment_location_state_init(struct vk_input_attachment_location_stat for (uint32_t a = 0; a < MIN2(ial_info->colorAttachmentCount, MESA_VK_MAX_COLOR_ATTACHMENTS); a++) { - ial->color_map[a] = - ial_info->pColorAttachmentInputIndices[a] == VK_ATTACHMENT_UNUSED ? - MESA_VK_ATTACHMENT_UNUSED : ial_info->pColorAttachmentInputIndices[a]; + if (!ial_info->pColorAttachmentInputIndices) { + ial->color_map[a] = a; + } else if (ial_info->pColorAttachmentInputIndices[a] == VK_ATTACHMENT_UNUSED) { + ial->color_map[a] = MESA_VK_ATTACHMENT_UNUSED; + } else { + ial->color_map[a] = ial_info->pColorAttachmentInputIndices[a]; + } } ial->depth_att = ial_info->pDepthInputAttachmentIndex != NULL ? *ial_info->pDepthInputAttachmentIndex : MESA_VK_ATTACHMENT_UNUSED; @@ -3115,9 +3119,16 @@ vk_common_CmdSetRenderingInputAttachmentIndicesKHR( assert(pLocationInfo->colorAttachmentCount <= MESA_VK_MAX_COLOR_ATTACHMENTS); for (uint32_t i = 0; i < pLocationInfo->colorAttachmentCount; i++) { - uint8_t val = - pLocationInfo->pColorAttachmentInputIndices[i] == VK_ATTACHMENT_UNUSED ? - MESA_VK_ATTACHMENT_UNUSED : pLocationInfo->pColorAttachmentInputIndices[i]; + uint8_t val; + + if (!pLocationInfo->pColorAttachmentInputIndices) { + val = i; + } else if (pLocationInfo->pColorAttachmentInputIndices[i] == VK_ATTACHMENT_UNUSED) { + val = MESA_VK_ATTACHMENT_UNUSED; + } else { + val = pLocationInfo->pColorAttachmentInputIndices[i]; + } + SET_DYN_VALUE(dyn, INPUT_ATTACHMENT_MAP, ial.color_map[i], val); }