mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
radv: convert the meta resolve color FS path to dynamic rendering
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15612>
This commit is contained in:
parent
42db590006
commit
518c6d808e
2 changed files with 27 additions and 120 deletions
|
|
@ -149,10 +149,6 @@ create_resolve_pipeline(struct radv_device *device, int samples_log2, VkFormat f
|
|||
nir_shader *fs = build_resolve_fragment_shader(device, is_integer, samples);
|
||||
nir_shader *vs = build_nir_vertex_shader();
|
||||
|
||||
VkRenderPass *rp = &device->meta_state.resolve_fragment.rc[samples_log2].render_pass[fs_key][0];
|
||||
|
||||
assert(!*rp);
|
||||
|
||||
VkPipelineShaderStageCreateInfo pipeline_shader_stages[] = {
|
||||
{.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||
.stage = VK_SHADER_STAGE_VERTEX_BIT,
|
||||
|
|
@ -166,69 +162,15 @@ create_resolve_pipeline(struct radv_device *device, int samples_log2, VkFormat f
|
|||
.pSpecializationInfo = NULL},
|
||||
};
|
||||
|
||||
for (unsigned dst_layout = 0; dst_layout < RADV_META_DST_LAYOUT_COUNT; ++dst_layout) {
|
||||
VkImageLayout layout = radv_meta_dst_layout_to_layout(dst_layout);
|
||||
result = radv_CreateRenderPass2(
|
||||
radv_device_to_handle(device),
|
||||
&(VkRenderPassCreateInfo2){
|
||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2,
|
||||
.attachmentCount = 1,
|
||||
.pAttachments =
|
||||
&(VkAttachmentDescription2){
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2,
|
||||
.format = format,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
|
||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
.initialLayout = layout,
|
||||
.finalLayout = layout,
|
||||
},
|
||||
.subpassCount = 1,
|
||||
.pSubpasses =
|
||||
&(VkSubpassDescription2){
|
||||
.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2,
|
||||
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
.inputAttachmentCount = 0,
|
||||
.colorAttachmentCount = 1,
|
||||
.pColorAttachments =
|
||||
&(VkAttachmentReference2){
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2,
|
||||
.attachment = 0,
|
||||
.layout = layout,
|
||||
},
|
||||
.pResolveAttachments = NULL,
|
||||
.pDepthStencilAttachment =
|
||||
&(VkAttachmentReference2){
|
||||
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2,
|
||||
.attachment = VK_ATTACHMENT_UNUSED,
|
||||
.layout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
},
|
||||
.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}},
|
||||
},
|
||||
&device->meta_state.alloc, rp + dst_layout);
|
||||
}
|
||||
const VkPipelineRenderingCreateInfo rendering_create_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
|
||||
.colorAttachmentCount = 1,
|
||||
.pColorAttachmentFormats = &format,
|
||||
};
|
||||
|
||||
const VkGraphicsPipelineCreateInfo vk_pipeline_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
|
||||
.pNext = &rendering_create_info,
|
||||
.stageCount = ARRAY_SIZE(pipeline_shader_stages),
|
||||
.pStages = pipeline_shader_stages,
|
||||
.pVertexInputState = vi_create_info,
|
||||
|
|
@ -286,7 +228,7 @@ create_resolve_pipeline(struct radv_device *device, int samples_log2, VkFormat f
|
|||
},
|
||||
.flags = 0,
|
||||
.layout = device->meta_state.resolve_fragment.p_layout,
|
||||
.renderPass = *rp,
|
||||
.renderPass = VK_NULL_HANDLE,
|
||||
.subpass = 0,
|
||||
};
|
||||
|
||||
|
|
@ -712,10 +654,6 @@ radv_device_finish_meta_resolve_fragment_state(struct radv_device *device)
|
|||
struct radv_meta_state *state = &device->meta_state;
|
||||
for (uint32_t i = 0; i < MAX_SAMPLES_LOG2; ++i) {
|
||||
for (unsigned j = 0; j < NUM_META_FS_KEYS; ++j) {
|
||||
for (unsigned k = 0; k < RADV_META_DST_LAYOUT_COUNT; ++k) {
|
||||
radv_DestroyRenderPass(radv_device_to_handle(device),
|
||||
state->resolve_fragment.rc[i].render_pass[j][k], &state->alloc);
|
||||
}
|
||||
radv_DestroyPipeline(radv_device_to_handle(device),
|
||||
state->resolve_fragment.rc[i].pipeline[j], &state->alloc);
|
||||
}
|
||||
|
|
@ -933,27 +871,12 @@ radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
|||
VkImageLayout src_image_layout, struct radv_image *dest_image,
|
||||
VkImageLayout dest_image_layout, const VkImageResolve2 *region)
|
||||
{
|
||||
struct radv_device *device = cmd_buffer->device;
|
||||
struct radv_meta_saved_state saved_state;
|
||||
const uint32_t samples = src_image->info.samples;
|
||||
const uint32_t samples_log2 = ffs(samples) - 1;
|
||||
unsigned fs_key = radv_format_meta_fs_key(cmd_buffer->device, dest_image->vk_format);
|
||||
unsigned dst_layout = radv_meta_dst_layout_from_layout(dest_image_layout);
|
||||
VkRenderPass rp;
|
||||
VkImageLayout layout = radv_meta_dst_layout_to_layout(dst_layout);
|
||||
|
||||
radv_decompress_resolve_src(cmd_buffer, src_image, src_image_layout, region);
|
||||
|
||||
if (!device->meta_state.resolve_fragment.rc[samples_log2].render_pass[fs_key][dst_layout]) {
|
||||
VkResult ret =
|
||||
create_resolve_pipeline(device, samples_log2, radv_fs_key_format_exemplars[fs_key]);
|
||||
if (ret != VK_SUCCESS) {
|
||||
cmd_buffer->record_result = ret;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rp = device->meta_state.resolve_fragment.rc[samples_log2].render_pass[fs_key][dst_layout];
|
||||
|
||||
radv_meta_save(
|
||||
&saved_state, cmd_buffer,
|
||||
RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_CONSTANTS | RADV_META_SAVE_DESCRIPTORS);
|
||||
|
|
@ -1012,50 +935,35 @@ radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
|||
},
|
||||
NULL);
|
||||
|
||||
VkFramebuffer fb;
|
||||
radv_CreateFramebuffer(
|
||||
radv_device_to_handle(cmd_buffer->device),
|
||||
&(VkFramebufferCreateInfo){.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
|
||||
.attachmentCount = 1,
|
||||
.pAttachments =
|
||||
(VkImageView[]){
|
||||
radv_image_view_to_handle(&dest_iview),
|
||||
},
|
||||
.width = extent.width + dstOffset.x,
|
||||
.height = extent.height + dstOffset.y,
|
||||
.layers = 1},
|
||||
&cmd_buffer->pool->vk.alloc, &fb);
|
||||
const VkRenderingAttachmentInfo color_att = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||
.imageView = radv_image_view_to_handle(&dest_iview),
|
||||
.imageLayout = layout,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
|
||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
};
|
||||
|
||||
radv_cmd_buffer_begin_render_pass(cmd_buffer,
|
||||
&(VkRenderPassBeginInfo){
|
||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
|
||||
.renderPass = rp,
|
||||
.framebuffer = fb,
|
||||
.renderArea =
|
||||
{
|
||||
.offset =
|
||||
{
|
||||
dstOffset.x,
|
||||
dstOffset.y,
|
||||
},
|
||||
.extent = {extent.width, extent.height},
|
||||
},
|
||||
.clearValueCount = 0,
|
||||
.pClearValues = NULL,
|
||||
});
|
||||
const VkRenderingInfo rendering_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
|
||||
.renderArea = {
|
||||
.offset = { dstOffset.x, dstOffset.y },
|
||||
.extent = { extent.width, extent.height }
|
||||
},
|
||||
.layerCount = 1,
|
||||
.colorAttachmentCount = 1,
|
||||
.pColorAttachments = &color_att,
|
||||
};
|
||||
|
||||
radv_cmd_buffer_set_subpass(cmd_buffer, &cmd_buffer->state.pass->subpasses[0]);
|
||||
radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), &rendering_info);
|
||||
|
||||
emit_resolve(cmd_buffer, &src_iview, &dest_iview, &(VkOffset2D){srcOffset.x, srcOffset.y},
|
||||
&(VkOffset2D){dstOffset.x, dstOffset.y},
|
||||
&(VkExtent2D){extent.width, extent.height});
|
||||
|
||||
radv_cmd_buffer_end_render_pass(cmd_buffer);
|
||||
radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
|
||||
|
||||
radv_image_view_finish(&src_iview);
|
||||
radv_image_view_finish(&dest_iview);
|
||||
radv_DestroyFramebuffer(radv_device_to_handle(cmd_buffer->device), fb,
|
||||
&cmd_buffer->pool->vk.alloc);
|
||||
}
|
||||
|
||||
radv_meta_restore(&saved_state, cmd_buffer);
|
||||
|
|
|
|||
|
|
@ -602,7 +602,6 @@ struct radv_meta_state {
|
|||
VkPipelineLayout p_layout;
|
||||
|
||||
struct {
|
||||
VkRenderPass render_pass[NUM_META_FS_KEYS][RADV_META_DST_LAYOUT_COUNT];
|
||||
VkPipeline pipeline[NUM_META_FS_KEYS];
|
||||
} rc[MAX_SAMPLES_LOG2];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue