Mesa (main): radv: convert the meta depth decompression path to dynamic rendering
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Apr 1 07:01:28 UTC 2022
Module: Mesa
Branch: main
Commit: 70e663aa215c590e0015f936631436a6b6ecc107
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=70e663aa215c590e0015f936631436a6b6ecc107
Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date: Wed Mar 16 16:07:58 2022 +0100
radv: convert the meta depth decompression path to dynamic rendering
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15612>
---
src/amd/vulkan/radv_meta_decompress.c | 167 ++++++++++------------------------
src/amd/vulkan/radv_private.h | 1 -
2 files changed, 46 insertions(+), 122 deletions(-)
diff --git a/src/amd/vulkan/radv_meta_decompress.c b/src/amd/vulkan/radv_meta_decompress.c
index cb70e569e92..0df3d9476a7 100644
--- a/src/amd/vulkan/radv_meta_decompress.c
+++ b/src/amd/vulkan/radv_meta_decompress.c
@@ -148,74 +148,6 @@ cleanup:
return result;
}
-static VkResult
-create_pass(struct radv_device *device, uint32_t samples, VkRenderPass *pass)
-{
- VkResult result;
- VkDevice device_h = radv_device_to_handle(device);
- const VkAllocationCallbacks *alloc = &device->meta_state.alloc;
- VkAttachmentDescription2 attachment;
-
- attachment.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2;
- attachment.pNext = NULL;
- attachment.flags = 0;
- attachment.format = VK_FORMAT_D32_SFLOAT_S8_UINT;
- attachment.samples = samples;
- attachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
- attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
- attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
- attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
- attachment.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
- attachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
-
- result = radv_CreateRenderPass2(
- device_h,
- &(VkRenderPassCreateInfo2){
- .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2,
- .attachmentCount = 1,
- .pAttachments = &attachment,
- .subpassCount = 1,
- .pSubpasses =
- &(VkSubpassDescription2){
- .sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2,
- .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
- .inputAttachmentCount = 0,
- .colorAttachmentCount = 0,
- .pColorAttachments = NULL,
- .pResolveAttachments = NULL,
- .pDepthStencilAttachment =
- &(VkAttachmentReference2){
- .sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2,
- .attachment = 0,
- .layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
- },
- .preserveAttachmentCount = 0,
- .pPreserveAttachments = NULL,
- },
- .dependencyCount = 2,
- .pDependencies =
- (VkSubpassDependency2[]){{.sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2,
- .srcSubpass = VK_SUBPASS_EXTERNAL,
- .dstSubpass = 0,
- .srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
- .dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
- .srcAccessMask = 0,
- .dstAccessMask = 0,
- .dependencyFlags = 0},
- {.sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2,
- .srcSubpass = 0,
- .dstSubpass = VK_SUBPASS_EXTERNAL,
- .srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
- .dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
- .srcAccessMask = 0,
- .dstAccessMask = 0,
- .dependencyFlags = 0}},
- },
- alloc, pass);
-
- return result;
-}
-
static VkResult
create_pipeline_layout(struct radv_device *device, VkPipelineLayout *layout)
{
@@ -232,8 +164,8 @@ create_pipeline_layout(struct radv_device *device, VkPipelineLayout *layout)
}
static VkResult
-create_pipeline(struct radv_device *device, uint32_t samples, VkRenderPass pass,
- VkPipelineLayout layout, enum radv_depth_op op, VkPipeline *pipeline)
+create_pipeline(struct radv_device *device, uint32_t samples, VkPipelineLayout layout,
+ enum radv_depth_op op, VkPipeline *pipeline)
{
VkResult result;
VkDevice device_h = radv_device_to_handle(device);
@@ -258,8 +190,15 @@ create_pipeline(struct radv_device *device, uint32_t samples, VkRenderPass pass,
.sampleLocationsEnable = false,
};
+ const VkPipelineRenderingCreateInfo rendering_create_info = {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
+ .depthAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT,
+ .stencilAttachmentFormat = VK_FORMAT_D32_SFLOAT_S8_UINT,
+ };
+
const VkGraphicsPipelineCreateInfo pipeline_create_info = {
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
+ .pNext = &rendering_create_info,
.stageCount = 2,
.pStages =
(VkPipelineShaderStageCreateInfo[]){
@@ -340,7 +279,7 @@ create_pipeline(struct radv_device *device, uint32_t samples, VkRenderPass pass,
},
},
.layout = layout,
- .renderPass = pass,
+ .renderPass = VK_NULL_HANDLE,
.subpass = 0,
};
@@ -368,8 +307,6 @@ radv_device_finish_meta_depth_decomp_state(struct radv_device *device)
struct radv_meta_state *state = &device->meta_state;
for (uint32_t i = 0; i < ARRAY_SIZE(state->depth_decomp); ++i) {
- radv_DestroyRenderPass(radv_device_to_handle(device), state->depth_decomp[i].pass,
- &state->alloc);
radv_DestroyPipelineLayout(radv_device_to_handle(device), state->depth_decomp[i].p_layout,
&state->alloc);
@@ -396,10 +333,6 @@ radv_device_init_meta_depth_decomp_state(struct radv_device *device, bool on_dem
for (uint32_t i = 0; i < ARRAY_SIZE(state->depth_decomp); ++i) {
uint32_t samples = 1 << i;
- res = create_pass(device, samples, &state->depth_decomp[i].pass);
- if (res != VK_SUCCESS)
- goto fail;
-
res = create_pipeline_layout(device, &state->depth_decomp[i].p_layout);
if (res != VK_SUCCESS)
goto fail;
@@ -407,14 +340,12 @@ radv_device_init_meta_depth_decomp_state(struct radv_device *device, bool on_dem
if (on_demand)
continue;
- res = create_pipeline(device, samples, state->depth_decomp[i].pass,
- state->depth_decomp[i].p_layout, DEPTH_DECOMPRESS,
+ res = create_pipeline(device, samples, state->depth_decomp[i].p_layout, DEPTH_DECOMPRESS,
&state->depth_decomp[i].decompress_pipeline);
if (res != VK_SUCCESS)
goto fail;
- res = create_pipeline(device, samples, state->depth_decomp[i].pass,
- state->depth_decomp[i].p_layout, DEPTH_RESUMMARIZE,
+ res = create_pipeline(device, samples, state->depth_decomp[i].p_layout, DEPTH_RESUMMARIZE,
&state->depth_decomp[i].resummarize_pipeline);
if (res != VK_SUCCESS)
goto fail;
@@ -443,17 +374,15 @@ radv_get_depth_pipeline(struct radv_cmd_buffer *cmd_buffer, struct radv_image *i
if (!state->depth_decomp[samples_log2].decompress_pipeline) {
VkResult ret;
- ret = create_pipeline(cmd_buffer->device, samples, state->depth_decomp[samples_log2].pass,
- state->depth_decomp[samples_log2].p_layout, DEPTH_DECOMPRESS,
- &state->depth_decomp[samples_log2].decompress_pipeline);
+ ret = create_pipeline(cmd_buffer->device, samples, state->depth_decomp[samples_log2].p_layout,
+ DEPTH_DECOMPRESS, &state->depth_decomp[samples_log2].decompress_pipeline);
if (ret != VK_SUCCESS) {
cmd_buffer->record_result = ret;
return NULL;
}
- ret = create_pipeline(cmd_buffer->device, samples, state->depth_decomp[samples_log2].pass,
- state->depth_decomp[samples_log2].p_layout, DEPTH_RESUMMARIZE,
- &state->depth_decomp[samples_log2].resummarize_pipeline);
+ ret = create_pipeline(cmd_buffer->device, samples, state->depth_decomp[samples_log2].p_layout,
+ DEPTH_RESUMMARIZE, &state->depth_decomp[samples_log2].resummarize_pipeline);
if (ret != VK_SUCCESS) {
cmd_buffer->record_result = ret;
return NULL;
@@ -479,8 +408,6 @@ radv_process_depth_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_i
const VkImageSubresourceRange *range, int level, int layer)
{
struct radv_device *device = cmd_buffer->device;
- struct radv_meta_state *state = &device->meta_state;
- uint32_t samples_log2 = ffs(image->info.samples) - 1;
struct radv_image_view iview;
uint32_t width, height;
@@ -504,42 +431,40 @@ radv_process_depth_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_i
},
NULL);
- VkFramebuffer fb_h;
- radv_CreateFramebuffer(
- radv_device_to_handle(device),
- &(VkFramebufferCreateInfo){.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
- .attachmentCount = 1,
- .pAttachments = (VkImageView[]){radv_image_view_to_handle(&iview)},
- .width = width,
- .height = height,
- .layers = 1},
- &cmd_buffer->pool->vk.alloc, &fb_h);
-
- radv_cmd_buffer_begin_render_pass(cmd_buffer,
- &(VkRenderPassBeginInfo){
- .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
- .renderPass = state->depth_decomp[samples_log2].pass,
- .framebuffer = fb_h,
- .renderArea = {.offset =
- {
- 0,
- 0,
- },
- .extent =
- {
- width,
- height,
- }},
- .clearValueCount = 0,
- .pClearValues = NULL,
- });
- radv_cmd_buffer_set_subpass(cmd_buffer, &cmd_buffer->state.pass->subpasses[0]);
+ const VkRenderingAttachmentInfo depth_att = {
+ .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
+ .imageView = radv_image_view_to_handle(&iview),
+ .imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
+ .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
+ .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
+ };
+
+ const VkRenderingAttachmentInfo stencil_att = {
+ .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
+ .imageView = radv_image_view_to_handle(&iview),
+ .imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
+ .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
+ .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
+ };
+
+ const VkRenderingInfo rendering_info = {
+ .sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
+ .renderArea = {
+ .offset = { 0, 0 },
+ .extent = { width, height }
+ },
+ .layerCount = 1,
+ .pDepthAttachment = &depth_att,
+ .pStencilAttachment = &stencil_att,
+ };
+
+ radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), &rendering_info);
radv_CmdDraw(radv_cmd_buffer_to_handle(cmd_buffer), 3, 1, 0, 0);
- radv_cmd_buffer_end_render_pass(cmd_buffer);
+
+ radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
radv_image_view_finish(&iview);
- radv_DestroyFramebuffer(radv_device_to_handle(device), fb_h, &cmd_buffer->pool->vk.alloc);
}
static void
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index b30c65aff71..aa9536cca83 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -630,7 +630,6 @@ struct radv_meta_state {
VkPipelineLayout p_layout;
VkPipeline decompress_pipeline;
VkPipeline resummarize_pipeline;
- VkRenderPass pass;
} depth_decomp[MAX_SAMPLES_LOG2];
VkDescriptorSetLayout expand_depth_stencil_compute_ds_layout;
More information about the mesa-commit
mailing list