not sure
This commit is contained in:
parent
560398fefb
commit
80ed37298b
73 changed files with 3619 additions and 1295 deletions
|
|
@ -15,7 +15,6 @@ struct Counters {
|
|||
|
||||
var<workgroup> workgroupAliveCount: atomic<u32>;
|
||||
var<workgroup> workgroupCompactedOffset: u32;
|
||||
var<workgroup> workgroupCopyCount: u32;
|
||||
|
||||
@compute @workgroup_size(64)
|
||||
fn main(
|
||||
|
|
@ -31,9 +30,12 @@ fn main(
|
|||
workgroupBarrier();
|
||||
|
||||
var localCompactedIndex = 0u;
|
||||
var agent = Agent(vec2<f32>(0.0, 0.0), 0.0, -1.0, vec2<f32>(-1.0, -1.0), 0.0, 0.0);
|
||||
var isAlive = false;
|
||||
if id < settings.agentCount {
|
||||
let agent = agents[id];
|
||||
if agent.colorIndex >= 0.0 {
|
||||
agent = agents[id];
|
||||
isAlive = agent.colorIndex >= 0.0;
|
||||
if isAlive {
|
||||
localCompactedIndex = atomicAdd(&workgroupAliveCount, 1u);
|
||||
}
|
||||
}
|
||||
|
|
@ -51,30 +53,7 @@ fn main(
|
|||
|
||||
workgroupBarrier();
|
||||
|
||||
if id < settings.agentCount {
|
||||
let agent = agents[id];
|
||||
if agent.colorIndex >= 0.0 {
|
||||
compactedAgents[workgroupCompactedOffset + localCompactedIndex] = agent;
|
||||
}
|
||||
if isAlive {
|
||||
compactedAgents[workgroupCompactedOffset + localCompactedIndex] = agent;
|
||||
}
|
||||
}
|
||||
|
||||
@compute @workgroup_size(64)
|
||||
fn copyCompactedAgents(
|
||||
@builtin(global_invocation_id) global_id: vec3<u32>,
|
||||
@builtin(local_invocation_id) local_id: vec3<u32>
|
||||
) {
|
||||
let id = get_id(global_id);
|
||||
|
||||
if local_id.x == 0u {
|
||||
workgroupCopyCount = atomicLoad(&counters.aliveAgentCount);
|
||||
}
|
||||
|
||||
workgroupBarrier();
|
||||
|
||||
if id >= workgroupCopyCount {
|
||||
return;
|
||||
}
|
||||
|
||||
agents[id] = compactedAgents[id];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue