From 8bce68edf553c079ed8451ecf24dd2831f409c25 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Thu, 27 Jul 2023 12:18:51 +0200 Subject: [PATCH] etnaviv: switch to U_FIXED(..) macro Lets have a look at trace from blob (GC3000): 0x000b000b, /* [10080] NTE.SAMPLER[0].SIZE := WIDTH=11,HEIGHT=11 */ 0x2001b86e, /* [10100] NTE.SAMPLER[0].LOG_SIZE := WIDTH=3.437500,HEIGHT=3.437500,ASTC=0,INT_FILTER=1,SRGB=0 */ If we ignore the WIDTH and HEIGHT outputs and only look at the raw value (0x2001b86e) we can see that 0x6e is used for WIDTH and HEIGHT. Lets have a look at an other texutre size 180x180: 0x00b400b4, /* [10080] NTE.SAMPLER[0].SIZE := WIDTH=180,HEIGHT=180 */ 0x2003bcef, /* [10100] NTE.SAMPLER[0].LOG_SIZE := WIDTH=7.468750,HEIGHT=7.468750,ASTC=0,INT_FILTER=1,SRGB=0 */ Lets use the same test on a different GPU that uses texture descriptors (GC7000): [44] SIZE: 0x000b000b WIDTH=11,HEIGHT=11 ... [74] LOG_SIZE_EXT: 0x03750375 WIDTH=3.457031,HEIGHT=3.457031 If we ignore the WIDTH and HEIGHT outputs and only look at the raw value (0x03750375) we can see that 0x375 is used for WIDTH and HEIGHT. Lets have a look at an other texutre size 180x180: [44] SIZE: 0x00b400b4 WIDTH=180,HEIGHT=180 .. [74] LOG_SIZE_EXT: 0x077d077d WIDTH=7.488281,HEIGHT=7.488281 etnaviv creates the following values for the two texture sizes: 11 -> 0x6f 180 -> 0xf0 Lets switch to U_FIXED(..) which results in equal values. Signed-off-by: Christian Gmeiner Reviewed-by: Lucas Stach Part-of: --- src/gallium/drivers/etnaviv/etnaviv_util.h | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_util.h b/src/gallium/drivers/etnaviv/etnaviv_util.h index 5caf17e..0c2b98b 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_util.h +++ b/src/gallium/drivers/etnaviv/etnaviv_util.h @@ -26,6 +26,7 @@ #define H_ETNA_UTIL #include +#include "mesa/main/macros.h" /* for conditionally setting boolean flag(s): */ #define COND(bool, val) ((bool) ? (val) : 0) @@ -47,26 +48,14 @@ etna_cfloat_to_uint8(float f) static inline uint32_t etna_float_to_fixp55(float f) { - if (f >= 15.953125f) - return 511; - - if (f < -16.0f) - return 512; - - return (int32_t)(f * 32.0f + 0.5f); + return U_FIXED(f, 5); } /* float to fixp 8.8 */ static inline uint32_t etna_float_to_fixp88(float f) { - if (f >= (32767.0 - 1.0f) / 256.0f) - return 32767; - - if (f < -16.0f) - return 32768; - - return (int32_t)(f * 256.0f + 0.5f); + return U_FIXED(f, 8); } /* texture size to log2 in fixp 5.5 format */ -- 2.7.4