Skip to content

Commit e0919e8

Browse files
committed
hlsl_generator: update pointer_t impl
Signed-off-by: Ali Cheraghi <[email protected]>
1 parent 9778007 commit e0919e8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tools/hlsl_generator/gen.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@
2828
namespace spirv
2929
{
3030
31+
//! General Decls
32+
template<class T>
33+
NBL_CONSTEXPR_STATIC_INLINE bool is_pointer_v = is_spirv_type<T>::value;
34+
35+
template<uint32_t StorageClass, typename T>
36+
struct pointer
37+
{
38+
using type = vk::SpirvOpaqueType<spv::OpTypePointer, vk::Literal< vk::integral_constant<uint32_t, StorageClass> >, T>;
39+
};
40+
// partial spec for BDA
41+
template<typename T>
42+
struct pointer<spv::StorageClassPhysicalStorageBuffer, T>
43+
{
44+
using type = vk::SpirvType<spv::OpTypePointer, sizeof(uint64_t), sizeof(uint64_t), vk::Literal<vk::integral_constant<uint32_t, spv::StorageClassPhysicalStorageBuffer> >, T>;
45+
};
46+
47+
template<uint32_t StorageClass, typename T>
48+
using pointer_t = typename pointer<StorageClass, T>::type;
49+
3150
// The holy operation that makes addrof possible
3251
template<uint32_t StorageClass, typename T>
3352
[[vk::ext_instruction(spv::OpCopyObject)]]

tools/hlsl_generator/out.hlsl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ namespace hlsl
1919
namespace spirv
2020
{
2121

22+
//! General Decls
23+
template<class T>
24+
NBL_CONSTEXPR_STATIC_INLINE bool is_pointer_v = is_spirv_type<T>::value;
25+
26+
template<uint32_t StorageClass, typename T>
27+
struct pointer
28+
{
29+
using type = vk::SpirvOpaqueType<spv::OpTypePointer, vk::Literal< vk::integral_constant<uint32_t, StorageClass> >, T>;
30+
};
31+
// partial spec for BDA
32+
template<typename T>
33+
struct pointer<spv::StorageClassPhysicalStorageBuffer, T>
34+
{
35+
using type = vk::SpirvType<spv::OpTypePointer, sizeof(uint64_t), sizeof(uint64_t), vk::Literal<vk::integral_constant<uint32_t, spv::StorageClassPhysicalStorageBuffer> >, T>;
36+
};
37+
38+
template<uint32_t StorageClass, typename T>
39+
using pointer_t = typename pointer<StorageClass, T>::type;
40+
2241
// The holy operation that makes addrof possible
2342
template<uint32_t StorageClass, typename T>
2443
[[vk::ext_instruction(spv::OpCopyObject)]]

0 commit comments

Comments
 (0)