Skip to content

Commit

Permalink
Workaround wgpu vulkan sync bug for Tracy initialisation (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone authored Oct 15, 2024
1 parent 36639a9 commit 887fd5a
Showing 1 changed file with 11 additions and 6 deletions.
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

0 comments on commit 887fd5a

Please sign in to comment.