radv/meta: rework creating HW resolve pipelines
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30244>
This commit is contained in:
committed by
Marge Bot
parent
c4d8ccfcb3
commit
792665bbee
@@ -158,6 +158,26 @@ cleanup:
|
||||
return result;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
get_pipeline(struct radv_device *device, unsigned fs_key, VkPipeline *pipeline_out)
|
||||
{
|
||||
struct radv_meta_state *state = &device->meta_state;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
mtx_lock(&state->mtx);
|
||||
if (!state->resolve.pipeline[fs_key]) {
|
||||
result = create_pipeline(device, radv_fs_key_format_exemplars[fs_key], &state->resolve.pipeline[fs_key]);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
*pipeline_out = state->resolve.pipeline[fs_key];
|
||||
|
||||
fail:
|
||||
mtx_unlock(&state->mtx);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
radv_device_finish_meta_resolve_state(struct radv_device *device)
|
||||
{
|
||||
@@ -197,13 +217,21 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer, const struct radv_image *src_im
|
||||
struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
|
||||
VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
|
||||
unsigned fs_key = radv_format_meta_fs_key(device, vk_format);
|
||||
VkPipeline pipeline;
|
||||
VkResult result;
|
||||
|
||||
result = get_pipeline(device, fs_key, &pipeline);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
cmd_buffer->state.flush_bits |= radv_src_access_flush(cmd_buffer, VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
||||
VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, src_image) |
|
||||
radv_dst_access_flush(cmd_buffer, VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
||||
VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT, src_image);
|
||||
|
||||
radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS, device->meta_state.resolve.pipeline[fs_key]);
|
||||
radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||
|
||||
radv_CmdDraw(cmd_buffer_h, 3, 1, 0, 0);
|
||||
cmd_buffer->state.flush_bits |= radv_src_access_flush(cmd_buffer, VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
||||
@@ -267,24 +295,6 @@ radv_pick_resolve_method_images(struct radv_device *device, struct radv_image *s
|
||||
}
|
||||
}
|
||||
|
||||
static VkResult
|
||||
build_resolve_pipeline(struct radv_device *device, unsigned fs_key)
|
||||
{
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
mtx_lock(&device->meta_state.mtx);
|
||||
if (device->meta_state.resolve.pipeline[fs_key]) {
|
||||
mtx_unlock(&device->meta_state.mtx);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = create_pipeline(device, radv_fs_key_format_exemplars[fs_key],
|
||||
&device->meta_state.resolve.pipeline[fs_key]);
|
||||
|
||||
mtx_unlock(&device->meta_state.mtx);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
radv_meta_resolve_hardware_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
|
||||
VkImageLayout src_image_layout, struct radv_image *dst_image,
|
||||
@@ -298,8 +308,6 @@ radv_meta_resolve_hardware_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
||||
assert(src_image->vk.samples > 1);
|
||||
assert(dst_image->vk.samples == 1);
|
||||
|
||||
unsigned fs_key = radv_format_meta_fs_key(device, dst_image->vk.format);
|
||||
|
||||
/* From the Vulkan 1.0 spec:
|
||||
*
|
||||
* - The aspectMask member of srcSubresource and dstSubresource must
|
||||
@@ -355,12 +363,6 @@ radv_meta_resolve_hardware_image(struct radv_cmd_buffer *cmd_buffer, struct radv
|
||||
|
||||
radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &resolve_area);
|
||||
|
||||
VkResult ret = build_resolve_pipeline(device, fs_key);
|
||||
if (ret != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
struct radv_image_view src_iview;
|
||||
radv_image_view_init(&src_iview, device,
|
||||
&(VkImageViewCreateInfo){
|
||||
@@ -563,12 +565,6 @@ radv_cmd_buffer_resolve_rendering_hw(struct radv_cmd_buffer *cmd_buffer, struct
|
||||
|
||||
radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), &rendering_info);
|
||||
|
||||
VkResult ret = build_resolve_pipeline(device, radv_format_meta_fs_key(device, dst_iview->vk.format));
|
||||
if (ret != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
emit_resolve(cmd_buffer, src_img, dst_img, dst_iview->vk.format);
|
||||
|
||||
radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
|
||||
|
||||
Reference in New Issue
Block a user