pub fn inject_truncations(src: &str, table: &SymbolTable) -> StringExpand description
Walk var X: TYPE = <expr>; (or let) declarations and fix HLSL-
implicit-conversion mismatches between LHS type and RHS type:
f32 = vec: rewrite RHS to(<expr>).x(HLSL truncation).vec = scalar: rewrite RHS tovecN<f32>(<expr>)(HLSL broadcast).
The pass is intentionally conservative: only fires when the LHS type
is known and the inferred RHS type is the other of the two cases
above. Anything ambiguous (Unknown RHS) passes through.
Why this exists: MD2 user shaders frequently write
float3 bg = pow(length(dz), 0.7)*2 + GetBlur1(uv).y*2; — RHS is
scalar, LHS is vec3; HLSL silently broadcasts, WGSL rejects with
the type of bg is expected to be vec3<f32> but got f32. Mirror
case: float lum = GetPixel(uv) * c.x; — RHS vec3, LHS f32.