rewrite_vec_scalar_compare

Function rewrite_vec_scalar_compare 

Source
pub(crate) fn rewrite_vec_scalar_compare(src: &str) -> String
Expand description

HLSL auto-broadcasts the scalar operand of a comparison (vec3 >= 0.1 → element-wise vec3 >= float3(0.1)); WGSL rejects vec3<f32> >= f32 with InvalidBinaryOperandTypes (a dominant validate-stage cluster, op=Ge/Le/Gt/Lt/Eq/Ne with lhs_type: Vector). Wraps the scalar operand in a vecN<f32>(…) constructor so the comparison evaluates as a vector-bool.

Stays conservative: only fires when one side is a known vector and the other is a known scalar f32. (a < b) <= c chained comparisons (where one side is already bool) are left alone — they belong to the eval long-tail, not this cluster.