mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 17:40:11 +01:00
anv: Make subpass::depth_stencil_attachment a pointer
This makes certain checks a bit easier and means that we don't have the attachment information duplicated in the attachment list and in depth_stencil_attachment. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
parent
75e308fc44
commit
208be8eafa
8 changed files with 28 additions and 25 deletions
|
|
@ -1060,7 +1060,7 @@ clear_depth_stencil_attachment(struct anv_cmd_buffer *cmd_buffer,
|
||||||
{
|
{
|
||||||
static const union isl_color_value color_value = { .u32 = { 0, } };
|
static const union isl_color_value color_value = { .u32 = { 0, } };
|
||||||
const struct anv_subpass *subpass = cmd_buffer->state.subpass;
|
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)
|
if (att_idx == VK_ATTACHMENT_UNUSED)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -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_subpass *subpass = cmd_buffer->state.subpass;
|
||||||
const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
|
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;
|
return NULL;
|
||||||
|
|
||||||
const struct anv_image_view *iview =
|
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 |
|
assert(iview->aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT |
|
||||||
VK_IMAGE_ASPECT_STENCIL_BIT));
|
VK_IMAGE_ASPECT_STENCIL_BIT));
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,14 @@ anv_render_pass_compile(struct anv_render_pass *pass)
|
||||||
for (uint32_t i = 0; i < pass->subpass_count; i++) {
|
for (uint32_t i = 0; i < pass->subpass_count; i++) {
|
||||||
struct anv_subpass *subpass = &pass->subpasses[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++) {
|
for (uint32_t j = 0; j < subpass->attachment_count; j++) {
|
||||||
struct anv_subpass_attachment *subpass_att = &subpass->attachments[j];
|
struct anv_subpass_attachment *subpass_att = &subpass->attachments[j];
|
||||||
if (subpass_att->attachment == VK_ATTACHMENT_UNUSED)
|
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 &&
|
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;
|
subpass->has_ds_self_dep = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -283,18 +292,13 @@ VkResult anv_CreateRenderPass(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc->pDepthStencilAttachment) {
|
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,
|
.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||||
.attachment = desc->pDepthStencilAttachment->attachment,
|
.attachment = desc->pDepthStencilAttachment->attachment,
|
||||||
.layout = desc->pDepthStencilAttachment->layout,
|
.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 all sample counts.
|
||||||
*/
|
*/
|
||||||
for (unsigned i = 0; i < pass->subpass_count; ++i) {
|
for (unsigned i = 0; i < pass->subpass_count; ++i) {
|
||||||
if (pass->subpasses[i].depth_stencil_attachment.attachment !=
|
if (pass->subpasses[i].depth_stencil_attachment) {
|
||||||
VK_ATTACHMENT_UNUSED) {
|
|
||||||
*pGranularity = (VkExtent2D) { .width = 8, .height = 4 };
|
*pGranularity = (VkExtent2D) { .width = 8, .height = 4 };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1173,7 +1173,7 @@ copy_non_dynamic_state(struct anv_pipeline *pipeline,
|
||||||
* against does not use a depth/stencil attachment.
|
* against does not use a depth/stencil attachment.
|
||||||
*/
|
*/
|
||||||
if (!pCreateInfo->pRasterizationState->rasterizerDiscardEnable &&
|
if (!pCreateInfo->pRasterizationState->rasterizerDiscardEnable &&
|
||||||
subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) {
|
subpass->depth_stencil_attachment) {
|
||||||
assert(pCreateInfo->pDepthStencilState);
|
assert(pCreateInfo->pDepthStencilState);
|
||||||
|
|
||||||
if (states & (1 << VK_DYNAMIC_STATE_DEPTH_BOUNDS)) {
|
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->pViewportState);
|
||||||
assert(info->pMultisampleState);
|
assert(info->pMultisampleState);
|
||||||
|
|
||||||
if (subpass && subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED)
|
if (subpass && subpass->depth_stencil_attachment)
|
||||||
assert(info->pDepthStencilState);
|
assert(info->pDepthStencilState);
|
||||||
|
|
||||||
if (subpass && subpass->color_count > 0) {
|
if (subpass && subpass->color_count > 0) {
|
||||||
|
|
|
||||||
|
|
@ -3146,7 +3146,7 @@ struct anv_subpass {
|
||||||
struct anv_subpass_attachment * color_attachments;
|
struct anv_subpass_attachment * color_attachments;
|
||||||
struct anv_subpass_attachment * resolve_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;
|
uint32_t view_mask;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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_render_pass *pass = cmd_buffer->state.pass;
|
||||||
const struct anv_subpass *subpass = cmd_buffer->state.subpass;
|
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;
|
return D16_UNORM;
|
||||||
|
|
||||||
struct anv_render_pass_attachment *att =
|
struct anv_render_pass_attachment *att =
|
||||||
&pass->attachments[subpass->depth_stencil_attachment.attachment];
|
&pass->attachments[subpass->depth_stencil_attachment->attachment];
|
||||||
|
|
||||||
switch (att->format) {
|
switch (att->format) {
|
||||||
case VK_FORMAT_D16_UNORM:
|
case VK_FORMAT_D16_UNORM:
|
||||||
|
|
|
||||||
|
|
@ -1372,7 +1372,7 @@ genX(BeginCommandBuffer)(
|
||||||
|
|
||||||
if (iview) {
|
if (iview) {
|
||||||
VkImageLayout layout =
|
VkImageLayout layout =
|
||||||
cmd_buffer->state.subpass->depth_stencil_attachment.layout;
|
cmd_buffer->state.subpass->depth_stencil_attachment->layout;
|
||||||
|
|
||||||
enum isl_aux_usage aux_usage =
|
enum isl_aux_usage aux_usage =
|
||||||
anv_layout_to_aux_usage(&cmd_buffer->device->info, iview->image,
|
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);
|
surface->offset);
|
||||||
|
|
||||||
const uint32_t ds =
|
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;
|
info.hiz_usage = cmd_buffer->state.attachments[ds].aux_usage;
|
||||||
if (info.hiz_usage == ISL_AUX_USAGE_HIZ) {
|
if (info.hiz_usage == ISL_AUX_USAGE_HIZ) {
|
||||||
info.hiz_surf = &image->planes[depth_plane].aux_surface.isl;
|
info.hiz_surf = &image->planes[depth_plane].aux_surface.isl;
|
||||||
|
|
|
||||||
|
|
@ -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
|
/* Gen7 requires that we provide the depth format in 3DSTATE_SF so that it
|
||||||
* can get the depth offsets correct.
|
* can get the depth offsets correct.
|
||||||
*/
|
*/
|
||||||
if (subpass->depth_stencil_attachment.attachment < pass->attachment_count) {
|
if (subpass->depth_stencil_attachment) {
|
||||||
VkFormat vk_format =
|
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));
|
assert(vk_format_is_depth_or_stencil(vk_format));
|
||||||
if (vk_format_aspects(vk_format) & VK_IMAGE_ASPECT_DEPTH_BIT) {
|
if (vk_format_aspects(vk_format) & VK_IMAGE_ASPECT_DEPTH_BIT) {
|
||||||
enum isl_format isl_format =
|
enum isl_format isl_format =
|
||||||
|
|
@ -816,9 +816,9 @@ emit_ds_state(struct anv_pipeline *pipeline,
|
||||||
}
|
}
|
||||||
|
|
||||||
VkImageAspectFlags ds_aspects = 0;
|
VkImageAspectFlags ds_aspects = 0;
|
||||||
if (subpass->depth_stencil_attachment.attachment != VK_ATTACHMENT_UNUSED) {
|
if (subpass->depth_stencil_attachment) {
|
||||||
VkFormat depth_stencil_format =
|
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);
|
ds_aspects = vk_format_aspects(depth_stencil_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue