pub(crate) fn inject_qa_stub(src: &str) -> StringExpand description
_qa/_qb/…/_qh are MD2 runtime-defined aliases that pack the 32
q1..q32 evaluator channels into 8 × float4 (_qa = float4(q1, q2, q3, q4),
_qb = float4(q5, …), etc.). User comp shaders read them directly,
typically via mul(uv, float2x2(_qb)) for kaleidoscope rotation.
The standalone HLSL parser never sees their declarations because they
live in the host-provided prelude — naga rejects with
no definition in scope for identifier: '_qb'. We stub the full
_qa..._qh family — many presets reference _qb and a long tail of
the others.
For each referenced identifier we:
- prepend
float4 _qX = float4(0.0, 0.0, 0.0, 0.0);at the start ofshader_body { ... }so any later read picks up a defined value, and - expand every
float2x2(_qX)call into the four-scalar constructor formfloat2x2(_qX.x, _qX.y, _qX.z, _qX.w)so it survivesreplace_typesinto a validmat2x2<f32>(...)call (WGSL refuses the single-vec4 form).
If no _qX identifier is referenced, returns the input unchanged.