|
1 | 1 | #import bevy_hanabi::vfx_common::{ |
2 | | - ChildInfo, ChildInfoBuffer, SimParams, Spawner, |
| 2 | + ChildInfo, ChildInfoBuffer, DispatchIndirectArgs, SimParams, Spawner, |
3 | 3 | EM_OFFSET_ALIVE_COUNT, EM_OFFSET_MAX_UPDATE, EM_OFFSET_CAPACITY, |
4 | 4 | EM_OFFSET_MAX_SPAWN, EM_OFFSET_INDIRECT_DISPATCH_INDEX, DRAW_INDEXED_INDIRECT_STRIDE, |
5 | | - EM_OFFSET_INDIRECT_WRITE_INDEX, DISPATCH_INDIRECT_STRIDE, EFFECT_METADATA_STRIDE |
| 5 | + EM_OFFSET_INDIRECT_WRITE_INDEX, EFFECT_METADATA_STRIDE |
6 | 6 | } |
7 | 7 |
|
8 | 8 | @group(0) @binding(0) var<uniform> sim_params : SimParams; |
9 | 9 |
|
10 | 10 | // Tightly packed array of EffectMetadata[], accessed as u32 array. |
11 | 11 | @group(1) @binding(0) var<storage, read_write> effect_metadata_buffer : array<u32>; |
12 | | -// Tightly packed array of DispatchIndirectArgs[], accessed as u32 array. |
13 | | -@group(1) @binding(1) var<storage, read_write> dispatch_indirect_buffer : array<u32>; |
| 12 | +@group(1) @binding(1) var<storage, read_write> dispatch_indirect_buffer : array<DispatchIndirectArgs>; |
14 | 13 | // Tightly packed array of DrawIndexedIndirectArgs[], accessed as u32 array. This can contain |
15 | 14 | // some DrawIndirectArgs[] instead, but in that case the stride is adjusted so all rows have |
16 | 15 | // the same size. Since we access the instance_count, which is at the same position in both, |
@@ -70,10 +69,9 @@ fn main(@builtin(global_invocation_id) global_invocation_id: vec3<u32>) { |
70 | 69 | // Calculate the number of workgroups (thread groups) to dispatch for the update |
71 | 70 | // pass, which is the number of alive particles rounded up to 64 (workgroup_size). |
72 | 71 | let indirect_dispatch_index = effect_metadata_buffer[em_base + EM_OFFSET_INDIRECT_DISPATCH_INDEX]; |
73 | | - let di_base = DISPATCH_INDIRECT_STRIDE * indirect_dispatch_index; |
74 | | - dispatch_indirect_buffer[di_base] = (alive_count + 63u) >> 6u; |
75 | | - dispatch_indirect_buffer[di_base + 1u] = 1u; |
76 | | - dispatch_indirect_buffer[di_base + 2u] = 1u; |
| 72 | + dispatch_indirect_buffer[indirect_dispatch_index].x = (alive_count + 63u) >> 6u; |
| 73 | + dispatch_indirect_buffer[indirect_dispatch_index].y = 1u; |
| 74 | + dispatch_indirect_buffer[indirect_dispatch_index].z = 1u; |
77 | 75 |
|
78 | 76 | // Swap ping/pong buffers. The update pass always writes into ping, and both the update |
79 | 77 | // pass and the render pass always read from pong. |
|
0 commit comments