nir/lower_blend: Use correct clamp for SNORM

nir_lower_blend was written against the OpenGL ES 3.2 specification,
which does not support blending SNORM render targets. The ES spec
says that non-floating point buffers get clamped to [0, 1] before
blending. The story is not so simple: SNORM buffers are blendable in
OpenGL and must clamped to [-1, 1] rather than [0, 1]. Handle this case.

NIR does have the fsat_signed_mali instruction to clamp to [-1, 1], but
it is only implemented in Panfrost, and this pass is in common code.
Open code it instead. Panfrost optimizes the open coded version, so this
is good enough.

Fixes SNORM subtests of Piglit arb_texture_view-rendering-formats.

Signed-off-by: Alyssa Rosenzweig <>
Reviewed-by: Jason Ekstrand <>
Reviewed-by: Boris Brezillon <>
Part-of: <!13499>
144 jobs for !13499 with render-snorm in 51 minutes and 45 seconds (queued for 15 seconds)
latest merge request