On Fri Apr 5 11:40:02 2024 +0000, Giovanni Mascellani wrote:
Notice that native too might become unable to unroll a loop if you force it to lose the information of what is the iteration instruction. Compare for example https://shader-playground.timjones.io/5e211ad0eacd7f37429eed7821208dec and https://shader-playground.timjones.io/bbdbef08299b83cc0427884d49d656fc. Copying those shaders here to avoid depending on a possibly ephemeral site:
```hlsl Buffer<float> buf; float4 main() : sv_target { float a = 0.0; int i = 0; [unroll] for (;; ++i) { if (!(i < 4)) break; if (buf[i] < 0.1) break; if (buf[i] < 0.2) continue; a += buf[i]; } return a; } ``` ```hlsl Buffer<float> buf; float4 main() : sv_target { float a = 0.0; int i = 0; [unroll] for (;;) { if (!(i < 4)) break; if (buf[i] < 0.1) break; if (buf[i] < 0.2) { ++i; continue; } a += buf[i]; ++i; } return a; } ``` -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/748#note_67067