Skip to content

Commit a297411

Browse files
author
devsh
committed
correct small bugs in nbl::hlsl:::mpl
1 parent 02f18a2 commit a297411

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

include/nbl/builtin/hlsl/bda/__ref.hlsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct __base_ref
5757
};
5858

5959
// TODO: I wish HLSL had some things like C++ which would allow you to make a "stack only"/non-storable type
60+
// NOTE: I guess there's the Function/Private storage space variables?
6061
template<typename T, uint32_t alignment=alignment_of_v<T>, bool _restrict=false>
6162
struct __ref : __base_ref<T,alignment,_restrict>
6263
{

include/nbl/builtin/hlsl/bda/struct_declare.hlsl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,9 @@ namespace impl
5858
template<typename T, uint32_t N>
5959
struct default_alignment
6060
{
61-
NBL_CONSTEXPR_STATIC_INLINE uint32_t value = mpl::max_v<uint32_t,member_alignment_v<T,N-1>,member_alignment_v<T,N-2> >;
61+
NBL_CONSTEXPR_STATIC_INLINE uint32_t value = mpl::max_v<uint32_t,member_alignment_v<T,N-1>,default_alignment<T,N-1>::value>;
6262
};
63-
template<typename T>
64-
struct default_alignment<T,1>
65-
{
66-
NBL_CONSTEXPR_STATIC_INLINE uint32_t value = member_alignment_v<T,0>;
67-
};
68-
// le invalid value
63+
// le invalid values
6964
template<typename T>
7065
struct default_alignment<T,0>
7166
{

include/nbl/builtin/hlsl/mpl.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ NBL_CONSTEXPR T rotr_v = rotr<T,X,S>::value;
7474
template<uint64_t X, uint64_t M>
7575
struct align_up
7676
{
77-
NBL_CONSTEXPR_STATIC_INLINE uint64_t value = (X+M-1)/M;
77+
NBL_CONSTEXPR_STATIC_INLINE uint64_t value = X ? (((X-1)/M+1)*M):0;
7878
};
7979
template<uint64_t X, uint64_t M>
8080
NBL_CONSTEXPR uint64_t align_up_v = align_up<X,M>::value;

0 commit comments

Comments
 (0)