From 8e153bbd8fa6b81ecee72bc089bb42e01f5319de Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Wed, 4 Sep 2024 06:29:37 -0400 Subject: [PATCH] vulkan/state: Track the input attachment count Tilers need to know, at the very least, which input attachments are "real" input attachments which map to a color or depth/stencil attachment in tile memory and which are "fake" input attachments that should be treated as regular textures. To do this we need to know VkRenderingInputAttachmentIndexInfoKHR::colorAttachmentCount, which wasn't provided by the state tracking infrastructure. When the VkRenderingInputAttachmentIndexInfoKHR isn't provided, we don't know it, though, so we have to record a special UKNOWN value. In that case, the driver will know thanks to VUID-VkGraphicsPipelineCreateInfo-renderPass-09652 that all input attachments are "real" input attachments that map directly to color attachments if they have an InputAttachmentIndex. Part-of: --- src/vulkan/runtime/vk_graphics_state.c | 3 +++ src/vulkan/runtime/vk_graphics_state.h | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/vulkan/runtime/vk_graphics_state.c b/src/vulkan/runtime/vk_graphics_state.c index 526c6764b0d..24b9689eef3 100644 --- a/src/vulkan/runtime/vk_graphics_state.c +++ b/src/vulkan/runtime/vk_graphics_state.c @@ -1070,6 +1070,7 @@ vk_input_attachment_location_state_init(struct vk_input_attachment_location_stat { *ial = (struct vk_input_attachment_location_state) { .color_map = { 0, 1, 2, 3, 4, 5, 6, 7 }, + .color_attachment_count = MESA_VK_COLOR_ATTACHMENT_COUNT_UNKNOWN, .depth_att = MESA_VK_ATTACHMENT_UNUSED, .stencil_att = MESA_VK_ATTACHMENT_UNUSED, }; @@ -1087,6 +1088,8 @@ vk_input_attachment_location_state_init(struct vk_input_attachment_location_stat } } + ial->color_attachment_count = ial_info->colorAttachmentCount; + ial->depth_att = map_ds_input_attachment_index(ial_info->pDepthInputAttachmentIndex); ial->stencil_att = diff --git a/src/vulkan/runtime/vk_graphics_state.h b/src/vulkan/runtime/vk_graphics_state.h index 7d9ed73ce06..91684a76229 100644 --- a/src/vulkan/runtime/vk_graphics_state.h +++ b/src/vulkan/runtime/vk_graphics_state.h @@ -721,6 +721,8 @@ static_assert(MESA_VK_MAX_COLOR_ATTACHMENTS == 8, #define MESA_VK_RP_ATTACHMENT_COLOR_BIT(n) \ ((enum vk_rp_attachment_flags)(MESA_VK_RP_ATTACHMENT_COLOR_0_BIT << (n))) +#define MESA_VK_COLOR_ATTACHMENT_COUNT_UNKNOWN 0xff + /***/ struct vk_input_attachment_location_state { /** VkRenderingInputAttachmentIndexInfoKHR::pColorAttachmentLocations @@ -729,6 +731,18 @@ struct vk_input_attachment_location_state { */ uint8_t color_map[MESA_VK_MAX_COLOR_ATTACHMENTS]; + /** VkRenderingInputAttachmentIndexInfoKHR::colorAttachmentCount + * + * This must match vk_render_pass_state::color_attachment_count or be equal + * to MESA_VK_COLOR_ATTACHMENT_COUNT_UNKNOWN, in which case it can be + * assumed that there is an identity mapping and every input attachment + * with an index is a color attachment. Unlike vk_render_pass_state this + * state is available when compiling the fragment shader. + * + * MESA_VK_DYNAMIC_INPUT_ATTACHMENT_MAP + */ + uint8_t color_attachment_count; + /** VkRenderingInputAttachmentIndexInfoKHR::pDepthInputAttachmentIndex * * MESA_VK_DYNAMIC_INPUT_ATTACHMENT_MAP