vulkan: Expose a vk_cmd_set_rendering_attachment_locations() helper

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31033>
This commit is contained in:
Faith Ekstrand 2024-09-04 13:59:52 -05:00 committed by Marge Bot
parent ea783a96b8
commit 9ba70bb1ed
2 changed files with 24 additions and 9 deletions

View file

@ -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

View file

@ -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);