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

Workaround wgpu vulkan sync bug for Tracy initialisation #85

Merged
merged 1 commit into from
Oct 15, 2024
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
17 changes: 11 additions & 6 deletions src/tracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ pub fn create_tracy_gpu_client(
mapped_at_creation: false,
});

let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
label: Some("wgpu-profiler gpu -> cpu sync cmd_buf"),
let mut timestamp_encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
label: Some("wgpu-profiler gpu -> cpu query timestamp"),
});
encoder.write_timestamp(&query_set, 0);
encoder.resolve_query_set(&query_set, 0..1, &resolve_buffer, 0);
encoder.copy_buffer_to_buffer(&resolve_buffer, 0, &map_buffer, 0, wgpu::QUERY_SIZE as _);
queue.submit(Some(encoder.finish()));
timestamp_encoder.write_timestamp(&query_set, 0);
timestamp_encoder.resolve_query_set(&query_set, 0..1, &resolve_buffer, 0);
// Workaround for https://github.com/gfx-rs/wgpu/issues/6406
// TODO when that bug is fixed, merge these encoders together again
let mut copy_encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
label: Some("wgpu-profiler gpu -> cpu copy timestamp"),
});
copy_encoder.copy_buffer_to_buffer(&resolve_buffer, 0, &map_buffer, 0, wgpu::QUERY_SIZE as _);
queue.submit([timestamp_encoder.finish(), copy_encoder.finish()]);

map_buffer.slice(..).map_async(wgpu::MapMode::Read, |_| ());
device.poll(wgpu::Maintain::Wait);
Expand Down