Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
cdcc9ad
Initial commit
Fletterio Mar 21, 2025
8e84558
Merge branch 'concepts_fix' into mortons
Fletterio Mar 21, 2025
d33fab5
Merge branch 'concepts_fix' into mortons
Fletterio Mar 21, 2025
5fe6c08
CHeckpoint before master merge
Fletterio Mar 23, 2025
f18b2fa
Checkpoint before merging new type_traits change
Fletterio Mar 24, 2025
7d86cba
Merge branch 'master' into mortons
Fletterio Mar 24, 2025
4ebc555
Works, but throws DXC warning
Fletterio Mar 24, 2025
55a2ef6
Added concept for valid morton dimensions
Fletterio Mar 24, 2025
f516256
Creation from vector working as intended
Fletterio Mar 25, 2025
534d81b
Added some extra macro specifiers, vector truncation with no warnings…
Fletterio Mar 26, 2025
6256390
Add safe copile-time vector truncation and some function specifiers f…
Fletterio Mar 26, 2025
246cefc
Morton class done!
Fletterio Mar 27, 2025
1c7f791
Remove some leftover commented code
Fletterio Mar 27, 2025
5088799
Remove leaking macro
Fletterio Mar 27, 2025
e25a35c
Bugfixes with arithmetic
Fletterio Mar 28, 2025
0d9dd4a
Checkpoint, have to check why vector compat isn't working
Fletterio Apr 1, 2025
89d2bf2
Refactor morton class, get new conversion running
Fletterio Apr 2, 2025
de4d0fb
Add new classes for encoding/decoding of mortn codes
Fletterio Apr 3, 2025
799420e
Fix conversion operators
Fletterio Apr 4, 2025
52323bc
Finish the rest of comparison ops and we're done!
Fletterio Apr 5, 2025
b6b7003
Final Mortons
Fletterio Apr 7, 2025
60ff99a
Clean up the emulated int code, fix some constant creation in the mor…
Fletterio Apr 8, 2025
5560162
Addressing latest PR review. Generic overloads for of different func…
Fletterio Apr 8, 2025
e50c56b
Bunch of emulated int64 fixes regarding creation, comparison operator…
Fletterio Apr 9, 2025
b1de9c3
Fix automatic specialize macro in cpp compat intrinsics, add intrins…
Fletterio Apr 9, 2025
ea8cd43
Checkpoint: adding a bunch of operators to emulated vector types
Fletterio Apr 11, 2025
53a5f6a
Vectorized encode/decode for better pipelining
Fletterio Apr 11, 2025
cf52d9c
Adress the last of PR review changes: vectorize more operators, add a…
Fletterio Apr 14, 2025
f954522
Removed `NBL_CONSTEXPR_INLINE_FUNC` macro, replaced all usages with
Fletterio Apr 24, 2025
2d0ffba
Fix the last of the operators
Fletterio Apr 28, 2025
68edc32
Change examples test submodule for master merge
Fletterio Apr 28, 2025
5013c89
Merged master
Fletterio Apr 28, 2025
c53668c
Merge branch 'master' into mortons
Nov 19, 2025
977c7dd
Add constexpr to _static_cast
Nov 20, 2025
3294d04
Change NBL_CONSTEXPR_STATIC_FUNC to NBL_CONSTEXPR_STATIC
Nov 20, 2025
e2401c6
Add template<> to signify specialization
Nov 20, 2025
07f7a4a
Remove duplicate partial specialization.
Nov 20, 2025
42baa6c
Change NBL_CONSTEXPR_STATIC_FUNC to NBL_CONSTEXPR_STATIC
Nov 20, 2025
22e78eb
Fix concatenation of 'operator' and OP with '##' since operatorOP is …
Nov 20, 2025
8daf855
'equals' to 'equal'
Nov 20, 2025
831244f
Pass vec by value not ref
Nov 20, 2025
a560180
Use truncate to truncate
Nov 20, 2025
e320ed8
Make morton compile
Nov 22, 2025
83d27c9
NBL_CONSTEXPR_INLINE_VAR for template constexpr variable
Nov 27, 2025
c496916
Promote and Truncate take vector and scalar by value and the rest by …
Nov 28, 2025
d7bd053
Remove promote and truncate comment about specialization
Nov 28, 2025
3f3a23e
Add comment to rename log2
Nov 28, 2025
8dcdfdd
Change dimension type from uint16_t to int32_t
Nov 28, 2025
92cd9e7
Redefine some macro
Nov 28, 2025
7f6d8b8
use const instead of static const for local variable in hlsl
Nov 28, 2025
1d9ce20
Rename NBL_CONSTEXPR_INLINE to NBL_CONSTEXPR_INLINE_NSPC_SCOPE_VAR
Nov 28, 2025
1eded12
Refactor emulated_integral_64
Dec 1, 2025
aa9e24d
Add unary_minus_operator class
Dec 1, 2025
6683cd5
Remove commented code on emulated/vector_t.hlsl
Dec 1, 2025
cdb6ad7
Unify all Truncate specializaton for vector type
Dec 1, 2025
c365240
Fix promote.hlsl and reduce the amount of specialization for Promote
Dec 1, 2025
ec1d674
Make promote constrainable
Dec 1, 2025
51e35cf
equal to _equal
Dec 1, 2025
062ce7b
Remove some constraint in morton::code::create
Dec 1, 2025
6c82428
Remove NBL_CONSTEXPR_STATIC_INLINE_VAR macro
Dec 2, 2025
ca2ac6f
Remove Bit count constraint on some of Transcoder method due to redun…
Dec 2, 2025
4c9635d
Use cpp syntax instead of portable macro wherever possible
Dec 2, 2025
23292bd
Fix morton code constraint
Dec 3, 2025
5da522e
Add assert in morton code creation
Dec 3, 2025
812ae7b
Fix is_emulating concepts
Dec 3, 2025
341d6cd
Move storage_t to common_inc
Dec 3, 2025
2fd2cba
Rename ImitationIntegral64Scalar to EmulatedIntegral64Scalar
Dec 3, 2025
1255d1c
Fix extent and remove duplicated extent specialization
Dec 3, 2025
527129f
Remove redundant extent
Dec 3, 2025
ed696ef
Fix unary_minus_operator
Dec 3, 2025
4da1fb8
Fix redundant extent specialization
Dec 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions include/nbl/builtin/hlsl/algorithm.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,71 +19,71 @@ namespace impl
// TODO: use structs

template<typename T>
NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(T) lhs, NBL_REF_ARG(T) rhs)
NBL_CONSTEXPR_FUNC void swap(NBL_REF_ARG(T) lhs, NBL_REF_ARG(T) rhs)
{
T tmp = lhs;
lhs = rhs;
rhs = tmp;
}

template<>
NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(uint16_t) lhs, NBL_REF_ARG(uint16_t) rhs)
NBL_CONSTEXPR_FUNC void swap(NBL_REF_ARG(uint16_t) lhs, NBL_REF_ARG(uint16_t) rhs)
{
lhs ^= rhs;
rhs ^= lhs;
lhs ^= rhs;
}

template<>
NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(uint32_t) lhs, NBL_REF_ARG(uint32_t) rhs)
NBL_CONSTEXPR_FUNC void swap(NBL_REF_ARG(uint32_t) lhs, NBL_REF_ARG(uint32_t) rhs)
{
lhs ^= rhs;
rhs ^= lhs;
lhs ^= rhs;
}

template<>
NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(uint64_t) lhs, NBL_REF_ARG(uint64_t) rhs)
NBL_CONSTEXPR_FUNC void swap(NBL_REF_ARG(uint64_t) lhs, NBL_REF_ARG(uint64_t) rhs)
{
lhs ^= rhs;
rhs ^= lhs;
lhs ^= rhs;
}

template<>
NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(int16_t) lhs, NBL_REF_ARG(int16_t) rhs)
NBL_CONSTEXPR_FUNC void swap(NBL_REF_ARG(int16_t) lhs, NBL_REF_ARG(int16_t) rhs)
{
lhs ^= rhs;
rhs ^= lhs;
lhs ^= rhs;
}

template<>
NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(int32_t) lhs, NBL_REF_ARG(int32_t) rhs)
NBL_CONSTEXPR_FUNC void swap(NBL_REF_ARG(int32_t) lhs, NBL_REF_ARG(int32_t) rhs)
{
lhs ^= rhs;
rhs ^= lhs;
lhs ^= rhs;
}

template<>
NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(int64_t) lhs, NBL_REF_ARG(int64_t) rhs)
NBL_CONSTEXPR_FUNC void swap(NBL_REF_ARG(int64_t) lhs, NBL_REF_ARG(int64_t) rhs)
{
lhs ^= rhs;
rhs ^= lhs;
lhs ^= rhs;
}
#else
template<typename T>
NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(T) lhs, NBL_REF_ARG(T) rhs)
NBL_CONSTEXPR_FUNC void swap(NBL_REF_ARG(T) lhs, NBL_REF_ARG(T) rhs)
{
std::swap(lhs, rhs);
}
#endif
}

template<typename T>
NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(T) lhs, NBL_REF_ARG(T) rhs)
NBL_CONSTEXPR_FUNC void swap(NBL_REF_ARG(T) lhs, NBL_REF_ARG(T) rhs)
{
impl::swap<T>(lhs, rhs);
}
Expand Down
2 changes: 1 addition & 1 deletion include/nbl/builtin/hlsl/bxdf/ndf/ggx.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ template<class T>
struct is_ggx : impl::is_ggx<T, typename T::scalar_type> {};

template<typename T>
NBL_CONSTEXPR bool is_ggx_v = is_ggx<T>::value;
NBL_CONSTEXPR_INLINE_NSPC_SCOPE_VAR bool is_ggx_v = is_ggx<T>::value;

}
}
Expand Down
16 changes: 0 additions & 16 deletions include/nbl/builtin/hlsl/complex.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -436,22 +436,6 @@ complex_t<Scalar> rotateRight(NBL_CONST_REF_ARG(complex_t<Scalar>) value)
return retVal;
}

template<typename Scalar>
struct ternary_operator< complex_t<Scalar> >
{
using type_t = complex_t<Scalar>;

complex_t<Scalar> operator()(bool condition, NBL_CONST_REF_ARG(complex_t<Scalar>) lhs, NBL_CONST_REF_ARG(complex_t<Scalar>) rhs)
{
const vector<Scalar, 2> lhsVector = vector<Scalar, 2>(lhs.real(), lhs.imag());
const vector<Scalar, 2> rhsVector = vector<Scalar, 2>(rhs.real(), rhs.imag());
const vector<Scalar, 2> resultVector = condition ? lhsVector : rhsVector;
const complex_t<Scalar> result = { resultVector.x, resultVector.y };
return result;
}
};


}
}

Expand Down
14 changes: 12 additions & 2 deletions include/nbl/builtin/hlsl/concepts/core.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,23 @@ namespace impl
template<typename T>
struct is_emulating_floating_point_scalar
{
NBL_CONSTEXPR_STATIC_INLINE bool value = FloatingPointScalar<T>;
NBL_CONSTEXPR_STATIC_INLINE bool value = false;
};

template<typename T>
struct is_emulating_integral_scalar
{
NBL_CONSTEXPR_STATIC_INLINE bool value = false;
};
}

//! Floating point types are native floating point types or types that imitate native floating point types (for example emulated_float64_t)
template<typename T>
NBL_BOOL_CONCEPT FloatingPointLikeScalar = impl::is_emulating_floating_point_scalar<T>::value;
NBL_BOOL_CONCEPT FloatingPointLikeScalar = FloatingPointScalar<T> || impl::is_emulating_floating_point_scalar<T>::value;

//! Integral-like types are native integral types or types that imitate native integral types (for example emulated_uint64_t)
template<typename T>
NBL_BOOL_CONCEPT IntegralLikeScalar = IntegralScalar<T> || impl::is_emulating_integral_scalar<T>::value;

}
}
Expand Down
6 changes: 2 additions & 4 deletions include/nbl/builtin/hlsl/concepts/vector.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ NBL_BOOL_CONCEPT FloatingPointLikeVectorial = concepts::Vectorial<T> && concepts
template<typename T>
NBL_BOOL_CONCEPT IntVectorial = concepts::Vectorial<T> && (is_integral_v<typename vector_traits<T>::scalar_type>);
template<typename T>
NBL_BOOL_CONCEPT IntegralLikeVectorial = concepts::Vectorial<T> && concepts::IntegralLikeScalar<typename vector_traits<T>::scalar_type>;
template<typename T>
NBL_BOOL_CONCEPT SignedIntVectorial = concepts::Vectorial<T> && concepts::SignedIntegralScalar<typename vector_traits<T>::scalar_type>;

}

template<typename Vectorial>
NBL_PARTIAL_REQ_TOP(concepts::Vectorial<Vectorial>)
struct extent<Vectorial, 0 NBL_PARTIAL_REQ_BOT(concepts::Vectorial<Vectorial>) > : integral_constant<uint64_t, vector_traits<Vectorial>::Dimension> {};

}
}
#endif
4 changes: 4 additions & 0 deletions include/nbl/builtin/hlsl/cpp_compat.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
// it includes vector and matrix
#include <nbl/builtin/hlsl/cpp_compat/intrinsics.hlsl>
#include <nbl/builtin/hlsl/cpp_compat/promote.hlsl>
#include <nbl/builtin/hlsl/cpp_compat/truncate.hlsl>

// Had to push some stuff here to avoid circular dependencies
#include <nbl/builtin/hlsl/cpp_compat/vector.hlsl>

#endif
69 changes: 41 additions & 28 deletions include/nbl/builtin/hlsl/cpp_compat/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,25 @@

#include <nbl/builtin/hlsl/macros.h>

namespace nbl
{
namespace hlsl
{
namespace impl
{
template<typename To, typename From, typename Enabled = void>
struct static_cast_helper
{
static inline To cast(From u)
{
#ifndef __HLSL_VERSION
return static_cast<To>(u);
#else
return To(u);
#endif
}
};
}

template<typename To, typename From>
inline To _static_cast(From v)
{
return impl::static_cast_helper<To, From>::cast(v);
}

}
}

#ifndef __HLSL_VERSION
#include <type_traits>

#define ARROW ->
#define NBL_DEREF_THIS (*this)
#define NBL_CONSTEXPR constexpr // TODO: rename to NBL_CONSTEXPR_VAR
#define NBL_CONSTEXPR_FUNC constexpr
#define NBL_CONSTEXPR_STATIC constexpr static
#define NBL_CONSTEXPR_STATIC_INLINE constexpr static inline
#define NBL_CONSTEXPR_INLINE_FUNC constexpr inline
#define NBL_CONSTEXPR_FORCED_INLINE_FUNC NBL_FORCE_INLINE constexpr
#define NBL_CONST_MEMBER_FUNC const
#define NBL_CONSTEXPR_INLINE_NSPC_SCOPE_VAR constexpr inline
#define NBL_CONSTEXPR_FUNC_SCOPE_VAR constexpr
#define NBL_CONSTEXPR_OOL_MEMBER constexpr
#define NBL_CONSTEXPR_INLINE_OOL_MEMBER constexpr inline
#define NBL_IF_CONSTEXPR(...) if constexpr (__VA_ARGS__)
#define NBL_ASSERT(...) assert(__VA_ARGS__)

namespace nbl::hlsl
{
Expand All @@ -67,14 +45,20 @@ namespace nbl::hlsl
#else

#define ARROW .arrow().
#define NBL_DEREF_THIS this
#define NBL_CONSTEXPR const static // TODO: rename to NBL_CONSTEXPR_VAR
#define NBL_CONSTEXPR_FUNC
#define NBL_CONSTEXPR_STATIC const static
#define NBL_CONSTEXPR_STATIC_INLINE const static
#define NBL_CONSTEXPR_INLINE_FUNC inline
#define NBL_CONSTEXPR_FORCED_INLINE_FUNC inline
#define NBL_CONST_MEMBER_FUNC
#define NBL_CONSTEXPR_INLINE_NSPC_SCOPE_VAR const static
#define NBL_CONSTEXPR_FUNC_SCOPE_VAR const
#define NBL_CONSTEXPR_OOL_MEMBER const
#define NBL_CONSTEXPR_INLINE_OOL_MEMBER const
#define NBL_IF_CONSTEXPR(...) if (__VA_ARGS__)
#define NBL_ASSERT(...)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wel aready have a shader assert somwhere, it does a vk::RawBufferStore to an invalid (0) BDA

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


namespace nbl
{
Expand Down Expand Up @@ -102,4 +86,33 @@ struct add_pointer

#endif

namespace nbl
{
namespace hlsl
{
namespace impl
{
template<typename To, typename From, typename Enabled = void>
struct static_cast_helper
{
NBL_CONSTEXPR_STATIC_INLINE To cast(From u)
{
#ifndef __HLSL_VERSION
return static_cast<To>(u);
#else
return To(u);
#endif
}
};
}

template<typename To, typename From>
NBL_CONSTEXPR_INLINE_FUNC To _static_cast(From v)
{
return impl::static_cast_helper<To, From>::cast(v);
}

}
}

#endif
Loading
Loading