I want to use wgslFn
instead of Fn
to do some work on the position attribute. Here’s my code.
const positionBaseAttribute = geometry.attributes.position;
const positionStorageBufferAttribute = new TSL.StorageBufferAttribute( positionBaseAttribute.count, 4 );
const positionStorageAttribute = storage( positionStorageBufferAttribute, 'vec4', positionStorageBufferAttribute.count );
let computeNode = wgslFn(`
fn doWork(v: array<vec4<f32>,${positionBaseAttribute.count}> ) -> array<vec4<f32>>{
...
return v;
}
`)({v:positionStorageAttribute}).compute(positionBaseAttribute.count)
await renderer.computeAsync( computeNode );
const outArray = new Float32Array( await renderer.getArrayBufferAsync( positionStorageBufferAttribute ) );
It looks like the wgsl has a limit to the size of an array I can input. This is the error i get:
Error while parsing WGSL: :22:16 error: array count (3780060) must be less than 65536
fn doWork ( v: array<vec4<f32>,3780060> ) -> array<vec4<f32>>{
^^^^^^^^^^^^^^^^^^^^^^^^
:22:13 note: while instantiating parameter v
fn doWork ( v: array<vec4<f32>,3780060> ) -> array<vec4<f32>>{
^
- While validating [ShaderModuleDescriptor "compute"]
- While calling [Device].CreateShaderModule([ShaderModuleDescriptor "compute"]).