Skip to content

Commit 4154f08

Browse files
committed
pull master & resolve conflicts
2 parents bfdbcf2 + 0632553 commit 4154f08

File tree

15 files changed

+250
-47
lines changed

15 files changed

+250
-47
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@
105105
[submodule "3rdparty/imgui_test_engine"]
106106
path = 3rdparty/imgui_test_engine
107107
url = [email protected]:ocornut/imgui_test_engine.git
108+
[submodule "3rdparty/git-version-tracking"]
109+
path = 3rdparty/git-version-tracking
110+
url = [email protected]:Devsh-Graphics-Programming/cmake-git-version-tracking.git

3rdparty/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ add_library(spirv_cross OBJECT
275275
)
276276
target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
277277

278+
# cmake-git-version-tracking
279+
add_subdirectory(git-version-tracking EXCLUDE_FROM_ALL)
280+
NBL_ADD_GIT_TRACKING_META_LIBRARY(nabla "${NBL_ROOT_PATH}")
281+
NBL_ADD_GIT_TRACKING_META_LIBRARY(dxc "${CMAKE_CURRENT_SOURCE_DIR}/dxc/dxc")
282+
NBL_GENERATE_GIT_TRACKING_META()
283+
278284
if(NBL_BUILD_IMGUI)
279285
set(NBL_IMGUI_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
280286
set(NBL_IMGUI_USER_CONFIG_ISD "${CMAKE_CURRENT_BINARY_DIR}/imgui/config/include")

3rdparty/git-version-tracking

Submodule git-version-tracking added at 6980df4

include/nabla.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
#ifndef __NABLA_H_INCLUDED__
1818
#define __NABLA_H_INCLUDED__
1919

20+
// meta info
21+
#include "git_info.h"
22+
23+
namespace nbl {
24+
NBL_API2 const gtml::GitInfo& getGitInfo(gtml::E_GIT_REPO_META repo);
25+
}
26+
2027
// core lib
2128
#include "nbl/core/declarations.h"
2229

include/nbl/builtin/hlsl/bda/bda_accessor.hlsl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,28 @@ namespace nbl
1212
namespace hlsl
1313
{
1414

15+
namespace impl {
16+
17+
struct BdaAccessorBase
18+
{
19+
// Note: Its a funny quirk of the SPIR-V Vulkan Env spec that `MemorySemanticsUniformMemoryMask` means SSBO as well :facepalm: (and probably BDA)
20+
void workgroupExecutionAndMemoryBarrier()
21+
{
22+
// we're only barriering the workgroup and trading memory within a workgroup
23+
spirv::controlBarrier(spv::ScopeWorkgroup, spv::ScopeWorkgroup, spv::MemorySemanticsAcquireReleaseMask | spv::MemorySemanticsUniformMemoryMask);
24+
}
25+
26+
void memoryBarrier()
27+
{
28+
// By default it's device-wide access to the buffer
29+
spirv::memoryBarrier(spv::ScopeDevice, spv::MemorySemanticsAcquireReleaseMask | spv::MemorySemanticsUniformMemoryMask);
30+
}
31+
};
32+
33+
} //namespace impl
34+
1535
template<typename T>
16-
struct BdaAccessor
36+
struct BdaAccessor : impl::BdaAccessorBase
1737
{
1838
using type_t = T;
1939
static BdaAccessor<T> create(const bda::__ptr<T> ptr)
@@ -61,7 +81,7 @@ struct BdaAccessor
6181
};
6282

6383
template<typename T>
64-
struct DoubleBdaAccessor
84+
struct DoubleBdaAccessor : impl::BdaAccessorBase
6585
{
6686
using type_t = T;
6787
static DoubleBdaAccessor<T> create(const bda::__ptr<T> inputPtr, const bda::__ptr<T> outputPtr)
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// Copyright (C) 2018-2024 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
5+
// TODO: Remove all appearances of this class and refactor to use the real BDA once https://github.com/microsoft/DirectXShaderCompiler/issues/6541 is resolved
6+
// Then, delete this file altogether.
7+
8+
9+
#ifndef _NBL_BUILTIN_HLSL_LEGACY_BDA_ACCESSOR_INCLUDED_
10+
#define _NBL_BUILTIN_HLSL_LEGACY_BDA_ACCESSOR_INCLUDED_
11+
12+
#include "nbl/builtin/hlsl/glsl_compat/core.hlsl"
13+
#include "nbl/builtin/hlsl/bda/__ptr.hlsl"
14+
15+
16+
namespace nbl
17+
{
18+
namespace hlsl
19+
{
20+
21+
namespace impl {
22+
23+
struct LegacyBdaAccessorBase
24+
{
25+
// Note: Its a funny quirk of the SPIR-V Vulkan Env spec that `MemorySemanticsUniformMemoryMask` means SSBO as well :facepalm: (and probably BDA)
26+
void workgroupExecutionAndMemoryBarrier()
27+
{
28+
// we're only barriering the workgroup and trading memory within a workgroup
29+
spirv::controlBarrier(spv::ScopeWorkgroup, spv::ScopeWorkgroup, spv::MemorySemanticsAcquireReleaseMask | spv::MemorySemanticsUniformMemoryMask);
30+
}
31+
32+
void memoryBarrier()
33+
{
34+
// By default it's device-wide access to the buffer
35+
spirv::memoryBarrier(spv::ScopeDevice, spv::MemorySemanticsAcquireReleaseMask | spv::MemorySemanticsUniformMemoryMask);
36+
}
37+
};
38+
39+
} //namespace impl
40+
41+
template<typename T>
42+
struct LegacyBdaAccessor : impl::LegacyBdaAccessorBase
43+
{
44+
using type_t = T;
45+
static LegacyBdaAccessor<T> create(const uint64_t address)
46+
{
47+
LegacyBdaAccessor<T> accessor;
48+
accessor.address = address;
49+
return accessor;
50+
}
51+
52+
T get(const uint64_t index)
53+
{
54+
return vk::RawBufferLoad<T>(address + index * sizeof(T));
55+
}
56+
57+
void get(const uint64_t index, NBL_REF_ARG(T) value)
58+
{
59+
value = vk::RawBufferLoad<T>(address + index * sizeof(T));
60+
}
61+
62+
void set(const uint64_t index, const T value)
63+
{
64+
vk::RawBufferStore<T>(address + index * sizeof(T), value);
65+
}
66+
67+
uint64_t address;
68+
};
69+
70+
template<typename T>
71+
struct DoubleLegacyBdaAccessor : impl::LegacyBdaAccessorBase
72+
{
73+
using type_t = T;
74+
static DoubleLegacyBdaAccessor<T> create(const uint64_t inputAddress, const uint64_t outputAddress)
75+
{
76+
DoubleLegacyBdaAccessor<T> accessor;
77+
accessor.inputAddress = inputAddress;
78+
accessor.outputAddress = outputAddress;
79+
return accessor;
80+
}
81+
82+
T get(const uint64_t index)
83+
{
84+
return vk::RawBufferLoad<T>(inputAddress + index * sizeof(T));
85+
}
86+
87+
void get(const uint64_t index, NBL_REF_ARG(T) value)
88+
{
89+
value = vk::RawBufferLoad<T>(inputAddress + index * sizeof(T));
90+
}
91+
92+
void set(const uint64_t index, const T value)
93+
{
94+
vk::RawBufferStore<T>(outputAddress + index * sizeof(T), value);
95+
}
96+
97+
uint64_t inputAddress, outputAddress;
98+
};
99+
100+
101+
}
102+
}
103+
104+
#endif

include/nbl/builtin/hlsl/complex.hlsl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,4 +378,23 @@ NBL_REGISTER_OBJ_TYPE(complex_t<float64_t2>,::nbl::hlsl::alignment_of_v<float64_
378378
NBL_REGISTER_OBJ_TYPE(complex_t<float64_t3>,::nbl::hlsl::alignment_of_v<float64_t3>)
379379
NBL_REGISTER_OBJ_TYPE(complex_t<float64_t4>,::nbl::hlsl::alignment_of_v<float64_t4>)
380380

381+
382+
383+
--------------------------------------------- Some more functions that come in handy --------------------------------------
384+
// Fast mul by i
385+
template<typename Scalar>
386+
complex_t<Scalar> rotateLeft(NBL_CONST_REF_ARG(complex_t<Scalar>) value)
387+
{
388+
complex_t<Scalar> retVal = {- value.imag(), value.real()};
389+
return retVal;
390+
}
391+
392+
// Fast mul by -i
393+
template<typename Scalar>
394+
complex_t<Scalar> rotateRight(NBL_CONST_REF_ARG(complex_t<Scalar>) value)
395+
{
396+
complex_t<Scalar> retVal = {value.imag(), -value.real()};
397+
return retVal;
398+
}
399+
381400
#endif

include/nbl/builtin/hlsl/glsl_compat/core.hlsl

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,13 @@ T bitfieldExtract( T val, uint32_t offsetBits, uint32_t numBits )
219219
return impl::bitfieldExtract<T, is_signed<T>::value, is_integral<T>::value>::__call(val,offsetBits,numBits);
220220
}
221221

222-
223222
namespace impl
224223
{
225224

226225
template<typename T>
227226
struct bitfieldInsert
228227
{
229-
static enable_if_t<is_integral_v<T>, T> __call( T base, T insert, uint32_t offset, uint32_t count )
228+
static T __call( T base, T insert, uint32_t offset, uint32_t count )
230229
{
231230
return spirv::bitFieldInsert<T>( base, insert, offset, count );
232231
}
@@ -235,9 +234,29 @@ struct bitfieldInsert
235234
} //namespace impl
236235

237236
template<typename T>
238-
T bitfieldInsert( T base, T insert, uint32_t offset, uint32_t count )
237+
T bitfieldInsert( T base, T insert, uint32_t offset, uint32_t bits )
238+
{
239+
return impl::bitfieldInsert<T>::__call(base, insert, offset, bits);
240+
}
241+
242+
namespace impl
243+
{
244+
245+
template<typename T>
246+
struct bitfieldReverse
247+
{
248+
static T __call( T base )
249+
{
250+
return spirv::bitFieldReverse<T>( base );
251+
}
252+
};
253+
254+
} //namespace impl
255+
256+
template<typename T>
257+
T bitfieldReverse( T value )
239258
{
240-
return impl::bitfieldInsert<T>::__call(base, insert, offset, count);
259+
return impl::bitfieldReverse<T>::__call(value);
241260
}
242261

243262
#endif

include/nbl/builtin/hlsl/spirv_intrinsics/core.hlsl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ enable_if_t<is_signed_v<Signed>, Signed> bitFieldSExtract( Signed val, uint32_t
238238

239239
template<typename Integral>
240240
[[vk::ext_instruction( spv::OpBitFieldInsert )]]
241-
Integral bitFieldInsert( Integral base, Integral insert, uint32_t offset, uint32_t count );
241+
enable_if_t<is_integral_v<Integral>, Integral> bitFieldInsert( Integral base, Integral insert, uint32_t offset, uint32_t count );
242+
243+
template<typename Integral>
244+
[[vk::ext_instruction( spv::OpBitReverse )]]
245+
enable_if_t<is_integral_v<Integral>, Integral> bitFieldReverse( Integral base );
242246

243247
}
244248

include/nbl/builtin/hlsl/type_traits.hlsl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ template<class T>
306306
NBL_CONSTEXPR_STATIC_INLINE bool is_unsigned_v = is_unsigned<T>::value;
307307

308308
template<class T>
309-
struct is_integral : impl::base_type_forwarder<impl::is_integral, T> {};
309+
struct is_integral : impl::base_type_forwarder<impl::is_integral, typename remove_cv<T>::type> {};
310+
template<class T>
311+
NBL_CONSTEXPR_STATIC_INLINE bool is_integral_v = is_integral<T>::value;
310312

311313
template<class T>
312314
struct is_floating_point : impl::base_type_forwarder<impl::is_floating_point, typename remove_cv<T>::type> {};
@@ -321,6 +323,8 @@ struct is_scalar : bool_constant<
321323
impl::is_integral<typename remove_cv<T>::type>::value ||
322324
impl::is_floating_point<typename remove_cv<T>::type>::value
323325
> {};
326+
template<class T>
327+
NBL_CONSTEXPR_STATIC_INLINE bool is_scalar_v = is_scalar<T>::value;
324328

325329
template<class T>
326330
struct is_const : bool_constant<false> {};
@@ -395,12 +399,6 @@ struct enable_if<true, T> : type_identity<T> {};
395399
template<bool B, class T = void>
396400
using enable_if_t = typename enable_if<B, T>::type;
397401

398-
template<class T>
399-
NBL_CONSTEXPR_STATIC_INLINE bool is_integral_v = is_integral<T>::value;
400-
401-
template<class T>
402-
NBL_CONSTEXPR_STATIC_INLINE bool is_scalar_v = is_scalar<T>::value;
403-
404402
template<class T>
405403
struct alignment_of;
406404
template<class T>

0 commit comments

Comments
 (0)