Getting there
This commit is contained in:
parent
ed5a4379db
commit
f300dbd394
43 changed files with 1213 additions and 459 deletions
|
|
@ -36,7 +36,8 @@ export class AgentGenerationPipeline {
|
|||
private readonly resizePipeline: GPUComputePipeline;
|
||||
private readonly compactionPipeline: GPUComputePipeline;
|
||||
private readonly clearCompactedTailPipeline: GPUComputePipeline;
|
||||
private readonly workgroupSize: number;
|
||||
private readonly resizeWorkgroupSize: number;
|
||||
private readonly compactionWorkgroupSize: number;
|
||||
|
||||
private activeAgentsBuffer: GPUBuffer;
|
||||
private inactiveAgentsBuffer: GPUBuffer;
|
||||
|
|
@ -110,20 +111,26 @@ export class AgentGenerationPipeline {
|
|||
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
||||
});
|
||||
|
||||
this.workgroupSize = getAgentWorkgroupSize(device);
|
||||
const sizedSchema = substituteAgentWorkgroupSize(device, agentSchema);
|
||||
this.resizeWorkgroupSize = getAgentWorkgroupSize(device, 'resize');
|
||||
this.compactionWorkgroupSize = getAgentWorkgroupSize(device, 'compaction');
|
||||
const resizeSchema = substituteAgentWorkgroupSize(device, agentSchema, 'resize');
|
||||
const compactionSchema = substituteAgentWorkgroupSize(
|
||||
device,
|
||||
agentSchema,
|
||||
'compaction'
|
||||
);
|
||||
|
||||
this.resizePipeline = device.createComputePipeline({
|
||||
layout: device.createPipelineLayout({
|
||||
bindGroupLayouts: [emptyBindGroupLayout, this.bindGroupLayout],
|
||||
}),
|
||||
compute: {
|
||||
module: smartCompile(device, sizedSchema, resizeShader),
|
||||
module: smartCompile(device, resizeSchema, resizeShader),
|
||||
entryPoint: 'main',
|
||||
},
|
||||
});
|
||||
|
||||
const compactionModule = smartCompile(device, sizedSchema, compactionShader);
|
||||
const compactionModule = smartCompile(device, compactionSchema, compactionShader);
|
||||
|
||||
this.compactionPipeline = device.createComputePipeline({
|
||||
layout: device.createPipelineLayout({
|
||||
|
|
@ -248,7 +255,7 @@ export class AgentGenerationPipeline {
|
|||
const passEncoder = commandEncoder.beginComputePass();
|
||||
passEncoder.setPipeline(this.resizePipeline);
|
||||
passEncoder.setBindGroup(1, this.getBindGroup());
|
||||
dispatchAgentWorkgroups(passEncoder, this.workgroupSize, agentCount);
|
||||
dispatchAgentWorkgroups(passEncoder, this.resizeWorkgroupSize, agentCount);
|
||||
passEncoder.end();
|
||||
|
||||
this.device.queue.submit([commandEncoder.finish()]);
|
||||
|
|
@ -267,11 +274,11 @@ export class AgentGenerationPipeline {
|
|||
const passEncoder = commandEncoder.beginComputePass();
|
||||
passEncoder.setPipeline(this.compactionPipeline);
|
||||
passEncoder.setBindGroup(1, this.getBindGroup());
|
||||
dispatchAgentWorkgroups(passEncoder, this.workgroupSize, agentCount);
|
||||
dispatchAgentWorkgroups(passEncoder, this.compactionWorkgroupSize, agentCount);
|
||||
passEncoder.setPipeline(this.clearCompactedTailPipeline);
|
||||
dispatchAgentWorkgroups(
|
||||
passEncoder,
|
||||
this.workgroupSize,
|
||||
this.compactionWorkgroupSize,
|
||||
Math.ceil(agentCount / AgentGenerationPipeline.CLEAR_COMPACTED_TAIL_STRIDE)
|
||||
);
|
||||
passEncoder.end();
|
||||
|
|
|
|||
Loading…
Reference in a new issue