Skip to content

Commit

Permalink
Improve cpp prelude. (shader-slang#3725)
Browse files Browse the repository at this point in the history
  • Loading branch information
csyonghe authored and djohansson committed Sep 21, 2024
1 parent 9fdbbd9 commit 13a3f31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions prelude/slang-cpp-scalar-intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ SLANG_FORCE_INLINE float _bitCastUIntToFloat(uint32_t ui) { Union32 u; u.u = ui;


// This impl is based on FloatToHalf that is in Slang codebase
uint32_t f32tof16(const float value)
SLANG_FORCE_INLINE uint32_t f32tof16(const float value)
{
const uint32_t inBits = _bitCastFloatToUInt(value);

Expand Down Expand Up @@ -97,7 +97,7 @@ uint32_t f32tof16(const float value)

static const float g_f16tof32Magic = _bitCastIntToFloat((127 + (127 - 15)) << 23);

float f16tof32(const uint32_t value)
SLANG_FORCE_INLINE float f16tof32(const uint32_t value)
{
const uint32_t sign = (value & 0x8000) << 16;
uint32_t exponent = (value & 0x7c00) >> 10;
Expand Down Expand Up @@ -469,7 +469,7 @@ SLANG_FORCE_INLINE int64_t I64_max(int64_t a, int64_t b) { return a > b ? a : b;
# include <intrin.h>
# endif

void InterlockedAdd(uint32_t* dest, uint32_t value, uint32_t* oldValue)
SLANG_FORCE_INLINE void InterlockedAdd(uint32_t* dest, uint32_t value, uint32_t* oldValue)
{
# ifdef _WIN32
*oldValue = _InterlockedExchangeAdd((long*)dest, (long)value);
Expand Down
3 changes: 3 additions & 0 deletions prelude/slang-cpp-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
namespace SLANG_PRELUDE_NAMESPACE {
#endif

#ifndef SLANG_FORCE_INLINE
# define SLANG_FORCE_INLINE inline
#endif

#include "slang-cpp-types-core.h"

Expand Down

0 comments on commit 13a3f31

Please sign in to comment.