I’m trying to pass an existing DataBuffer to a compute shader.
Which means calling ComputeShader.setStorageBuffer(name: string, buffer: StorageBuffer): void;
However, the StorageBuffer
API always creates a new storage buffer. Would it be possible to add another constructor or a static function along the lines of .fromBuffer(buffer: DataBuffer)
?
More specifically, I’m trying to do indirect drawing as in Dynamic size of instance count . The accepted answer there actually has a workaround for this, which just works due to the implementation of Buffer coincidentally being close enough to StorageBuffer
https://playground.babylonjs.com/?webgpu#SLP3YY#9