Skip to content

Commit

Permalink
Fix multiple resolves per frame causing invalid buffer copy operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Sep 21, 2024
1 parent ea4cd1b commit 72de1a4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ impl GpuProfiler {
continue;
}

assert!(num_resolved_queries < num_used_queries);
debug_assert!(query_pool.capacity >= num_used_queries);
debug_assert!(num_resolved_queries < num_used_queries);

// Resolve into offset 0 of the resolve buffer - this way we don't have to worry about
// the offset restrictions on resolve buffers (`wgpu::QUERY_RESOLVE_BUFFER_ALIGNMENT`)
Expand All @@ -364,14 +365,16 @@ impl GpuProfiler {
&query_pool.resolve_buffer,
0,
);
// Copy the resolved queries into the read buffer, making sure
// Copy the newly resolved queries into the read buffer, making sure
// that we don't override any of the results that are already there.
let destination_offset = (num_resolved_queries * wgpu::QUERY_SIZE) as u64;
let copy_size = ((num_used_queries - num_resolved_queries) * wgpu::QUERY_SIZE) as u64;
encoder.copy_buffer_to_buffer(
&query_pool.resolve_buffer,
0,
&query_pool.read_buffer,
(num_resolved_queries * wgpu::QUERY_SIZE) as u64,
(num_used_queries * wgpu::QUERY_SIZE) as u64,
destination_offset,
copy_size,
);

query_pool
Expand Down

0 comments on commit 72de1a4

Please sign in to comment.