diff --git a/src/profiler.rs b/src/profiler.rs index 18556e6..60aa205 100644 --- a/src/profiler.rs +++ b/src/profiler.rs @@ -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`) @@ -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