translate_shader

Function translate_shader 

Source
pub fn translate_shader(hlsl: &str) -> Result<String>
Expand description

Translate HLSL shader code to WGSL.

The pipeline is intentionally linear:

  1. strip the MD2 shader_body { ... } outer wrapper,
  2. type-substitute (float4 → vec4<f32>, …),
  3. function-substitute (lerp → mix, tex2D → textureSample, …),
  4. rewrite typed local declarations into WGSL var ident: T = …; form,
  5. strip HLSL semantics (: POSITION, …).