summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2019-12-09 13:56:24 +0100
committerSamuel Pitoiset <[email protected]>2019-12-10 13:16:17 +0100
commite4c8491bdf8a1238d475491533d937568019e633 (patch)
treefa3e11a03e6edd5d935ac13f221cfd9eb8417567 /src
parent48ee62178f42690d061b3ce85da364c9bb4149fb (diff)
radv: implement VK_KHR_separate_depth_stencil_layouts
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/amd/vulkan/radv_cmd_buffer.c50
-rw-r--r--src/amd/vulkan/radv_device.c6
-rw-r--r--src/amd/vulkan/radv_extensions.py1
-rw-r--r--src/amd/vulkan/radv_image.c4
-rw-r--r--src/amd/vulkan/radv_pass.c35
-rw-r--r--src/amd/vulkan/radv_private.h4
6 files changed, 93 insertions, 7 deletions
diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index bbbb190394c..0c62eacf05c 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -2974,14 +2974,48 @@ static void radv_handle_subpass_image_transition(struct radv_cmd_buffer *cmd_buf
sample_locs = radv_get_attachment_sample_locations(cmd_buffer, idx,
begin_subpass);
- radv_handle_image_transition(cmd_buffer,
- view->image,
- cmd_buffer->state.attachments[idx].current_layout,
- cmd_buffer->state.attachments[idx].current_in_render_loop,
- att.layout, att.in_render_loop,
- 0, 0, &range, sample_locs);
+ /* Determine if the subpass uses separate depth/stencil layouts. */
+ bool uses_separate_depth_stencil_layouts = false;
+ if ((cmd_buffer->state.attachments[idx].current_layout !=
+ cmd_buffer->state.attachments[idx].current_stencil_layout) ||
+ (att.layout != att.stencil_layout)) {
+ uses_separate_depth_stencil_layouts = true;
+ }
+
+ /* For separate layouts, perform depth and stencil transitions
+ * separately.
+ */
+ if (uses_separate_depth_stencil_layouts &&
+ (range.aspectMask == (VK_IMAGE_ASPECT_DEPTH_BIT |
+ VK_IMAGE_ASPECT_STENCIL_BIT))) {
+ /* Depth-only transitions. */
+ range.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
+ radv_handle_image_transition(cmd_buffer,
+ view->image,
+ cmd_buffer->state.attachments[idx].current_layout,
+ cmd_buffer->state.attachments[idx].current_in_render_loop,
+ att.layout, att.in_render_loop,
+ 0, 0, &range, sample_locs);
+
+ /* Stencil-only transitions. */
+ range.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT;
+ radv_handle_image_transition(cmd_buffer,
+ view->image,
+ cmd_buffer->state.attachments[idx].current_stencil_layout,
+ cmd_buffer->state.attachments[idx].current_in_render_loop,
+ att.stencil_layout, att.in_render_loop,
+ 0, 0, &range, sample_locs);
+ } else {
+ radv_handle_image_transition(cmd_buffer,
+ view->image,
+ cmd_buffer->state.attachments[idx].current_layout,
+ cmd_buffer->state.attachments[idx].current_in_render_loop,
+ att.layout, att.in_render_loop,
+ 0, 0, &range, sample_locs);
+ }
cmd_buffer->state.attachments[idx].current_layout = att.layout;
+ cmd_buffer->state.attachments[idx].current_stencil_layout = att.stencil_layout;
cmd_buffer->state.attachments[idx].current_in_render_loop = att.in_render_loop;
@@ -3138,6 +3172,7 @@ radv_cmd_state_setup_attachments(struct radv_cmd_buffer *cmd_buffer,
}
state->attachments[i].current_layout = att->initial_layout;
+ state->attachments[i].current_stencil_layout = att->stencil_initial_layout;
state->attachments[i].sample_location.count = 0;
struct radv_image_view *iview;
@@ -4218,7 +4253,8 @@ radv_cmd_buffer_end_subpass(struct radv_cmd_buffer *cmd_buffer)
continue;
VkImageLayout layout = state->pass->attachments[a].final_layout;
- struct radv_subpass_attachment att = { a, layout };
+ VkImageLayout stencil_layout = state->pass->attachments[a].stencil_final_layout;
+ struct radv_subpass_attachment att = { a, layout, stencil_layout };
radv_handle_subpass_image_transition(cmd_buffer, att, false);
}
}
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index fe8430e7ac5..2a65fb9cc3a 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -1192,6 +1192,12 @@ void radv_GetPhysicalDeviceFeatures2(
features->shaderSubgroupExtendedTypes = true;
break;
}
+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR: {
+ VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *features =
+ (VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *)ext;
+ features->separateDepthStencilLayouts = true;
+ break;
+ }
default:
break;
}
diff --git a/src/amd/vulkan/radv_extensions.py b/src/amd/vulkan/radv_extensions.py
index f49f34fb9ed..2a1d50f1254 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -87,6 +87,7 @@ EXTENSIONS = [
Extension('VK_KHR_relaxed_block_layout', 1, True),
Extension('VK_KHR_sampler_mirror_clamp_to_edge', 1, True),
Extension('VK_KHR_sampler_ycbcr_conversion', 1, True),
+ Extension('VK_KHR_separate_depth_stencil_layouts', 1, True),
Extension('VK_KHR_shader_atomic_int64', 1, 'LLVM_VERSION_MAJOR >= 9'),
Extension('VK_KHR_shader_clock', 1, True),
Extension('VK_KHR_shader_draw_parameters', 1, True),
diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index fcdab593937..520d078e4a9 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -1757,6 +1757,8 @@ bool radv_layout_has_htile(const struct radv_image *image,
return radv_image_has_htile(image) &&
(layout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL ||
+ layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL_KHR ||
+ layout == VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR ||
(layout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL &&
queue_mask == (1u << RADV_QUEUE_GENERAL)));
}
@@ -1771,6 +1773,8 @@ bool radv_layout_is_htile_compressed(const struct radv_image *image,
return radv_image_has_htile(image) &&
(layout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL ||
+ layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL_KHR ||
+ layout == VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR ||
(layout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL &&
queue_mask == (1u << RADV_QUEUE_GENERAL)));
}
diff --git a/src/amd/vulkan/radv_pass.c b/src/amd/vulkan/radv_pass.c
index 2b60a25535a..c47720213a8 100644
--- a/src/amd/vulkan/radv_pass.c
+++ b/src/amd/vulkan/radv_pass.c
@@ -226,6 +226,8 @@ VkResult radv_CreateRenderPass(
att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
att->initial_layout = pCreateInfo->pAttachments[i].initialLayout;
att->final_layout = pCreateInfo->pAttachments[i].finalLayout;
+ att->stencil_initial_layout = pCreateInfo->pAttachments[i].initialLayout;
+ att->stencil_final_layout = pCreateInfo->pAttachments[i].finalLayout;
// att->store_op = pCreateInfo->pAttachments[i].storeOp;
// att->stencil_store_op = pCreateInfo->pAttachments[i].stencilStoreOp;
}
@@ -269,6 +271,7 @@ VkResult radv_CreateRenderPass(
subpass->input_attachments[j] = (struct radv_subpass_attachment) {
.attachment = desc->pInputAttachments[j].attachment,
.layout = desc->pInputAttachments[j].layout,
+ .stencil_layout = desc->pInputAttachments[j].layout,
};
}
}
@@ -293,6 +296,7 @@ VkResult radv_CreateRenderPass(
subpass->resolve_attachments[j] = (struct radv_subpass_attachment) {
.attachment = desc->pResolveAttachments[j].attachment,
.layout = desc->pResolveAttachments[j].layout,
+ .stencil_layout = desc->pResolveAttachments[j].layout,
};
}
}
@@ -303,6 +307,7 @@ VkResult radv_CreateRenderPass(
*subpass->depth_stencil_attachment = (struct radv_subpass_attachment) {
.attachment = desc->pDepthStencilAttachment->attachment,
.layout = desc->pDepthStencilAttachment->layout,
+ .stencil_layout = desc->pDepthStencilAttachment->layout,
};
}
}
@@ -372,6 +377,9 @@ VkResult radv_CreateRenderPass2KHR(
for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
struct radv_render_pass_attachment *att = &pass->attachments[i];
+ const VkAttachmentDescriptionStencilLayoutKHR *stencil_layout =
+ vk_find_struct_const(pCreateInfo->pAttachments[i].pNext,
+ ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR);
att->format = pCreateInfo->pAttachments[i].format;
att->samples = pCreateInfo->pAttachments[i].samples;
@@ -379,6 +387,12 @@ VkResult radv_CreateRenderPass2KHR(
att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
att->initial_layout = pCreateInfo->pAttachments[i].initialLayout;
att->final_layout = pCreateInfo->pAttachments[i].finalLayout;
+ att->stencil_initial_layout = (stencil_layout ?
+ stencil_layout->stencilInitialLayout :
+ pCreateInfo->pAttachments[i].initialLayout);
+ att->stencil_final_layout = (stencil_layout ?
+ stencil_layout->stencilFinalLayout :
+ pCreateInfo->pAttachments[i].finalLayout);
// att->store_op = pCreateInfo->pAttachments[i].storeOp;
// att->stencil_store_op = pCreateInfo->pAttachments[i].stencilStoreOp;
}
@@ -417,9 +431,16 @@ VkResult radv_CreateRenderPass2KHR(
p += desc->inputAttachmentCount;
for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
+ const VkAttachmentReferenceStencilLayoutKHR *stencil_attachment =
+ vk_find_struct_const(desc->pInputAttachments[j].pNext,
+ ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR);
+
subpass->input_attachments[j] = (struct radv_subpass_attachment) {
.attachment = desc->pInputAttachments[j].attachment,
.layout = desc->pInputAttachments[j].layout,
+ .stencil_layout = (stencil_attachment ?
+ stencil_attachment->stencilLayout :
+ desc->pInputAttachments[j].layout),
};
}
}
@@ -451,9 +472,16 @@ VkResult radv_CreateRenderPass2KHR(
if (desc->pDepthStencilAttachment) {
subpass->depth_stencil_attachment = p++;
+ const VkAttachmentReferenceStencilLayoutKHR *stencil_attachment =
+ vk_find_struct_const(desc->pDepthStencilAttachment->pNext,
+ ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR);
+
*subpass->depth_stencil_attachment = (struct radv_subpass_attachment) {
.attachment = desc->pDepthStencilAttachment->attachment,
.layout = desc->pDepthStencilAttachment->layout,
+ .stencil_layout = (stencil_attachment ?
+ stencil_attachment->stencilLayout :
+ desc->pDepthStencilAttachment->layout),
};
}
@@ -464,9 +492,16 @@ VkResult radv_CreateRenderPass2KHR(
if (ds_resolve && ds_resolve->pDepthStencilResolveAttachment) {
subpass->ds_resolve_attachment = p++;
+ const VkAttachmentReferenceStencilLayoutKHR *stencil_resolve_attachment =
+ vk_find_struct_const(ds_resolve->pDepthStencilResolveAttachment->pNext,
+ ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR);
+
*subpass->ds_resolve_attachment = (struct radv_subpass_attachment) {
.attachment = ds_resolve->pDepthStencilResolveAttachment->attachment,
.layout = ds_resolve->pDepthStencilResolveAttachment->layout,
+ .stencil_layout = (stencil_resolve_attachment ?
+ stencil_resolve_attachment->stencilLayout :
+ ds_resolve->pDepthStencilResolveAttachment->layout),
};
subpass->depth_resolve_mode = ds_resolve->depthResolveMode;
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 1e15de10924..1be61679d8a 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -1195,6 +1195,7 @@ struct radv_attachment_state {
uint32_t cleared_views;
VkClearValue clear_value;
VkImageLayout current_layout;
+ VkImageLayout current_stencil_layout;
bool current_in_render_loop;
struct radv_sample_locations_state sample_location;
@@ -2128,6 +2129,7 @@ void radv_subpass_barrier(struct radv_cmd_buffer *cmd_buffer,
struct radv_subpass_attachment {
uint32_t attachment;
VkImageLayout layout;
+ VkImageLayout stencil_layout;
bool in_render_loop;
};
@@ -2167,6 +2169,8 @@ struct radv_render_pass_attachment {
VkAttachmentLoadOp stencil_load_op;
VkImageLayout initial_layout;
VkImageLayout final_layout;
+ VkImageLayout stencil_initial_layout;
+ VkImageLayout stencil_final_layout;
/* The subpass id in which the attachment will be used first/last. */
uint32_t first_subpass_idx;