-
-
Notifications
You must be signed in to change notification settings - Fork 36k
Description
Description
*Related Issues: #30394
@sunag
I'm now getting a different issue where a TSL inline function (i.e a function that generates code inline within the main function) that calls a setLayout function is not properly defining the structType in every file where that struct type appears.
For instance my computeHeight function calls an inline TSL function GetNeighborValues() which calls a setLayout function GetNeighborIndices(). My computeSmooth function calls the exact same function. However, on compilation, while both functions will properly generate the GetNeighborIndices function in WGSL, the computeHeight function generates the NeighborIndicesStructType in WGSL while the computeSmooth function does not.
I've updated the link with these changes. Clicking the computeSmooth function call will result in this compilation error:

Reproduction steps
- In webgpu_compute_water, replace the current call to getNeighborIndicesTSL with a defined function executing the same code, but created with set layout.
- Have that function return a struct type for the relevant returned values.
Code
Relevant TSL calls are below. destructureStruct is simply a convenience function. The WGSL output does not meaningfully change irrespective of whether it is used or not
// Struct Definition
const NeighborIndicesStructure = {
northIndex: 'uint',
eastIndex: 'uint',
southIndex: 'uint',
westIndex: 'uint',
};
const NeighborIndicesStruct = struct( NeighborIndicesStructure, 'NeighborIndicesStructType' );
const NeighborValuesStruct = struct( NeighborValuesStructure, 'NeighborValuesStructType' );
// Compute Height shader
```ts
// This codepath calls GetNeighborIndices and properly generates the NeighborIndicesStructType returned by GetNeighborIndices
const { north, south, east, west } = destructureStruct( NeighborValuesStructure, GetNeighborValues( instanceIndex, heightStorage ) );
// Compute smooth shader
// This code path calls GetNeighborIndices and does not generate the NeighborIndicesStructType returned by GetNeighborIndices
const { north: northH, south: southH, east: eastH, west: westH } = destructureStruct( NeighborValuesStructure, GetNeighborValues( instanceIndex, heightStorage ) );
Live example
Screenshots
No response
Version
r173
Device
Desktop
Browser
Chrome
OS
Windows