diff --git a/src/vulkan/runtime/vk_graphics_state.c b/src/vulkan/runtime/vk_graphics_state.c index 416230a328f..25d955d6d39 100644 --- a/src/vulkan/runtime/vk_graphics_state.c +++ b/src/vulkan/runtime/vk_graphics_state.c @@ -3093,22 +3093,30 @@ vk_common_CmdSetDepthBias2EXT( } } +void +vk_cmd_set_rendering_attachment_locations(struct vk_command_buffer *cmd, + const VkRenderingAttachmentLocationInfoKHR *info) +{ + struct vk_dynamic_graphics_state *dyn = &cmd->dynamic_graphics_state; + + assert(info->colorAttachmentCount <= MESA_VK_MAX_COLOR_ATTACHMENTS); + for (uint32_t i = 0; i < info->colorAttachmentCount; i++) { + const uint8_t val = + info->pColorAttachmentLocations == NULL ? i : + info->pColorAttachmentLocations[i] == VK_ATTACHMENT_UNUSED ? + MESA_VK_ATTACHMENT_UNUSED : info->pColorAttachmentLocations[i]; + SET_DYN_VALUE(dyn, COLOR_ATTACHMENT_MAP, cal.color_map[i], val); + } +} + VKAPI_ATTR void VKAPI_CALL vk_common_CmdSetRenderingAttachmentLocationsKHR( VkCommandBuffer commandBuffer, const VkRenderingAttachmentLocationInfoKHR* pLocationInfo) { VK_FROM_HANDLE(vk_command_buffer, cmd, commandBuffer); - struct vk_dynamic_graphics_state *dyn = &cmd->dynamic_graphics_state; - assert(pLocationInfo->colorAttachmentCount <= MESA_VK_MAX_COLOR_ATTACHMENTS); - for (uint32_t i = 0; i < pLocationInfo->colorAttachmentCount; i++) { - uint8_t val = - pLocationInfo->pColorAttachmentLocations == NULL ? i : - pLocationInfo->pColorAttachmentLocations[i] == VK_ATTACHMENT_UNUSED ? - MESA_VK_ATTACHMENT_UNUSED : pLocationInfo->pColorAttachmentLocations[i]; - SET_DYN_VALUE(dyn, COLOR_ATTACHMENT_MAP, cal.color_map[i], val); - } + vk_cmd_set_rendering_attachment_locations(cmd, pLocationInfo); } VKAPI_ATTR void VKAPI_CALL diff --git a/src/vulkan/runtime/vk_graphics_state.h b/src/vulkan/runtime/vk_graphics_state.h index 3e8bb5fe37d..008ef4e1461 100644 --- a/src/vulkan/runtime/vk_graphics_state.h +++ b/src/vulkan/runtime/vk_graphics_state.h @@ -1248,6 +1248,13 @@ void vk_cmd_set_rp_attachments(struct vk_command_buffer *cmd, enum vk_rp_attachment_flags attachments); +/* This is equivalent to CmdSetRenderingAttachmentLocationsKHR() but easier to + * invoke from inside drivers. + */ +void +vk_cmd_set_rendering_attachment_locations(struct vk_command_buffer *cmd, + const VkRenderingAttachmentLocationInfoKHR *info); + const char * vk_dynamic_graphic_state_to_str(enum mesa_vk_dynamic_graphics_state state);