anv: Store depth stencil layouts

Store the current and requested depth stencil layouts so that we can
perform the appropriate HiZ resolves for a given transition while
recording a render pass.

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Nanley Chery
2017-01-02 00:44:08 -08:00
parent 2e2cf78a51
commit 104ce1dbab
3 changed files with 17 additions and 0 deletions

View File

@@ -74,6 +74,8 @@ VkResult anv_CreateRenderPass(
att->load_op = pCreateInfo->pAttachments[i].loadOp; att->load_op = pCreateInfo->pAttachments[i].loadOp;
att->store_op = pCreateInfo->pAttachments[i].storeOp; att->store_op = pCreateInfo->pAttachments[i].storeOp;
att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp; att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
att->initial_layout = pCreateInfo->pAttachments[i].initialLayout;
att->final_layout = pCreateInfo->pAttachments[i].finalLayout;
att->subpass_usage = usages; att->subpass_usage = usages;
usages += pass->subpass_count; usages += pass->subpass_count;
} }
@@ -161,6 +163,8 @@ VkResult anv_CreateRenderPass(
if (desc->pDepthStencilAttachment) { if (desc->pDepthStencilAttachment) {
uint32_t a = desc->pDepthStencilAttachment->attachment; uint32_t a = desc->pDepthStencilAttachment->attachment;
subpass->depth_stencil_attachment = a; subpass->depth_stencil_attachment = a;
subpass->depth_stencil_layout =
desc->pDepthStencilAttachment->layout;
if (a != VK_ATTACHMENT_UNUSED) { if (a != VK_ATTACHMENT_UNUSED) {
pass->attachments[a].usage |= pass->attachments[a].usage |=
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
@@ -168,6 +172,7 @@ VkResult anv_CreateRenderPass(
} }
} else { } else {
subpass->depth_stencil_attachment = VK_ATTACHMENT_UNUSED; subpass->depth_stencil_attachment = VK_ATTACHMENT_UNUSED;
subpass->depth_stencil_layout = VK_IMAGE_LAYOUT_UNDEFINED;
} }
} }

View File

@@ -1097,6 +1097,7 @@ struct anv_attachment_state {
struct anv_state color_rt_state; struct anv_state color_rt_state;
struct anv_state input_att_state; struct anv_state input_att_state;
VkImageLayout current_layout;
VkImageAspectFlags pending_clear_aspects; VkImageAspectFlags pending_clear_aspects;
bool fast_clear; bool fast_clear;
VkClearValue clear_value; VkClearValue clear_value;
@@ -1733,7 +1734,12 @@ struct anv_subpass {
uint32_t color_count; uint32_t color_count;
uint32_t * color_attachments; uint32_t * color_attachments;
uint32_t * resolve_attachments; uint32_t * resolve_attachments;
/* TODO: Consider storing the depth/stencil VkAttachmentReference
* instead of its two structure members (below) individually.
*/
uint32_t depth_stencil_attachment; uint32_t depth_stencil_attachment;
VkImageLayout depth_stencil_layout;
/** Subpass has a depth/stencil self-dependency */ /** Subpass has a depth/stencil self-dependency */
bool has_ds_self_dep; bool has_ds_self_dep;
@@ -1750,12 +1756,17 @@ enum anv_subpass_usage {
}; };
struct anv_render_pass_attachment { struct anv_render_pass_attachment {
/* TODO: Consider using VkAttachmentDescription instead of storing each of
* its members individually.
*/
VkFormat format; VkFormat format;
uint32_t samples; uint32_t samples;
VkImageUsageFlags usage; VkImageUsageFlags usage;
VkAttachmentLoadOp load_op; VkAttachmentLoadOp load_op;
VkAttachmentStoreOp store_op; VkAttachmentStoreOp store_op;
VkAttachmentLoadOp stencil_load_op; VkAttachmentLoadOp stencil_load_op;
VkImageLayout initial_layout;
VkImageLayout final_layout;
/* An array, indexed by subpass id, of how the attachment will be used. */ /* An array, indexed by subpass id, of how the attachment will be used. */
enum anv_subpass_usage * subpass_usage; enum anv_subpass_usage * subpass_usage;

View File

@@ -480,6 +480,7 @@ genX(cmd_buffer_setup_attachments)(struct anv_cmd_buffer *cmd_buffer,
} }
} }
state->attachments[i].current_layout = att->initial_layout;
state->attachments[i].pending_clear_aspects = clear_aspects; state->attachments[i].pending_clear_aspects = clear_aspects;
if (clear_aspects) if (clear_aspects)
state->attachments[i].clear_value = begin->pClearValues[i]; state->attachments[i].clear_value = begin->pClearValues[i];