mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-02 11:00:27 +01:00
gallium/util: add bitcast helpers for double and uint
This complements u_bitcast_f2u and u_bitcast_u2f with similar helpers to cast between double and unsigned integers as well. Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com> Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8034>
This commit is contained in:
parent
615c4610bb
commit
c314893988
1 changed files with 16 additions and 0 deletions
|
|
@ -45,6 +45,14 @@ u_bitcast_f2u(float f)
|
|||
return u;
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
u_bitcast_d2u(double d)
|
||||
{
|
||||
uint64_t u;
|
||||
memcpy(&u, &d, sizeof(u));
|
||||
return u;
|
||||
}
|
||||
|
||||
static inline float
|
||||
u_bitcast_u2f(uint32_t u)
|
||||
{
|
||||
|
|
@ -53,6 +61,14 @@ u_bitcast_u2f(uint32_t u)
|
|||
return f;
|
||||
}
|
||||
|
||||
static inline double
|
||||
u_bitcast_u2d(uint64_t u)
|
||||
{
|
||||
double d;
|
||||
memcpy(&d, &u, sizeof(d));
|
||||
return d;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue