Naga should map `break if` 1:1 to the backend (i.e. `do`-`while` for GLSL/HLSL/MSL).
Quoting myself from https://github.com/gfx-rs/wgpu/issues/4558:
I do not understand why
break ifturns into that kind of conditionalbreak.AIUI it was only added to WGSL to represent SPIR-V conditional backedges. And SPIR-V itself only has conditional backedges to encode
do-whileloops. So that's the natural translation.That is,
loop { ... continuing { ... break if !(select(false, true, _e23)); } }should turn intodo { ... } while(!!(_e23 ? true : false));- without any overcomplicated propagation across the backedge.
I believe Naga already maps break if 1:1 to WGSL (as expected) and to SPIR-V (as conditional backedges).
So only the C-like backends (GLSL/HLSL/MSL) remain, and they should all allow a 1:1 mapping via do-while.
Source: gfx-rs/wgpu