diff --git a/src/webgpu/shader/execution/expression/expression.ts b/src/webgpu/shader/execution/expression/expression.ts index 0359e6e901a1..e86d068c6daa 100644 --- a/src/webgpu/shader/execution/expression/expression.ts +++ b/src/webgpu/shader/execution/expression/expression.ts @@ -158,7 +158,10 @@ function wgslMembers(members: Type[], source: InputSource, memberName: (i: numbe }); const padding = layout.stride - layout.size; if (padding > 0) { - lines.push(` @size(${padding}) padding : i32,`); + // Pad with a 'f16' if the padding requires an odd multiple of 2 bytes. + // This is required as 'i32' has an alignment and size of 4 bytes. + const ty = (padding & 2) !== 0 ? 'f16' : 'i32'; + lines.push(` @size(${padding}) padding : ${ty},`); } return lines.join('\n'); }