From 6d4c5396771c66b283540591e5772dceab09719f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Thu, 28 Nov 2024 14:41:05 +0100 Subject: [PATCH] Fix compilation with icx 2025 --- .../include/openvkl/VKLBackgroundUndefined.h | 23 ++++++++++-- openvkl/include/openvkl/ispc_cpp_interop.h | 36 ------------------- 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/openvkl/include/openvkl/VKLBackgroundUndefined.h b/openvkl/include/openvkl/VKLBackgroundUndefined.h index 567a1964..fb7dd53d 100644 --- a/openvkl/include/openvkl/VKLBackgroundUndefined.h +++ b/openvkl/include/openvkl/VKLBackgroundUndefined.h @@ -3,11 +3,28 @@ #pragma once -#include "ispc_cpp_interop.h" - // A special value we use to distinguish an undefined field value. This could // be the result of sampling out of bounds, or sampling at a position in bounds // but not covered by any input data. // This value is a quiet NaN. -#define VKL_BACKGROUND_UNDEFINED floatbits(0xFFC068B5u) +#ifdef ISPC +#define vkl_floatbits floatbits +#else +#if defined(__cplusplus) +#include +#include +using std::memcpy; +#else +#include +#include +#endif +inline float vkl_floatbits(uint32_t bits) +{ + float fval; + memcpy(&fval, &bits, 4); + return fval; +} +#endif + +#define VKL_BACKGROUND_UNDEFINED vkl_floatbits(0xFFC068B5u) diff --git a/openvkl/include/openvkl/ispc_cpp_interop.h b/openvkl/include/openvkl/ispc_cpp_interop.h index 26cdbfb1..a932426e 100644 --- a/openvkl/include/openvkl/ispc_cpp_interop.h +++ b/openvkl/include/openvkl/ispc_cpp_interop.h @@ -79,42 +79,6 @@ #endif // defined(__cplusplus) -// ----------------------------------------------------------------------------- -// Standard library functions. -// ----------------------------------------------------------------------------- - -#if defined(__cplusplus) - -inline float floatbits(vkl_uint32 bits) -{ - VKL_INTEROP_STATIC_ASSERT(sizeof(float) == sizeof(vkl_uint32), - "Float is not 4 Bytes."); - float fval = 0.f; - reinterpret_cast(&fval)[0] = reinterpret_cast(&bits)[0]; - reinterpret_cast(&fval)[1] = reinterpret_cast(&bits)[1]; - reinterpret_cast(&fval)[2] = reinterpret_cast(&bits)[2]; - reinterpret_cast(&fval)[3] = reinterpret_cast(&bits)[3]; - return fval; -} - -inline vkl_uint32 intbits(float value) -{ - VKL_INTEROP_STATIC_ASSERT(sizeof(float) == sizeof(vkl_uint32), - "Float is not 4 Bytes."); - vkl_uint32 ival = 0; - reinterpret_cast(&ival)[0] = - reinterpret_cast(&value)[0]; - reinterpret_cast(&ival)[1] = - reinterpret_cast(&value)[1]; - reinterpret_cast(&ival)[2] = - reinterpret_cast(&value)[2]; - reinterpret_cast(&ival)[3] = - reinterpret_cast(&value)[3]; - return ival; -} - -#endif - // ----------------------------------------------------------------------------- // Helpers for univary definitions. // -----------------------------------------------------------------------------