diff --git a/src/util/util_bit.h b/src/util/util_bit.h index b8b2cee82..661bb51fa 100644 --- a/src/util/util_bit.h +++ b/src/util/util_bit.h @@ -15,7 +15,20 @@ #include "util_likely.h" +#include +#include + namespace dxvk::bit { + + template + T cast(const J& src) { + static_assert(sizeof(T) == sizeof(J)); + static_assert(std::is_trivially_copyable::value && std::is_trivial::value); + + T dst; + std::memcpy(&dst, &src, sizeof(T)); + return dst; + } template T extract(T value, uint32_t fst, uint32_t lst) {