Use of Structs in wgslFn (TSL)

I’m trying to use a wgslFn like

const computeShader = wgslFn(/* wgsl */`
		struct SomeOtherData {
			first: f32,
			second: f32,
			firstInt: i32,
			secondInt: i32,
		}
		fn compute(
		  positionBuffer: ptr<storage, array<vec3<f32>>, read_write>,  
		  velocitiesBuffer: ptr<storage, array<vec3<f32>>, read_write>,
		  otherData: ptr<storage, array<SomeOtherData>, read_write>,
		  index: u32,
		  deltaTime: f32,
		  gravity: vec3<f32>
		) -> void {
			// Use the otherData somehow
			velocitiesBuffer[index] += gravity * deltaTime;
			positionBuffer[index] += velocitiesBuffer[index] * deltaTime;
		}
	`);

	const computeShaderParams = {
		positionBuffer: positionsStorage,
		velocitiesBuffer: velocitiesStorage,
		otherData: otherDataStorage,
		index: instanceIndex,
		deltaTime: deltaTime,
		gravity: gravity
	}

	const computePositions = computeShader(computeShaderParams).compute(positionBuffer.count);

Doing this gets the error

Uncaught Error: FunctionNode: Function is not a WGSL code.

This only happens when I have a struct definition in the wgslFn. I am unsure of how to have more interesting datatypes exist in a wgslFn.

Ideally I would like to move entirely away from using anything TSL (there is simply not enough documentation), but I am not sure of how to have a shared position buffer between ThreeJs and a webgpu object created like

const positionStorage= device.createBuffer({
  label: "Vertex Positions",
  size: positionArray.byteLength,
  usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
});

Any help with this would be much appreciated, or just pointing me to more extensive documentation than the examples (which all use pure TSL) or the github docs.

I am no expert here, but I used structures a lot when I created programs in 68k assembly language.

In js, I found that I could do essentially the same thing by creating a parent variable which contains sub-variables. Most of my js variables are now defined this way.

I have not found that either option is available in wgslFn. I you want to create a struct-type variable, you can do that in js. But before you call a wgslFn function from js, you must pass the individual js sub-variables to separate wgslFn variables.

In your case, you would have to delete the struct envelope move the individual components into the area before void.

Let me know if you ever find a “structure-equivalent” for wgslFn.