Quick answer: SPIR-V validation reporting non-uniform control flow on Mali GPUs while desktop NVIDIA passes? Mali's compiler is stricter about derivative ops under dynamic branches - hoist the sample call.

Shader works on desktop, fails Mali validation: derivative operation in non-uniform control flow. The branch on vDiscard is the trigger.

Sample before branching

vec4 tex = texture(sampler, uv);
if (vDiscard > 0.5) discard;

Mali's compiler refuses derivative ops (which texture sampling uses for mip selection) inside dynamic branches. Hoist the sample to before the branch.

Or use textureLod

textureLod(sampler, uv, 0.0) sidesteps derivatives - explicit mip level. Useful when you really do need to sample inside a branch.

Validate with spirv-val

spirv-val --target-env vulkan1.1 shader.spv

Catches the issue before you ship. Add to CI; runs in milliseconds.

“SPIR-V validation is a contract. Vendors that allow violations don't make the violations correct.”

If your game targets mobile, run spirv-val as part of every shader build. The class of bug it catches takes hours to track from a crash report.