Skip to content

Commit 9d2fdb2

Browse files
committed
fix timestamp buffer not being big enough
1 parent 4cf1961 commit 9d2fdb2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/startup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn setup_app(mut commands: Commands, device: Res<RenderDevice>) {
4848
let features = device.features();
4949
let timestamps = features
5050
.contains(Features::TIMESTAMP_QUERY)
51-
.then(|| GpuTimestamps::new(device.wgpu_device(), 512));
51+
.then(|| GpuTimestamps::new(device.wgpu_device(), 1024));
5252
commands.insert_resource(Timestamps {
5353
timestamps,
5454
..Default::default()

src/step.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ fn step_simulation_multisteps(
177177
timestamps: Some(timestamps),
178178
..Default::default()
179179
};
180-
180+
debug_assert!(
181+
timestamps_ms.len() >= num_substeps * 2 * 9,
182+
"GpuTimestamps should be initialized with a bigger size"
183+
);
181184
for i in 0..num_substeps {
182185
let mut timings = [
183186
&mut new_timings.grid_sort,
@@ -190,7 +193,8 @@ fn step_simulation_multisteps(
190193
&mut new_timings.particles_update,
191194
&mut new_timings.integrate_bodies,
192195
];
193-
let times = &timestamps_ms[i * timings.len() * 2..];
196+
let start_index = i * timings.len() * 2;
197+
let times = &timestamps_ms[start_index..];
194198

195199
for (k, timing) in timings.iter_mut().enumerate() {
196200
**timing += times[k * 2 + 1] - times[k * 2];

0 commit comments

Comments
 (0)