Quick answer: SPIRV-Cross cross-compiling SPIR-V to GLSL for mobile / WebGL emitting precision-related warnings or wrong output? Default precision must be declared in GLSL ES.

A SPIR-V shader cross-compiled to GLSL ES 3.0 produces precision warnings; the mobile build crashes on shader load.

Declare Default Precision

precision mediump float;
precision mediump int;

Top of fragment shader. GLSL ES requires this; desktop GLSL doesn’t. SPIRV-Cross emits it but may pick lowp by default; mediump usually safer.

Per-Variable Precision

For specific variables: highp vec3 position;. Use highp for positions, normals; mediump for everything else — balance precision and perf.

Target Profile

Pass the right target version to SPIRV-Cross (e.g. --es --version 300). Different profiles emit different idioms.

Validate Output

Run the emitted GLSL through a validator (glslangValidator) before shipping. Catches issues before device.

Verifying

Cross-compiled GLSL runs cleanly on target devices. No precision warnings; no crashes.

“GLSL ES needs default precision. SPIRV-Cross emits it but tune to your needs.”

Test on a low-end mobile device every release — precision issues only surface where they bite.