{
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;
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));
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)
}
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;
}
}
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,
- };
}
}
* 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;
}
* 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)) {
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) {
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;
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:
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,
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;
/* 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 =
}
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);
}