diff options
-rw-r--r-- | src/intel/vulkan/anv_blorp.c | 2 | ||||
-rw-r--r-- | src/intel/vulkan/anv_cmd_buffer.c | 4 | ||||
-rw-r--r-- | src/intel/vulkan/anv_pass.c | 25 | ||||
-rw-r--r-- | src/intel/vulkan/anv_pipeline.c | 4 | ||||
-rw-r--r-- | src/intel/vulkan/anv_private.h | 2 | ||||
-rw-r--r-- | src/intel/vulkan/gen7_cmd_buffer.c | 4 | ||||
-rw-r--r-- | src/intel/vulkan/genX_cmd_buffer.c | 4 | ||||
-rw-r--r-- | src/intel/vulkan/genX_pipeline.c | 8 |
8 files changed, 28 insertions, 25 deletions
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c index 8e6d7db6e40..c76392fcd97 100644 --- a/src/intel/vulkan/anv_blorp.c +++ b/src/intel/vulkan/anv_blorp.c @@ -1060,7 +1060,7 @@ clear_depth_stencil_attachment(struct anv_cmd_buffer *cmd_buffer, { static const union isl_color_value color_value = { .u32 = { 0, } }; const struct anv_subpass *subpass = cmd_buffer->state.subpass; - const uint32_t att_idx = subpass->depth_stencil_attachment.attachment; + const uint32_t att_idx = subpass->depth_stencil_attachment->attachment; if (att_idx == VK_ATTACHMENT_UNUSED) return; diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c index 70a0718e3b9..201b73ad45a 100644 --- a/src/intel/vulkan/anv_cmd_buffer.c +++ b/src/intel/vulkan/anv_cmd_buffer.c @@ -916,11 +916,11 @@ anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer) const struct anv_subpass *subpass = cmd_buffer->state.subpass; const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer; - if (subpass->depth_stencil_attachment.attachment == VK_ATTACHMENT_UNUSED) + if (subpass->depth_stencil_attachment == NULL) return NULL; const struct anv_image_view *iview = - fb->attachments[subpass->depth_stencil_attachment.attachment]; + fb->attachments[subpass->depth_stencil_attachment->attachment]; assert(iview->aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)); diff --git a/src/intel/vulkan/anv_pass.c b/src/intel/vulkan/anv_pass.c index cb5e4bb7b79..cb73359af79 100644 --- a/src/intel/vulkan/anv_pass.c +++ b/src/intel/vulkan/anv_pass.c @@ -66,6 +66,14 @@ anv_render_pass_compile(struct anv_render_pass *pass) for (uint32_t i = 0; i < pass->subpass_count; i++) { struct anv_subpass *subpass = &pass->subpasses[i]; + /* We don't allow depth_stencil_attachment to be non-NULL and be + * VK_ATTACHMENT_UNUSED. This way something can just check for NULL + * and be guaranteed that they have a valid attachment. + */ + if (subpass->depth_stencil_attachment && + subpass->depth_stencil_attachment->attachment == VK_ATTACHMENT_UNUSED) + subpass->depth_stencil_attachment = NULL; + for (uint32_t j = 0; j < subpass->attachment_count; j++) { struct anv_subpass_attachment *subpass_att = &subpass->attachments[j]; if (subpass_att->attachment == VK_ATTACHMENT_UNUSED) @@ -86,7 +94,8 @@ anv_render_pass_compile(struct anv_render_pass *pass) } if (subpass_att->usage == VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT && - subpass_att->attachment == subpass->depth_stencil_attachment.attachment) + subpass->depth_stencil_attachment && + subpass_att->attachment == subpass->depth_stencil_attachment->attachment) subpass->has_ds_self_dep = true; } @@ -283,18 +292,13 @@ VkResult anv_CreateRenderPass( } if (desc->pDepthStencilAttachment) { - subpass->depth_stencil_attachment = (struct anv_subpass_attachment) { + subpass->depth_stencil_attachment = subpass_attachments++; + + *subpass->depth_stencil_attachment = (struct anv_subpass_attachment) { .usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, .attachment = desc->pDepthStencilAttachment->attachment, .layout = desc->pDepthStencilAttachment->layout, }; - *subpass_attachments++ = subpass->depth_stencil_attachment; - } else { - subpass->depth_stencil_attachment = (struct anv_subpass_attachment) { - .usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, - .attachment = VK_ATTACHMENT_UNUSED, - .layout = VK_IMAGE_LAYOUT_UNDEFINED, - }; } } @@ -357,8 +361,7 @@ void anv_GetRenderAreaGranularity( * for all sample counts. */ for (unsigned i = 0; i < pass->subpass_count; ++i) { - if (pass->subpasses[i].depth_stencil_attachment.attachment != - VK_ATTACHMENT_UNUSED) { + if (pass->subpasses[i].depth_stencil_attachment) { *pGranularity = (VkExtent2D) { .width = 8, .height = 4 }; return; } diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 2a36f2e6bc1..b0c9c3422a5 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -1173,7 +1173,7 @@ copy_non_dynamic_state(struct anv_pipeline *pipeline, * against does not use a depth/stencil attachment. */ if (!pCreateInfo->pRasterizationState->rasterizerDiscardEnable && - subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) { + subpass->depth_stencil_attachment) { assert(pCreateInfo->pDepthStencilState); if (states & (1 << VK_DYNAMIC_STATE_DEPTH_BOUNDS)) { @@ -1234,7 +1234,7 @@ anv_pipeline_validate_create_info(const VkGraphicsPipelineCreateInfo *info) assert(info->pViewportState); assert(info->pMultisampleState); - if (subpass && subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) + if (subpass && subpass->depth_stencil_attachment) assert(info->pDepthStencilState); if (subpass && subpass->color_count > 0) { diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 4a26b1d3096..1763b81fbc2 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -3146,7 +3146,7 @@ struct anv_subpass { struct anv_subpass_attachment * color_attachments; struct anv_subpass_attachment * resolve_attachments; - struct anv_subpass_attachment depth_stencil_attachment; + struct anv_subpass_attachment * depth_stencil_attachment; uint32_t view_mask; diff --git a/src/intel/vulkan/gen7_cmd_buffer.c b/src/intel/vulkan/gen7_cmd_buffer.c index aa4dcde46b9..3acfbb710c0 100644 --- a/src/intel/vulkan/gen7_cmd_buffer.c +++ b/src/intel/vulkan/gen7_cmd_buffer.c @@ -127,11 +127,11 @@ get_depth_format(struct anv_cmd_buffer *cmd_buffer) const struct anv_render_pass *pass = cmd_buffer->state.pass; const struct anv_subpass *subpass = cmd_buffer->state.subpass; - if (subpass->depth_stencil_attachment.attachment >= pass->attachment_count) + if (!subpass->depth_stencil_attachment) return D16_UNORM; struct anv_render_pass_attachment *att = - &pass->attachments[subpass->depth_stencil_attachment.attachment]; + &pass->attachments[subpass->depth_stencil_attachment->attachment]; switch (att->format) { case VK_FORMAT_D16_UNORM: diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 6832bb669f8..fbe4bf72815 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -1372,7 +1372,7 @@ genX(BeginCommandBuffer)( if (iview) { VkImageLayout layout = - cmd_buffer->state.subpass->depth_stencil_attachment.layout; + cmd_buffer->state.subpass->depth_stencil_attachment->layout; enum isl_aux_usage aux_usage = anv_layout_to_aux_usage(&cmd_buffer->device->info, iview->image, @@ -3417,7 +3417,7 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) surface->offset); const uint32_t ds = - cmd_buffer->state.subpass->depth_stencil_attachment.attachment; + cmd_buffer->state.subpass->depth_stencil_attachment->attachment; info.hiz_usage = cmd_buffer->state.attachments[ds].aux_usage; if (info.hiz_usage == ISL_AUX_USAGE_HIZ) { info.hiz_surf = &image->planes[depth_plane].aux_surface.isl; diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c index 3e9c4bbc21e..70097e46285 100644 --- a/src/intel/vulkan/genX_pipeline.c +++ b/src/intel/vulkan/genX_pipeline.c @@ -499,9 +499,9 @@ emit_rs_state(struct anv_pipeline *pipeline, /* Gen7 requires that we provide the depth format in 3DSTATE_SF so that it * can get the depth offsets correct. */ - if (subpass->depth_stencil_attachment.attachment < pass->attachment_count) { + if (subpass->depth_stencil_attachment) { VkFormat vk_format = - pass->attachments[subpass->depth_stencil_attachment.attachment].format; + pass->attachments[subpass->depth_stencil_attachment->attachment].format; assert(vk_format_is_depth_or_stencil(vk_format)); if (vk_format_aspects(vk_format) & VK_IMAGE_ASPECT_DEPTH_BIT) { enum isl_format isl_format = @@ -816,9 +816,9 @@ emit_ds_state(struct anv_pipeline *pipeline, } VkImageAspectFlags ds_aspects = 0; - if (subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) { + if (subpass->depth_stencil_attachment) { VkFormat depth_stencil_format = - pass->attachments[subpass->depth_stencil_attachment.attachment].format; + pass->attachments[subpass->depth_stencil_attachment->attachment].format; ds_aspects = vk_format_aspects(depth_stencil_format); } |