Skip to content

Commit

Permalink
Fix compilation with icx 2025
Browse files Browse the repository at this point in the history
  • Loading branch information
johguenther committed Nov 28, 2024
1 parent bc3b327 commit 6d4c539
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 39 deletions.
23 changes: 20 additions & 3 deletions openvkl/include/openvkl/VKLBackgroundUndefined.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstdint>
#include <cstring>
using std::memcpy;
#else
#include <stdint.h>
#include <string.h>
#endif
inline float vkl_floatbits(uint32_t bits)
{
float fval;
memcpy(&fval, &bits, 4);
return fval;
}
#endif

#define VKL_BACKGROUND_UNDEFINED vkl_floatbits(0xFFC068B5u)
36 changes: 0 additions & 36 deletions openvkl/include/openvkl/ispc_cpp_interop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<char *>(&fval)[0] = reinterpret_cast<const char *>(&bits)[0];
reinterpret_cast<char *>(&fval)[1] = reinterpret_cast<const char *>(&bits)[1];
reinterpret_cast<char *>(&fval)[2] = reinterpret_cast<const char *>(&bits)[2];
reinterpret_cast<char *>(&fval)[3] = reinterpret_cast<const char *>(&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<char *>(&ival)[0] =
reinterpret_cast<const char *>(&value)[0];
reinterpret_cast<char *>(&ival)[1] =
reinterpret_cast<const char *>(&value)[1];
reinterpret_cast<char *>(&ival)[2] =
reinterpret_cast<const char *>(&value)[2];
reinterpret_cast<char *>(&ival)[3] =
reinterpret_cast<const char *>(&value)[3];
return ival;
}

#endif

// -----------------------------------------------------------------------------
// Helpers for univary definitions.
// -----------------------------------------------------------------------------
Expand Down

0 comments on commit 6d4c539

Please sign in to comment.