Skip to content

Commit b140e26

Browse files
author
devsh
committed
fix final little things after testing with real world usage
1 parent a67f92a commit b140e26

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

include/nbl/builtin/hlsl/bda/__ptr.hlsl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct __ptr
3131
{
3232
i *= sizeof(T);
3333
uint32_t2 newAddr = addr;
34-
AddCarryOutput<T> lsbAddRes = spirv::addCarry<uint32_t>(addr[0],i);
34+
spirv::AddCarryOutput<uint32_t> lsbAddRes = spirv::addCarry<uint32_t>(addr[0],i);
3535
newAddr[0] = lsbAddRes.result;
3636
newAddr[1] += lsbAddRes.carry;
3737
return __ptr::create(newAddr);
@@ -40,20 +40,23 @@ struct __ptr
4040
{
4141
i *= sizeof(T);
4242
uint32_t2 newAddr = addr;
43-
AddCarryOutput<T> lsbSubRes = spirv::subBorrow<uint32_t>(addr[0],i);
43+
spirv::AddCarryOutput<uint32_t> lsbSubRes = spirv::subBorrow<uint32_t>(addr[0],i);
4444
newAddr[0] = lsbSubRes.result;
4545
newAddr[1] -= lsbSubRes.carry;
4646
return __ptr::create(newAddr);
4747
}
4848

49-
template< uint64_t alignment=alignment_of_v<T> >
50-
__ref<T,alignment,false> deref()
49+
template<uint64_t alignment=alignment_of_v<T>, bool _restrict=false>
50+
__ref<T,alignment,_restrict> deref()
5151
{
5252
// TODO: assert(addr&uint64_t(alignment-1)==0);
53-
__ref<T,alignment,false> retval;
53+
__ref<T,alignment,_restrict> retval;
5454
retval.__init(spirv::bitcast<spirv::bda_pointer_t<T>,uint32_t2>(addr));
5555
return retval;
5656
}
57+
58+
template<uint64_t alignment=alignment_of_v<T> >
59+
__ref<T,alignment,true> deref_restrict() {return deref<alignment,true>();}
5760

5861
//! Dont use these, to avoid emitting shaderUint64 capability when compiling for crappy mobile GPUs
5962
static this_t create(const uint64_t _addr)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
#ifndef _NBL_BUILTIN_HLSL_BDA_REF_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_BDA_REF_INCLUDED_
66

7+
// TODO: this shouldn't be included IMHO
78
#include "nbl/builtin/hlsl/functional.hlsl"
8-
#include "nbl/builtin/hlsl/bda/struct_declare.hlsl"
9+
#include "nbl/builtin/hlsl/spirv_intrinsics/core.hlsl"
910

1011
namespace nbl
1112
{

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
#ifndef _NBL_BUILTIN_HLSL_BDA_STRUCT_DECLARE_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_BDA_STRUCT_DECLARE_INCLUDED_
66

7+
#include "nbl/builtin/hlsl/type_traits.hlsl"
78
#include "nbl/builtin/hlsl/mpl.hlsl"
9+
#ifdef __HLSL_VERSION
10+
#include "nbl/builtin/hlsl/bda/__ptr.hlsl"
11+
#endif // __HLSL_VERSION
12+
813

914
namespace nbl
1015
{
@@ -52,7 +57,6 @@ template<typename T, int32_t MemberIx>
5257
NBL_CONSTEXPR uint64_t member_offset_v = member_offset<T,MemberIx>::value;
5358

5459
// stuff needed to compute alignment of the struct properly
55-
#ifdef __HLSL_VERSION
5660
namespace impl
5761
{
5862
template<typename T, uint32_t N>
@@ -69,7 +73,6 @@ struct default_alignment<T,0>
6973
template<typename T, typename MemberCount=member_count<T> >
7074
NBL_CONSTEXPR uint32_t default_alignment_v = default_alignment<T,MemberCount::value>::value;
7175
}
72-
#endif
7376
}
7477
}
7578
}

include/nbl/builtin/hlsl/spirv_intrinsics/output_structs.hlsl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace nbl
1010
{
1111
namespace hlsl
1212
{
13+
namespace spirv
14+
{
1315

1416
template<typename T NBL_STRUCT_CONSTRAINABLE>
1517
struct AddCarryOutput;
@@ -30,7 +32,8 @@ struct SubBorrowOutput<T NBL_PARTIAL_REQ_BOT(concepts::UnsignedIntegral<T>) >
3032
T result;
3133
T borrow;
3234
};
35+
36+
}
3337
}
3438
}
35-
3639
#endif

0 commit comments

Comments
 (0)