More clean up
This commit is contained in:
parent
c94ffcc506
commit
f03da42b5e
43 changed files with 818 additions and 1076 deletions
|
|
@ -9,6 +9,8 @@ struct Counters {
|
|||
aliveAgentCount: atomic<u32>,
|
||||
};
|
||||
|
||||
const clearCompactedTailStride = 4u;
|
||||
|
||||
@group(1) @binding(0) var<uniform> settings: Settings;
|
||||
@group(1) @binding(2) var<storage, read_write> counters: Counters;
|
||||
@group(1) @binding(3) var<storage, read_write> compactedAgents: array<Agent>;
|
||||
|
|
@ -20,10 +22,9 @@ var<workgroup> clearAliveAgentCount: u32;
|
|||
@compute @workgroup_size(64)
|
||||
fn main(
|
||||
@builtin(global_invocation_id) global_id: vec3<u32>,
|
||||
@builtin(local_invocation_id) local_id: vec3<u32>,
|
||||
@builtin(num_workgroups) num_workgroups: vec3<u32>
|
||||
@builtin(local_invocation_id) local_id: vec3<u32>
|
||||
) {
|
||||
let id = get_id(global_id, num_workgroups);
|
||||
let id = get_id(global_id);
|
||||
|
||||
if local_id.x == 0u {
|
||||
atomicStore(&workgroupAliveCount, 0u);
|
||||
|
|
@ -63,10 +64,9 @@ fn main(
|
|||
@compute @workgroup_size(64)
|
||||
fn clearCompactedTail(
|
||||
@builtin(global_invocation_id) global_id: vec3<u32>,
|
||||
@builtin(local_invocation_id) local_id: vec3<u32>,
|
||||
@builtin(num_workgroups) num_workgroups: vec3<u32>
|
||||
@builtin(local_invocation_id) local_id: vec3<u32>
|
||||
) {
|
||||
let id = get_id(global_id, num_workgroups);
|
||||
let id = get_id(global_id);
|
||||
|
||||
if local_id.x == 0u {
|
||||
clearAliveAgentCount = atomicLoad(&counters.aliveAgentCount);
|
||||
|
|
@ -74,11 +74,11 @@ fn clearCompactedTail(
|
|||
|
||||
workgroupBarrier();
|
||||
|
||||
if id >= settings.agentCount {
|
||||
return;
|
||||
}
|
||||
|
||||
if id >= clearAliveAgentCount {
|
||||
compactedAgents[id].colorIndex = -1.0;
|
||||
let firstClearId = clearAliveAgentCount + id * clearCompactedTailStride;
|
||||
for (var offset = 0u; offset < clearCompactedTailStride; offset += 1u) {
|
||||
let clearId = firstClearId + offset;
|
||||
if clearId < settings.agentCount {
|
||||
compactedAgents[clearId].colorIndex = -1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue