etnaviv: switch to S_FIXED(..) macro
authorChristian Gmeiner <cgmeiner@igalia.com>
Thu, 27 Jul 2023 13:12:59 +0000 (15:12 +0200)
committerMarge Bot <emma+marge@anholt.net>
Mon, 14 Aug 2023 14:10:15 +0000 (14:10 +0000)
In different traces for different GPU models I see the same pattern:
    0x00c80000, /*   [00A00] PA.VIEWPORT_SCALE_X = 200.000000 */
    0xff880000, /*   [00A04] PA.VIEWPORT_SCALE_Y = -120.000000 */

etna_f32_to_fixp16(..) handles the negative case differently then blob. In the
concrete example -120 gets converted to 0xff880001. Switch to S_FIXED(..) to
simplify our code and to get the same results as blob.

Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24364>

src/gallium/drivers/etnaviv/etnaviv_util.h

index 0c2b98b..c2ecb02 100644 (file)
@@ -76,13 +76,7 @@ etna_log2_fixp88(unsigned width)
 static inline uint32_t
 etna_f32_to_fixp16(float f)
 {
-   if (f >= (32768.0f - 1.0f / 65536.0f))
-      return 0x7fffffff;
-
-   if (f < -32768.0f)
-      return 0x80000000;
-
-   return (int32_t)(f * 65536.0f + 0.5f);
+   return S_FIXED(f, 16);
 }
 
 #endif