Quick answer: SPIR-V Cross translating [unroll] differently across HLSL and GLSL outputs? The decoration survives but the loop count must be a compile-time constant in both - audit the bounds.

HLSL loop with [unroll(8)] translates to a hand-unrolled GLSL output on D3D but stays as a for-loop on OpenGL.

Use compile-time bounds

#define SAMPLES 8
[unroll(SAMPLES)] for ...

Constant bounds let every translator unroll. Variable bounds can't unroll deterministically.

Manually unroll critical loops

For hot inner loops, unroll in source. Translator-independent; readable for the people who'll maintain the shader.

Profile per-backend

The visual output is identical but performance can differ 2x between unrolled and loop variants. Test on each backend you ship.

“Optimization pragmas are hints. Cross-compiled hints are softer hints.”

If you have hot shader loops, prefer manual unrolling. The pragma is convenience; the manual version is portable.