Skip to content

Commit 145fac5

Browse files
workaround Boost.Wave bugs
1 parent cc37325 commit 145fac5

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

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

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

22-
#pragma region ATOMICS
2322
template<typename T>
2423
T atomicAdd([[vk::ext_reference]] T ptr, uint32_t memoryScope, uint32_t memorySemantics, T value);
2524
template<>
@@ -95,9 +94,9 @@ int32_t atomicCompSwap([[vk::ext_reference]] int32_t ptr, uint32_t memoryScope,
9594
template<>
9695
[[vk::ext_instruction( spv::OpAtomicCompareExchange )]]
9796
uint32_t atomicCompSwap([[vk::ext_reference]] uint32_t ptr, uint32_t memoryScope, uint32_t memSemanticsEqual, uint32_t memSemanticsUnequal, uint32_t value, uint32_t comparator);
98-
#pragma endregion ATOMICS
9997

100-
#pragma region BARRIERS
98+
99+
101100
// Memory Semantics link here: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Memory_Semantics_-id-
102101

103102
// https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_memory_semantics_id
@@ -108,16 +107,12 @@ void controlBarrier(uint32_t executionScope, uint32_t memoryScope, uint32_t memo
108107

109108
[[vk::ext_instruction( spv::OpMemoryBarrier )]]
110109
void memoryBarrier(uint32_t memoryScope, uint32_t memorySemantics);
111-
#pragma endregion BARRIERS
112110

113-
#pragma region CONVERSION
114111

115112
// Add specializations if you need to emit a `ext_capability` (this means that the instruction needs to forward through an `impl::` struct and so on)
116113
template<class T, class U>
117114
[[vk::ext_instruction(spv::OpBitcast)]]
118115
T bitcast(U);
119-
120-
#pragma endregion CONVERSION
121116
}
122117
#endif
123118
}

include/nbl/builtin/hlsl/type_traits.hlsl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,16 +662,18 @@ struct unsigned_integer_of_size<8>
662662
// shoudl really return a std::type_info like struct or something, but no `constexpr` and unsure whether its possible to have a `const static SomeStruct` makes it hard to do...
663663
#define typeid(expr) (::nbl::hlsl::impl::typeid_t<__decltype(expr)>::value)
664664

665-
#define NBL_REGISTER_OBJ_TYPE(T, A) namespace nbl { namespace hlsl { \
666-
namespace impl { template<> struct typeid_t<T> : integral_constant<uint32_t,__COUNTER__> {}; } \
665+
// Found a bug in Boost.Wave, try to avoid multi-line macros https://github.com/boostorg/wave/issues/195
666+
#define NBL_IMPL_SPECIALIZE_TYPE_ID(T) namespace impl { template<> struct typeid_t<T> : integral_constant<uint32_t,__COUNTER__> {}; }
667+
668+
#define NBL_REGISTER_OBJ_TYPE(T,A) namespace nbl { namespace hlsl { NBL_IMPL_SPECIALIZE_TYPE_ID(T) \
667669
template<> struct alignment_of<T> : integral_constant<uint32_t,A> {}; \
668670
template<> struct alignment_of<const T> : integral_constant<uint32_t,A> {}; \
669671
template<> struct alignment_of<typename impl::add_lvalue_reference<T>::type> : integral_constant<uint32_t,A> {}; \
670672
template<> struct alignment_of<typename impl::add_lvalue_reference<const T>::type> : integral_constant<uint32_t,A> {}; \
671673
}}
672674

673675
// TODO: find out how to do it such that we don't get duplicate definition if we use two function identifiers with same signature
674-
#define NBL_REGISTER_FUN_TYPE(fn) namespace nbl { namespace hlsl { template<> struct typeid_t<__decltype(fn)> : integral_constant<uint32_t,__COUNTER__> {}; }}
676+
#define NBL_REGISTER_FUN_TYPE(fn) namespace nbl { namespace hlsl { NBL_IMPL_SPECIALIZE_TYPE_ID(__decltype(fn)) }}
675677
// TODO: ideally we'd like to call NBL_REGISTER_FUN_TYPE under the hood, but we can't right now. Also we have a bigger problem, the passing of the function identifier as the second template parameter doesn't work :(
676678
/*
677679
template<> \

src/nbl/asset/utils/waveContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ class context : private boost::noncopyable
153153
, macros(*this_())
154154
, language(language_support(
155155
support_cpp20
156-
| support_option_convert_trigraphs
157156
| support_option_preserve_comments
158157
| support_option_emit_line_directives
159158
| support_option_emit_pragma_directives
160-
| support_option_insert_whitespace
159+
// | support_option_emit_contnewlines
160+
// | support_option_insert_whitespace
161161
))
162162
, hooks(hooks_)
163163
{

0 commit comments

Comments
 (0)