strip_shader_body_wrapper

Function strip_shader_body_wrapper 

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

MD2 ships warp/comp shaders wrapped in a shader_body { ... } block. The codegen wrapper pastes the user code inside its own fs_main { ... }, so the outer wrapper has to come off first — otherwise WGSL sees a stray identifier (shader_body) followed by { and fails with expected assignment or increment/decrement, found "{".

If the input has no shader_body wrapper (synthetic test shaders, or a preset that already inlines the body), the input is returned unchanged.