Webgpu: use a GPUBuffer directly for creating a VertexBuffer

I am simulating a large particule system.
For this purpose, I have written WebGPU compute shaders as well as instanciation code, which is well contained into a sim class.

I want to pass the output (GPUBuffer) that represent vertices positions to the renderer.
So I would like to create a BABYLON.VertexBuffer that directly use an existing GPUBuffer. Is this possible ?

I would like to keep a clean separation between the simulation code (WebGPU only) and the rendering code (Babylonsjs).

Thanks,

Then you’ll have to copy the output buffer to the vertex buffer of the shader. But I believe you could pass a Float32Array read from your WebGPU buffer to the shader directly. It still counts as a good separation concept to me.

Thanks Roland.
How to pass a GPUBuffer Float32Array to the babylon buffer directly on the GPU (without having the data going to the CPU)?

Should my WebGPU code call GPUCommandEncoder.copyBufferToBuffer(source: GPUBuffer, sourceOffset: number, destination: GPUBuffer, destinationOffset: number, size: number): void to handle the copy directly to the babylon buffer ?
If so, I need to access the underlying GPUBuffer of the Babylon buffer. Is this possible?

Or maybe you thought of another way?

Previous bullshit posted by accident

Webgpu: use a GPUBuffer directly for creating a VertexBuffer

Check this out!

EDIT:

I think you referrenced to the wrong post :slight_smile:

1 Like

Look for the Boids WebGPU example PG.

Shit, I was already sleeping :smiley: Lemme fix it!

This can also be relevant

1 Like

@victor please mark a solution or add yours so we can close your question. Thx!

Hi Roland,
Still working on it :slight_smile:

1 Like