anv: fix multiview for clear commands

According to the VK_KHX_multiview spec:

"Multiview causes all drawing and clear commands in the subpass to
behave as if they were broadcast to each view, where each view is
represented by one layer of the framebuffer attachments."

This adds support for multiview clears, which were missing in the
initial implementation.

v2 (Jason):
  - split multiview from regular case
  - Use for_each_bit() macro

Fixes new CTS multiview tests:
dEQP-VK.multiview.clear_attachments.*

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Iago Toral Quiroga 2017-05-18 08:23:38 +02:00
parent 70215a23c6
commit 2322ddf548
1 changed files with 41 additions and 0 deletions

View File

@ -999,6 +999,25 @@ clear_color_attachment(struct anv_cmd_buffer *cmd_buffer,
union isl_color_value clear_color =
vk_to_isl_color(attachment->clearValue.color);
/* If multiview is enabled we ignore baseArrayLayer and layerCount */
if (subpass->view_mask) {
uint32_t view_idx;
for_each_bit(view_idx, subpass->view_mask) {
for (uint32_t r = 0; r < rectCount; ++r) {
const VkOffset2D offset = pRects[r].rect.offset;
const VkExtent2D extent = pRects[r].rect.extent;
blorp_clear_attachments(batch, binding_table,
ISL_FORMAT_UNSUPPORTED, pass_att->samples,
view_idx, 1,
offset.x, offset.y,
offset.x + extent.width,
offset.y + extent.height,
true, clear_color, false, 0.0f, 0, 0);
}
}
return;
}
for (uint32_t r = 0; r < rectCount; ++r) {
const VkOffset2D offset = pRects[r].rect.offset;
const VkExtent2D extent = pRects[r].rect.extent;
@ -1047,6 +1066,28 @@ clear_depth_stencil_attachment(struct anv_cmd_buffer *cmd_buffer,
if (result != VK_SUCCESS)
return;
/* If multiview is enabled we ignore baseArrayLayer and layerCount */
if (subpass->view_mask) {
uint32_t view_idx;
for_each_bit(view_idx, subpass->view_mask) {
for (uint32_t r = 0; r < rectCount; ++r) {
const VkOffset2D offset = pRects[r].rect.offset;
const VkExtent2D extent = pRects[r].rect.extent;
VkClearDepthStencilValue value = attachment->clearValue.depthStencil;
blorp_clear_attachments(batch, binding_table,
depth_format, pass_att->samples,
view_idx, 1,
offset.x, offset.y,
offset.x + extent.width,
offset.y + extent.height,
false, color_value,
clear_depth, value.depth,
clear_stencil ? 0xff : 0, value.stencil);
}
}
return;
}
for (uint32_t r = 0; r < rectCount; ++r) {
const VkOffset2D offset = pRects[r].rect.offset;
const VkExtent2D extent = pRects[r].rect.extent;