Skip to content

Commit 45f4c10

Browse files
committed
Resolved conflicts, merged master
2 parents df9b27c + f467148 commit 45f4c10

33 files changed

+1011
-1054
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@
7878
path = 3rdparty/dxc/dxc
7979
url = git@github.com:Devsh-Graphics-Programming/DirectXShaderCompiler.git
8080
branch = devshFixes
81-
[submodule "3rdparty/tcpp"]
82-
path = 3rdparty/tcpp
83-
url = git@github.com:Erfan-Ahmadi/tcpp.git
8481
[submodule "3rdparty/imgui"]
8582
path = 3rdparty/imgui
8683
url = git@github.com:Devsh-Graphics-Programming/imgui.git

3rdparty/tcpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

include/nbl/asset/utils/CHLSLCompiler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#ifdef _NBL_PLATFORM_WINDOWS_
1212

13-
namespace nbl::asset::hlsl::impl
13+
namespace nbl::asset::impl
1414
{
1515
class DXC;
1616
}
@@ -53,7 +53,7 @@ class NBL_API2 CHLSLCompiler final : public IShaderCompiler
5353

5454
// This can't be a unique_ptr due to it being an undefined type
5555
// when Nabla is used as a lib
56-
nbl::asset::hlsl::impl::DXC* m_dxcCompilerTypes;
56+
nbl::asset::impl::DXC* m_dxcCompilerTypes;
5757

5858
static CHLSLCompiler::SOptions option_cast(const IShaderCompiler::SCompilerOptions& options)
5959
{

include/nbl/asset/utils/IShaderCompiler.h

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,75 +26,81 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
2626

2727
class NBL_API2 IIncludeLoader : public core::IReferenceCounted
2828
{
29-
public:
30-
virtual std::optional<std::string> getInclude(const system::path& searchPath, const std::string& includeName) const = 0;
29+
public:
30+
struct found_t
31+
{
32+
system::path absolutePath = {};
33+
std::string contents = {};
34+
35+
explicit inline operator bool() const {return !absolutePath.empty();}
36+
};
37+
virtual found_t getInclude(const system::path& searchPath, const std::string& includeName) const = 0;
3138
};
3239

3340
class NBL_API2 IIncludeGenerator : public core::IReferenceCounted
3441
{
35-
public:
36-
// ! if includeName doesn't begin with prefix from `getPrefix` this function will return an empty string
37-
virtual std::optional<std::string> getInclude(const std::string& includeName) const;
42+
public:
43+
// ! if includeName doesn't begin with prefix from `getPrefix` this function will return an empty string
44+
virtual IIncludeLoader::found_t getInclude(const std::string& includeName) const;
3845

39-
virtual std::string_view getPrefix() const = 0;
46+
virtual std::string_view getPrefix() const = 0;
4047

41-
protected:
48+
protected:
4249

43-
using HandleFunc_t = std::function<std::string(const std::string&)>;
44-
virtual core::vector<std::pair<std::regex, HandleFunc_t>> getBuiltinNamesToFunctionMapping() const = 0;
50+
using HandleFunc_t = std::function<std::string(const std::string&)>;
51+
virtual core::vector<std::pair<std::regex,HandleFunc_t>> getBuiltinNamesToFunctionMapping() const = 0;
4552

46-
// ! Parses arguments from include path
47-
// ! template is path/to/shader.hlsl/arg0/arg1/...
48-
static core::vector<std::string> parseArgumentsFromPath(const std::string& _path);
53+
// ! Parses arguments from include path
54+
// ! template is path/to/shader.hlsl/arg0/arg1/...
55+
static core::vector<std::string> parseArgumentsFromPath(const std::string& _path);
4956
};
5057

5158
class NBL_API2 CFileSystemIncludeLoader : public IIncludeLoader
5259
{
53-
public:
54-
CFileSystemIncludeLoader(core::smart_refctd_ptr<system::ISystem>&& system);
60+
public:
61+
CFileSystemIncludeLoader(core::smart_refctd_ptr<system::ISystem>&& system);
5562

56-
std::optional<std::string> getInclude(const system::path& searchPath, const std::string& includeName) const override;
63+
IIncludeLoader::found_t getInclude(const system::path& searchPath, const std::string& includeName) const override;
5764

58-
protected:
59-
core::smart_refctd_ptr<system::ISystem> m_system;
65+
protected:
66+
core::smart_refctd_ptr<system::ISystem> m_system;
6067
};
6168

6269
class NBL_API2 CIncludeFinder : public core::IReferenceCounted
6370
{
64-
public:
65-
CIncludeFinder(core::smart_refctd_ptr<system::ISystem>&& system);
66-
67-
// ! includes within <>
68-
// @param requestingSourceDir: the directory where the incude was requested
69-
// @param includeName: the string within <> of the include preprocessing directive
70-
std::optional<std::string> getIncludeStandard(const system::path& requestingSourceDir, const std::string& includeName) const;
71+
public:
72+
CIncludeFinder(core::smart_refctd_ptr<system::ISystem>&& system);
7173

72-
// ! includes within ""
73-
// @param requestingSourceDir: the directory where the incude was requested
74-
// @param includeName: the string within "" of the include preprocessing directive
75-
std::optional<std::string> getIncludeRelative(const system::path& requestingSourceDir, const std::string& includeName) const;
74+
// ! includes within <>
75+
// @param requestingSourceDir: the directory where the incude was requested
76+
// @param includeName: the string within <> of the include preprocessing directive
77+
IIncludeLoader::found_t getIncludeStandard(const system::path& requestingSourceDir, const std::string& includeName) const;
7678

77-
inline core::smart_refctd_ptr<CFileSystemIncludeLoader> getDefaultFileSystemLoader() const { return m_defaultFileSystemLoader; }
79+
// ! includes within ""
80+
// @param requestingSourceDir: the directory where the incude was requested
81+
// @param includeName: the string within "" of the include preprocessing directive
82+
IIncludeLoader::found_t getIncludeRelative(const system::path& requestingSourceDir, const std::string& includeName) const;
7883

79-
void addSearchPath(const std::string& searchPath, const core::smart_refctd_ptr<IIncludeLoader>& loader);
84+
inline core::smart_refctd_ptr<CFileSystemIncludeLoader> getDefaultFileSystemLoader() const { return m_defaultFileSystemLoader; }
8085

81-
void addGenerator(const core::smart_refctd_ptr<IIncludeGenerator>& generator);
86+
void addSearchPath(const std::string& searchPath, const core::smart_refctd_ptr<IIncludeLoader>& loader);
8287

83-
protected:
88+
void addGenerator(const core::smart_refctd_ptr<IIncludeGenerator>& generator);
8489

85-
std::optional<std::string> trySearchPaths(const std::string& includeName) const;
90+
protected:
91+
IIncludeLoader::found_t trySearchPaths(const std::string& includeName) const;
8692

87-
std::optional<std::string> tryIncludeGenerators(const std::string& includeName) const;
93+
IIncludeLoader::found_t tryIncludeGenerators(const std::string& includeName) const;
8894

89-
struct LoaderSearchPath
90-
{
91-
core::smart_refctd_ptr<IIncludeLoader> loader = nullptr;
92-
std::string searchPath = {};
93-
};
95+
struct LoaderSearchPath
96+
{
97+
core::smart_refctd_ptr<IIncludeLoader> loader = nullptr;
98+
std::string searchPath = {};
99+
};
94100

95-
std::vector<LoaderSearchPath> m_loaders;
96-
std::vector<core::smart_refctd_ptr<IIncludeGenerator>> m_generators;
97-
core::smart_refctd_ptr<CFileSystemIncludeLoader> m_defaultFileSystemLoader;
101+
std::vector<LoaderSearchPath> m_loaders;
102+
std::vector<core::smart_refctd_ptr<IIncludeGenerator>> m_generators;
103+
core::smart_refctd_ptr<CFileSystemIncludeLoader> m_defaultFileSystemLoader;
98104
};
99105

100106
enum class E_SPIRV_VERSION : uint32_t
@@ -115,8 +121,12 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
115121
std::string_view sourceIdentifier = "";
116122
system::logger_opt_ptr logger = nullptr;
117123
const CIncludeFinder* includeFinder = nullptr;
118-
uint32_t maxSelfInclusionCount = 4u;
119-
core::SRange<const char* const> extraDefines = {nullptr, nullptr};
124+
struct SMacroDefinition
125+
{
126+
std::string_view identifier;
127+
std::string_view definition;
128+
};
129+
std::span<const SMacroDefinition> extraDefines = {};
120130
};
121131

122132
// https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#debugging
@@ -290,8 +300,6 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
290300

291301
virtual void insertIntoStart(std::string& code, std::ostringstream&& ins) const = 0;
292302

293-
void insertExtraDefines(std::string& code, const core::SRange<const char* const>& defines) const;
294-
295303
core::smart_refctd_ptr<system::ISystem> m_system;
296304
private:
297305
core::smart_refctd_ptr<CIncludeFinder> m_defaultIncludeFinder;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (C) 2023 - 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+
#ifndef _NBL_BUILTIN_HLSL_DEVICE_CAPABILITIES_TRAITS_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_DEVICE_CAPABILITIES_TRAITS_INCLUDED_
6+
7+
#include <nbl/builtin/hlsl/member_test_macros.hlsl>
8+
9+
#ifdef __HLSL_VERSION
10+
namespace nbl
11+
{
12+
namespace hlsl
13+
{
14+
template<typename device_capabilities>
15+
struct device_capabilities_traits
16+
{
17+
// TODO: check for members and default them to sane things, only do the 5 members in CJITIncludeLoader.cpp struct, we'll do the rest on `vulkan_1_3` branch with Nahim
18+
};
19+
}
20+
}
21+
#endif
22+
#endif

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<> \

include/nbl/system/CColoredStdoutLoggerANSI.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ class CColoredStdoutLoggerANSI : public IThreadsafeLogger
2222
switch (logLevel)
2323
{
2424
case ELL_DEBUG:
25-
printf("\x1b[37m%s", str.data()); // White
25+
printf("\x1b[37m%s\x1b[0m", str.data()); // White
2626
break;
2727
case ELL_INFO:
28-
printf("\x1b[37m%s", str.data()); // White
28+
printf("\x1b[37m%s\x1b[0m", str.data()); // White
2929
break;
3030
case ELL_WARNING:
31-
printf("\x1b[33m%s", str.data()); // yellow
31+
printf("\x1b[33m%s\x1b[0m", str.data()); // yellow
3232
break;
3333
case ELL_ERROR:
34-
printf("\x1b[31m%s", str.data()); // red
34+
printf("\x1b[31m%s\x1b[0m", str.data()); // red
3535
break;
3636
case ELL_PERFORMANCE:
37-
printf("\x1b[34m%s", str.data()); // blue
37+
printf("\x1b[34m%s\x1b[0m", str.data()); // blue
3838
break;
3939
case ELL_NONE:
4040
assert(false);

0 commit comments

Comments
 (0)