dzn: Pass an image view to dzn_cmd_buffer_clear_attachment()

Let the caller extract the image view from the attachment index, so
we can make this function framebuffer-agnostic and re-use it in the
dynamic rendering path.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15913>
This commit is contained in:
Boris Brezillon 2022-04-20 10:12:06 +02:00
parent 3420110ee7
commit 39851688df
1 changed files with 13 additions and 9 deletions

View File

@ -1172,7 +1172,7 @@ dzn_cmd_buffer_clear_ranges_with_copy(struct dzn_cmd_buffer *cmdbuf,
static void
dzn_cmd_buffer_clear_attachment(struct dzn_cmd_buffer *cmdbuf,
uint32_t idx,
struct dzn_image_view *view,
const VkClearValue *value,
VkImageAspectFlags aspects,
uint32_t base_layer,
@ -1180,11 +1180,8 @@ dzn_cmd_buffer_clear_attachment(struct dzn_cmd_buffer *cmdbuf,
uint32_t rect_count,
D3D12_RECT *rects)
{
if (idx == VK_ATTACHMENT_UNUSED)
return;
struct dzn_image_view *view = cmdbuf->state.framebuffer->attachments[idx];
struct dzn_image *image = container_of(view->vk.image, struct dzn_image, vk);
struct dzn_image *image =
container_of(view->vk.image, struct dzn_image, vk);
VkImageSubresourceRange range = {
.aspectMask = aspects,
@ -2120,12 +2117,17 @@ dzn_cmd_buffer_clear_attachments(struct dzn_cmd_buffer *cmdbuf,
else
idx = subpass->zs.idx;
if (idx == VK_ATTACHMENT_UNUSED)
continue;
struct dzn_image_view *view = cmdbuf->state.framebuffer->attachments[idx];
for (uint32_t j = 0; j < rect_count; j++) {
D3D12_RECT rect;
dzn_translate_rect(&rect, &rects[j].rect);
dzn_cmd_buffer_clear_attachment(cmdbuf,
idx, &attachments[i].clearValue,
dzn_cmd_buffer_clear_attachment(cmdbuf, view,
&attachments[i].clearValue,
attachments[i].aspectMask,
rects[j].baseArrayLayer,
rects[j].layerCount,
@ -3453,7 +3455,9 @@ dzn_CmdBeginRenderPass2(VkCommandBuffer commandBuffer,
aspectMask |= VK_IMAGE_ASPECT_COLOR_BIT;
}
dzn_cmd_buffer_clear_attachment(cmdbuf, i, &pRenderPassBeginInfo->pClearValues[i],
struct dzn_image_view *view = cmdbuf->state.framebuffer->attachments[i];
dzn_cmd_buffer_clear_attachment(cmdbuf, view, &pRenderPassBeginInfo->pClearValues[i],
aspectMask, 0, ~0, 1, &cmdbuf->state.render_area);
}
}