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

Fixes Queue Synchronization Validation issues #196

Merged
merged 15 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions auto_vk_toolkit/src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,8 @@ namespace avk
auto newRenderPass = context().create_renderpass(renderpassAttachments, {
// We only create one subpass here => create default dependencies as per specification chapter 8.1) Render Pass Creation:
avk::subpass_dependency{avk::subpass::external >> avk::subpass::index(0),
stage::color_attachment_output >> stage::early_fragment_tests | stage::late_fragment_tests | stage::color_attachment_output,
access::none >> access::color_attachment_read | access::color_attachment_write | access::depth_stencil_attachment_read | access::depth_stencil_attachment_write
stage::late_fragment_tests | stage::color_attachment_output >> stage::early_fragment_tests | stage::late_fragment_tests | stage::color_attachment_output,
access::depth_stencil_attachment_write >> access::color_attachment_read | access::color_attachment_write | access::depth_stencil_attachment_read | access::depth_stencil_attachment_write
},
avk::subpass_dependency{avk::subpass::index(0) >> avk::subpass::external,
stage::color_attachment_output >> stage::color_attachment_output,
Expand Down
3 changes: 0 additions & 3 deletions examples/framebuffer/source/framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,6 @@ int main() // <== Starting point ==
// Compile all the configuration parameters and the invokees into a "composition":
auto composition = configure_and_compose(
avk::application_name("Auto-Vk-Toolkit Example: Framebuffers"),
[](avk::validation_layers& config) {
//config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
},
// Pass windows:
mainWnd,
// Pass invokees:
Expand Down
4 changes: 1 addition & 3 deletions examples/multiple_queues/source/multiple_queues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ class multiple_queues_app : public avk::invokee
// A queue family ownership transfer consists of two distinct parts (as per specification 7.7.4. Queue Family Ownership Transfer):
// 2. Acquire exclusive ownership for the destination queue family

// TODO: Problem here vvv Why can't Auto-Vk find out stage and access in this case? It evaluates to none+none.
return sync::buffer_memory_barrier(vertexBuffer, stage::copy + access::transfer_write >> stage::auto_stages() + access::auto_accesses())
//return sync::buffer_memory_barrier(vertexBuffer, stage::copy + access::transfer_write >> stage::auto_stage + access::auto_access)
return sync::buffer_memory_barrier(vertexBuffer, stage::copy + access::transfer_write >> stage::auto_stage + access::auto_access)
.with_queue_family_ownership_transfer(mGraphicsQueue->family_index(), mTransferQueues[j]->family_index());
}
),
Expand Down
2 changes: 1 addition & 1 deletion examples/orca_loader/source/orca_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ int main() // <== Starting point ==
auto composition = configure_and_compose(
avk::application_name("Auto-Vk-Toolkit Example: ORCA Loader"),
[](avk::validation_layers& config) {
//config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
},
// Pass windows:
mainWnd,
Expand Down
9 changes: 3 additions & 6 deletions examples/present_from_compute/source/present_from_compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class present_from_compute_app : public avk::invokee
mVertexBuffers[inFlightIndex]->fill(vertexDataCurrentFrame.data(), 0),

// Release exclusive ownership from the transfer queue:
sync::buffer_memory_barrier(mVertexBuffers[inFlightIndex].as_reference(), stage::auto_stage + access::auto_access >> stage::none + access::none)
sync::buffer_memory_barrier(mVertexBuffers[inFlightIndex].as_reference(), stage::auto_stage + access::auto_access >> stage::copy + access::transfer_write)
.with_queue_family_ownership_transfer(mTransferQueue.family_index(), mGraphicsQueue.family_index())
}, mTransferQueue,
stage::auto_stage // Let the framework determine the (source) stage after which the semaphore can be signaled (will be stage::copy due to buffer_t::fill)
Expand Down Expand Up @@ -245,7 +245,7 @@ class present_from_compute_app : public avk::invokee
),

// Acquire exclusive ownership for the graphics queue:
sync::buffer_memory_barrier(mVertexBuffers[inFlightIndex].as_reference(), stage::none + access::none >> stage::vertex_attribute_input + access::vertex_attribute_read)
sync::buffer_memory_barrier(mVertexBuffers[inFlightIndex].as_reference(), stage::copy + access::transfer_write >> stage::vertex_attribute_input + access::vertex_attribute_read)
.with_queue_family_ownership_transfer(mTransferQueue.family_index(), mGraphicsQueue.family_index()),

// Begin and end one renderpass:
Expand Down Expand Up @@ -322,7 +322,7 @@ class present_from_compute_app : public avk::invokee
// Submit the dispatch calls to the compute queue:
avk::context().record({
// Acquire exclusive ownership from the graphics queue:
sync::image_memory_barrier(mFramebuffers[inFlightIndex]->image_at(0), stage::none + access::none >> stage::auto_stage + access::auto_access)
sync::image_memory_barrier(mFramebuffers[inFlightIndex]->image_at(0), stage::copy + access::transfer_write >> stage::auto_stage + access::auto_access)
.with_queue_family_ownership_transfer(mGraphicsQueue.family_index(), mComputeQueue.family_index()),

sync::image_memory_barrier(mFramebuffers[inFlightIndex]->image_at(0), stage::auto_stage + access::auto_access >> stage::auto_stage + access::auto_access)
Expand Down Expand Up @@ -438,9 +438,6 @@ int main() // <== Starting point ==
// Compile all the configuration parameters and the invokees into a "composition":
auto composition = configure_and_compose(
avk::application_name("Auto-Vk-Toolkit Example: Present from Compute"),
[](avk::validation_layers& config) {
//config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
},
// Pass windows:
mainWnd,
// Pass invokees:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,10 @@ class ray_query_in_ray_tracing_shaders_invokee : public avk::invokee
avk::stage::ray_tracing_shader >> avk::stage::copy,
avk::access::shader_write >> avk::access::transfer_read
).with_layout_transition(avk::layout::general >> avk::layout::transfer_src),
// Use dst stage + access to synchronize the image layout transition:
avk::sync::image_memory_barrier(mainWnd->current_backbuffer_reference().image_at(0),
avk::stage::none >> avk::stage::copy,
avk::access::none >> avk::access::transfer_write
avk::stage::color_attachment_output >> avk::stage::copy,
avk::access::color_attachment_write >> avk::access::transfer_write
).with_layout_transition(avk::layout::undefined >> avk::layout::transfer_dst),

avk::copy_image_to_another(
Expand Down Expand Up @@ -461,6 +462,9 @@ int main() // <== Starting point ==
// Compile all the configuration parameters and the invokees into a "composition":
auto composition = configure_and_compose(
avk::application_name("Auto-Vk-Toolkit Example: Ray Query in Ray Tracing Shaders"),
[](avk::validation_layers& config) {
config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
},
avk::required_device_extensions()
// We need several extensions for ray tracing:
.add_extension(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,10 @@ class ray_tracing_custom_intersection_app : public avk::invokee
avk::stage::ray_tracing_shader >> avk::stage::copy,
avk::access::shader_write >> avk::access::transfer_read
).with_layout_transition(avk::layout::general >> avk::layout::transfer_src),
// Use dst stage + access to synchronize the image layout transition:
avk::sync::image_memory_barrier(mainWnd->current_backbuffer_reference().image_at(0),
avk::stage::none >> avk::stage::copy,
avk::access::none >> avk::access::transfer_write
avk::stage::color_attachment_output >> avk::stage::copy,
avk::access::color_attachment_write >> avk::access::transfer_write
).with_layout_transition(avk::layout::undefined >> avk::layout::transfer_dst),

avk::copy_image_to_another(
Expand Down Expand Up @@ -449,6 +450,9 @@ int main() // <== Starting point ==
// Compile all the configuration parameters and the invokees into a "composition":
auto composition = configure_and_compose(
avk::application_name("Auto-Vk-Toolkit Example: Real-Time Ray Tracing - Custom Intersection Example"),
[](avk::validation_layers& config) {
config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
},
#if VK_HEADER_VERSION >= 162
avk::required_device_extensions()
// We need several extensions for ray tracing:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,10 @@ class ray_tracing_with_shadows_and_ao_invokee : public avk::invokee
avk::stage::ray_tracing_shader >> avk::stage::copy,
avk::access::shader_write >> avk::access::transfer_read
).with_layout_transition(avk::layout::general >> avk::layout::transfer_src),
// Use dst stage + access to synchronize the image layout transition:
avk::sync::image_memory_barrier(mainWnd->current_backbuffer_reference().image_at(0),
avk::stage::none >> avk::stage::copy,
avk::access::none >> avk::access::transfer_write
avk::stage::color_attachment_output >> avk::stage::copy,
avk::access::color_attachment_write >> avk::access::transfer_write
).with_layout_transition(avk::layout::undefined >> avk::layout::transfer_dst),

avk::copy_image_to_another(
Expand Down Expand Up @@ -463,6 +464,9 @@ int main() // <== Starting point ==
// Compile all the configuration parameters and the invokees into a "composition":
auto composition = configure_and_compose(
avk::application_name("Auto-Vk-Toolkit Example: Real-Time Ray Tracing with Shadows and AO"),
[](avk::validation_layers& config) {
config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
},
avk::required_device_extensions()
// We need several extensions for ray tracing:
.add_extension(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME)
Expand Down
9 changes: 8 additions & 1 deletion examples/vertex_buffers/source/vertex_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ class vertex_buffers_app : public avk::invokee
auto cmdBfr = commandPool->alloc_command_buffer(vk::CommandBufferUsageFlagBits::eOneTimeSubmit);

avk::context().record({
// Synchronization validation is unable to figure out that frame-3 used this buffer, but is no longer needing it.
// => so we've gotta be explicitly synchronizing it with this barrier:
avk::sync::buffer_memory_barrier(mVertexBuffers[inFlightIndex].as_reference(),
avk::stage::vertex_attribute_input >> avk::stage::copy ,
avk::access::vertex_attribute_read >> avk::access::transfer_write
),

// Fill the vertex buffer that corresponds to this the current inFlightIndex:
mVertexBuffers[inFlightIndex]->fill(vertexDataCurrentFrame.data(), 0),

Expand Down Expand Up @@ -219,7 +226,7 @@ int main() // <== Starting point ==
auto composition = configure_and_compose(
avk::application_name("Auto-Vk-Toolkit Example: Vertex Buffers"),
[](avk::validation_layers& config) {
//config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
config.enable_feature(vk::ValidationFeatureEnableEXT::eSynchronizationValidation);
},
// Pass windows:
mainWnd,
Expand Down
Loading