Extend WGSL to Support Additional Integer Types
Currently, WGSL supports only 32-bit integer types (i32 and u32). Many applications could greatly benefit from native support for additional integer types, such as i8, i16, i64, u8, u16, and u64.
- Supporting smaller integer sizes (i8, i16, u8, u16) would enable more compact data representations, reducing memory usage and potentially improving cache performance.
- Larger integer types (i64, u64) allow handling of larger numbers natively, which is useful for high-precision computations and applications requiring extended numerical ranges.
- Enhanced integer support can benefit many things but primarily AI and video work where 8 and 16 bit buffers are common.
64-bit integer math is not supported by Mac2 Metal feature sets - https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf but it seems like an extension would be reasonable.
I developed a WebGPU-based BLAKE2b implementation, and it performs approximately 20-30% slower than an equivalent OpenCL-based implementation primarily due to the extra operations required for arithmetic on 32-bit integer pairs to represent the 64-bit values defined by the algorithm. Extending WGSL to support u64 could bring it up to par with OpenCL for my project.
There is also a preceding issue for integers other than 32-bit: https://github.com/gpuweb/gpuweb/issues/273
Enhanced integer support can benefit many things but primarily AI and video work where 8 and 16 bit buffers are common.
When the buffer is a large array of small ints, the use case may be covered by storage texel buffers. See #162
Closing as duplicate of #273