mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 18:38:11 +02:00
nir/format_convert: Use fmin/fmax to clamp R9G9B9E5 data
As long as drivers implement an fmin/fmax that do the right thing with NaN, there's no reason for the integer comparison. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28793>
This commit is contained in:
parent
86aad90e2a
commit
5b9ac9a68f
1 changed files with 10 additions and 6 deletions
|
|
@ -408,12 +408,16 @@ nir_format_pack_r9g9b9e5(nir_builder *b, nir_def *color)
|
|||
{
|
||||
/* See also float3_to_rgb9e5 */
|
||||
|
||||
/* First, get rid of negatives and NaN */
|
||||
nir_def *clamped = nir_bcsel(b, nir_ugt_imm(b, color, 0x7f800000),
|
||||
nir_imm_float(b, 0), clamped);
|
||||
|
||||
/* Clamp it to range. */
|
||||
clamped = nir_fmin(b, color, nir_imm_float(b, MAX_RGB9E5));
|
||||
/* First, we need to clamp it to range. The fmax(color, 0) will also flush
|
||||
* NaN to 0. We set exact to ensure that nothing optimizes this behavior
|
||||
* away from us.
|
||||
*/
|
||||
float exact_save = b->exact;
|
||||
b->exact = true;
|
||||
nir_def *clamped =
|
||||
nir_fmin(b, nir_fmax(b, color, nir_imm_float(b, 0)),
|
||||
nir_imm_float(b, MAX_RGB9E5));
|
||||
b->exact = exact_save;
|
||||
|
||||
/* maxrgb.u = MAX3(rc.u, gc.u, bc.u); */
|
||||
nir_def *maxu = nir_umax(b, nir_channel(b, clamped, 0),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue