Skip to content

nir/lower_blend: Use correct clamp for SNORM

Alyssa Rosenzweig requested to merge alyssa/mesa:render-snorm into main

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.

Cc @kusma

Merge request reports