Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix barrier setting in async compute sample #1213

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions samples/performance/async_compute/async_compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ void AsyncComputeSample::prepare_render_targets()
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
VMA_MEMORY_USAGE_GPU_ONLY},
};
color_targets[0].set_debug_name("color_targets[0]");
color_targets[1].set_debug_name("color_targets[1]");

// Should only really need one depth target, but vkb::RenderTarget needs to own the resource.
vkb::core::Image depth_targets[2]{
Expand All @@ -92,6 +94,8 @@ void AsyncComputeSample::prepare_render_targets()
VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
VMA_MEMORY_USAGE_GPU_ONLY},
};
depth_targets[0].set_debug_name("depth_targets[0]");
depth_targets[1].set_debug_name("depth_targets[1]");

// 8K shadow-map overkill to stress devices.
// Min-spec is 4K however, so clamp to that if required.
Expand All @@ -108,6 +112,7 @@ void AsyncComputeSample::prepare_render_targets()
vkb::core::Image shadow_target{get_device(), shadow_resolution, VK_FORMAT_D16_UNORM,
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
VMA_MEMORY_USAGE_GPU_ONLY};
shadow_target.set_debug_name("shadow_target");

// Create a simple mip-chain used for bloom blur.
// Could technically mip-map the HDR target,
Expand Down Expand Up @@ -202,7 +207,7 @@ void AsyncComputeSample::setup_queues()

if (graphics_family_index == compute_family_index)
{
LOGI("Device has does not have a dedicated compute queue family.");
LOGI("Device does not have a dedicated compute queue family.");
post_compute_queue = early_graphics_queue;
}
else
Expand Down Expand Up @@ -324,6 +329,7 @@ void AsyncComputeSample::render_shadow_pass()
{
auto &queue = *early_graphics_queue;
auto &command_buffer = get_render_context().get_active_frame().request_command_buffer(queue);
command_buffer.set_debug_name("shadow_pass");
command_buffer.begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);

auto &views = shadow_render_target->get_views();
Expand Down Expand Up @@ -370,6 +376,7 @@ VkSemaphore AsyncComputeSample::render_forward_offscreen_pass(VkSemaphore hdr_wa
{
auto &queue = *early_graphics_queue;
auto &command_buffer = get_render_context().get_active_frame().request_command_buffer(queue);
command_buffer.set_debug_name("forward_offscreen_pass");

command_buffer.begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);

Expand Down Expand Up @@ -447,6 +454,7 @@ VkSemaphore AsyncComputeSample::render_swapchain(VkSemaphore post_semaphore)
{
auto &queue = *present_graphics_queue;
auto &command_buffer = get_render_context().get_active_frame().request_command_buffer(queue);
command_buffer.set_debug_name("swapchain");

command_buffer.begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);

Expand Down Expand Up @@ -514,6 +522,7 @@ VkSemaphore AsyncComputeSample::render_compute_post(VkSemaphore wait_graphics_se
{
auto &queue = *post_compute_queue;
auto &command_buffer = get_render_context().get_active_frame().request_command_buffer(queue);
command_buffer.set_debug_name("compute_post");

command_buffer.begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);

Expand All @@ -523,7 +532,7 @@ VkSemaphore AsyncComputeSample::render_compute_post(VkSemaphore wait_graphics_se
if (early_graphics_queue->get_family_index() != post_compute_queue->get_family_index())
{
vkb::ImageMemoryBarrier memory_barrier{};
memory_barrier.old_layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
memory_barrier.old_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
memory_barrier.new_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
memory_barrier.src_access_mask = 0;
memory_barrier.dst_access_mask = VK_ACCESS_SHADER_READ_BIT;
Expand Down
Loading