webgpuTexelBytes function
How many bytes one texel of format takes, for the uploads that state a row
stride.
Only the formats something in this engine actually uploads from the host have an answer: eight-bit colour, the two float layouts the morph and lightmap paths use, and the one- and two-channel maps. A format with no answer is a texture this backend refuses to create from pixels rather than one it fills with the wrong stride — which is a picture, and a plausible one.
Implementation
int? webgpuTexelBytes(TextureFormat format) => switch (format) {
TextureFormat.r8UNormInt => 1,
TextureFormat.r8g8UNormInt => 2,
TextureFormat.r8g8b8a8UNormInt ||
TextureFormat.r8g8b8a8UNormIntSRGB ||
TextureFormat.b8g8r8a8UNormInt ||
TextureFormat.b8g8r8a8UNormIntSRGB ||
TextureFormat.r32Float => 4,
TextureFormat.r16g16b16a16Float => 8,
TextureFormat.r32g32b32a32Float => 16,
_ => null,
};