Skip to content

Commit 7399ab5

Browse files
committed
Reduce Wave preprocess overhead and update DXC pointer
1 parent 1a3d26a commit 7399ab5

File tree

17 files changed

+510
-118
lines changed

17 files changed

+510
-118
lines changed

3rdparty/dxc/dxc

Submodule dxc updated 351 files

include/nbl/asset/utils/IShaderCompiler.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include "nbl/builtin/hlsl/enums.hlsl"
1818

1919
#include <functional>
20+
#include <mutex>
21+
#include <unordered_map>
22+
#include <unordered_set>
2023

2124
namespace nbl::asset
2225
{
@@ -39,7 +42,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
3942

4043
explicit inline operator bool() const {return !absolutePath.empty();}
4144
};
42-
virtual found_t getInclude(const system::path& searchPath, const std::string& includeName) const = 0;
45+
virtual found_t getInclude(const system::path& searchPath, const std::string& includeName, bool needHash = true) const = 0;
4346
};
4447

4548
class NBL_API2 IIncludeGenerator : public core::IReferenceCounted
@@ -65,10 +68,13 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
6568
public:
6669
CFileSystemIncludeLoader(core::smart_refctd_ptr<system::ISystem>&& system);
6770

68-
IIncludeLoader::found_t getInclude(const system::path& searchPath, const std::string& includeName) const override;
71+
IIncludeLoader::found_t getInclude(const system::path& searchPath, const std::string& includeName, bool needHash = true) const override;
6972

7073
protected:
7174
core::smart_refctd_ptr<system::ISystem> m_system;
75+
mutable std::mutex m_cacheMutex;
76+
mutable std::unordered_map<std::string, IIncludeLoader::found_t> m_cache;
77+
mutable std::unordered_set<std::string> m_missingCache;
7278
};
7379

7480
class NBL_API2 CIncludeFinder : public core::IReferenceCounted
@@ -79,12 +85,12 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
7985
// ! includes within <>
8086
// @param requestingSourceDir: the directory where the incude was requested
8187
// @param includeName: the string within <> of the include preprocessing directive
82-
IIncludeLoader::found_t getIncludeStandard(const system::path& requestingSourceDir, const std::string& includeName) const;
88+
IIncludeLoader::found_t getIncludeStandard(const system::path& requestingSourceDir, const std::string& includeName, bool needHash = true) const;
8389

8490
// ! includes within ""
8591
// @param requestingSourceDir: the directory where the incude was requested
8692
// @param includeName: the string within "" of the include preprocessing directive
87-
IIncludeLoader::found_t getIncludeRelative(const system::path& requestingSourceDir, const std::string& includeName) const;
93+
IIncludeLoader::found_t getIncludeRelative(const system::path& requestingSourceDir, const std::string& includeName, bool needHash = true) const;
8894

8995
inline core::smart_refctd_ptr<CFileSystemIncludeLoader> getDefaultFileSystemLoader() const { return m_defaultFileSystemLoader; }
9096

@@ -93,7 +99,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
9399
void addGenerator(const core::smart_refctd_ptr<IIncludeGenerator>& generator);
94100

95101
protected:
96-
IIncludeLoader::found_t trySearchPaths(const std::string& includeName) const;
102+
IIncludeLoader::found_t trySearchPaths(const std::string& includeName, bool needHash) const;
97103

98104
IIncludeLoader::found_t tryIncludeGenerators(const std::string& includeName) const;
99105

@@ -137,6 +143,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
137143
std::span<const SMacroDefinition> extraDefines = {};
138144
E_SPIRV_VERSION targetSpirvVersion = E_SPIRV_VERSION::ESV_1_6;
139145
bool depfile = false;
146+
bool preserveComments = false;
140147
system::path depfilePath = {};
141148
std::function<void(std::string_view)> onPartialOutputOnFailure = {};
142149
};

include/nbl/builtin/hlsl/bxdf/reflection/beckmann.hlsl

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

7-
#include "nbl/builtin/hlsl/bxdf/common.hlsl"
87
#include "nbl/builtin/hlsl/bxdf/bxdf_traits.hlsl"
9-
#include "nbl/builtin/hlsl/sampling/cos_weighted_spheres.hlsl"
108
#include "nbl/builtin/hlsl/bxdf/ndf/beckmann.hlsl"
119
#include "nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl"
1210

include/nbl/builtin/hlsl/bxdf/reflection/ggx.hlsl

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

7-
#include "nbl/builtin/hlsl/bxdf/common.hlsl"
87
#include "nbl/builtin/hlsl/bxdf/bxdf_traits.hlsl"
9-
#include "nbl/builtin/hlsl/sampling/cos_weighted_spheres.hlsl"
108
#include "nbl/builtin/hlsl/bxdf/ndf/ggx.hlsl"
119
#include "nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl"
1210

include/nbl/builtin/hlsl/bxdf/transmission/beckmann.hlsl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
#ifndef _NBL_BUILTIN_HLSL_BXDF_TRANSMISSION_BECKMANN_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_BXDF_TRANSMISSION_BECKMANN_INCLUDED_
66

7-
#include "nbl/builtin/hlsl/bxdf/common.hlsl"
87
#include "nbl/builtin/hlsl/bxdf/bxdf_traits.hlsl"
9-
#include "nbl/builtin/hlsl/sampling/cos_weighted_spheres.hlsl"
10-
#include "nbl/builtin/hlsl/bxdf/reflection.hlsl"
8+
#include "nbl/builtin/hlsl/bxdf/ndf/beckmann.hlsl"
119
#include "nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl"
1210

1311
namespace nbl

include/nbl/builtin/hlsl/bxdf/transmission/ggx.hlsl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
#ifndef _NBL_BUILTIN_HLSL_BXDF_TRANSMISSION_GGX_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_BXDF_TRANSMISSION_GGX_INCLUDED_
66

7-
#include "nbl/builtin/hlsl/bxdf/common.hlsl"
87
#include "nbl/builtin/hlsl/bxdf/bxdf_traits.hlsl"
9-
#include "nbl/builtin/hlsl/sampling/cos_weighted_spheres.hlsl"
10-
#include "nbl/builtin/hlsl/bxdf/reflection.hlsl"
118
#include "nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl"
129

1310
namespace nbl

include/nbl/builtin/hlsl/emulated/float64_t.hlsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define _NBL_BUILTIN_HLSL_EMULATED_FLOAT64_T_HLSL_INCLUDED_
33

44
#include <nbl/builtin/hlsl/emulated/float64_t_impl.hlsl>
5-
#include <nbl/builtin/hlsl/concepts/core.hlsl>
65

76
namespace nbl
87
{

include/nbl/builtin/hlsl/member_test_macros.hlsl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
#define _NBL_BUILTIN_HLSL_MEMBER_TEST_MACROS_INCLUDED_
66

77
#include <nbl/builtin/hlsl/utility.hlsl>
8-
#include <boost/preprocessor.hpp>
8+
#include <boost/preprocessor/arithmetic/inc.hpp>
9+
#include <boost/preprocessor/comparison/not_equal.hpp>
10+
#include <boost/preprocessor/punctuation/comma_if.hpp>
11+
#include <boost/preprocessor/repetition/repeat.hpp>
912

1013
#ifdef __HLSL_VERSION
1114

@@ -123,4 +126,4 @@ GENERATE_METHOD_TESTER(set)
123126

124127

125128
#endif
126-
#endif
129+
#endif

include/nbl/builtin/hlsl/path_tracing/concepts.hlsl

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#define _NBL_BUILTIN_HLSL_PATH_TRACING_CONCEPTS_INCLUDED_
66

77
#include <nbl/builtin/hlsl/concepts.hlsl>
8-
#include <nbl/builtin/hlsl/bxdf/common.hlsl>
98

109
namespace nbl
1110
{
@@ -15,6 +14,17 @@ namespace path_tracing
1514
{
1615
namespace concepts
1716
{
17+
namespace impl
18+
{
19+
template<typename Vector3>
20+
struct DummyRayInteraction
21+
{
22+
using vector3_type = Vector3;
23+
24+
vector3_type getN() NBL_CONST_MEMBER_FUNC;
25+
bool isMaterialBSDF() NBL_CONST_MEMBER_FUNC;
26+
};
27+
}
1828

1929
#define NBL_CONCEPT_NAME RandGenerator
2030
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
@@ -38,7 +48,7 @@ NBL_CONCEPT_END(
3848
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
3949
#define NBL_CONCEPT_PARAM_0 (ray, T)
4050
#define NBL_CONCEPT_PARAM_1 (v, typename T::vector3_type)
41-
#define NBL_CONCEPT_PARAM_2 (interaction, bxdf::surface_interactions::SIsotropic<bxdf::ray_dir_info::SBasic<float>, typename T::spectral_type>)
51+
#define NBL_CONCEPT_PARAM_2 (interaction, impl::DummyRayInteraction<typename T::vector3_type>)
4252
#define NBL_CONCEPT_PARAM_3 (scalar, typename T::scalar_type)
4353
#define NBL_CONCEPT_PARAM_4 (color, typename T::spectral_type)
4454
NBL_CONCEPT_BEGIN(5)
@@ -52,7 +62,7 @@ NBL_CONCEPT_END(
5262
((NBL_CONCEPT_REQ_TYPE)(T::vector3_type))
5363
((NBL_CONCEPT_REQ_TYPE)(T::spectral_type))
5464
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.init(v/*origin*/, v/*direction*/)), ::nbl::hlsl::is_same_v, void))
55-
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.template setInteraction<bxdf::surface_interactions::SIsotropic<bxdf::ray_dir_info::SBasic<float>, typename T::spectral_type> >(interaction)), ::nbl::hlsl::is_same_v, void))
65+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.setInteraction(interaction)), ::nbl::hlsl::is_same_v, void))
5666
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.initPayload()), ::nbl::hlsl::is_same_v, void))
5767
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.shouldDoMIS()), ::nbl::hlsl::is_same_v, bool))
5868
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.foundEmissiveMIS(scalar)), ::nbl::hlsl::is_same_v, typename T::scalar_type))
@@ -70,6 +80,21 @@ NBL_CONCEPT_END(
7080
#undef ray
7181
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
7282

83+
#define NBL_CONCEPT_NAME RaySetInteraction
84+
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename)
85+
#define NBL_CONCEPT_TPLT_PRM_NAMES (RayT)(Interaction)
86+
#define NBL_CONCEPT_PARAM_0 (ray, RayT)
87+
#define NBL_CONCEPT_PARAM_1 (interaction, Interaction)
88+
NBL_CONCEPT_BEGIN(2)
89+
#define ray NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
90+
#define interaction NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
91+
NBL_CONCEPT_END(
92+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.setInteraction(interaction)), ::nbl::hlsl::is_same_v, void))
93+
);
94+
#undef interaction
95+
#undef ray
96+
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
97+
7398
#define NBL_CONCEPT_NAME RayGenerator
7499
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
75100
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
@@ -124,6 +149,7 @@ NBL_CONCEPT_END(
124149
((NBL_CONCEPT_REQ_TYPE)(T::scene_type))
125150
((NBL_CONCEPT_REQ_TYPE)(T::ray_type))
126151
((NBL_CONCEPT_REQ_TYPE)(T::object_handle_type))
152+
((NBL_CONCEPT_REQ_TYPE)(T::anisotropic_interaction_type))
127153
((NBL_CONCEPT_REQ_TYPE)(T::closest_hit_type))
128154
((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(IntersectorClosestHit, typename T::closest_hit_type))
129155
((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(Ray, typename T::ray_type))
@@ -136,6 +162,26 @@ NBL_CONCEPT_END(
136162
#undef intersect
137163
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
138164

165+
#define NBL_CONCEPT_NAME UnidirectionalInteractionContract
166+
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename)(typename)
167+
#define NBL_CONCEPT_TPLT_PRM_NAMES (RayT)(IntersectorT)(MaterialSystemT)
168+
#define NBL_CONCEPT_PARAM_0 (ray, RayT)
169+
#define NBL_CONCEPT_PARAM_1 (hit, typename IntersectorT::closest_hit_type)
170+
#define NBL_CONCEPT_PARAM_2 (interaction, typename MaterialSystemT::anisotropic_interaction_type)
171+
NBL_CONCEPT_BEGIN(3)
172+
#define ray NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
173+
#define hit NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1
174+
#define interaction NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2
175+
NBL_CONCEPT_END(
176+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((hit.getInteraction()), ::nbl::hlsl::is_same_v, typename IntersectorT::anisotropic_interaction_type))
177+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((hit.getInteraction()), ::nbl::hlsl::is_same_v, typename MaterialSystemT::anisotropic_interaction_type))
178+
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((ray.setInteraction(interaction)), ::nbl::hlsl::is_same_v, void))
179+
);
180+
#undef interaction
181+
#undef hit
182+
#undef ray
183+
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
184+
139185
#define NBL_CONCEPT_NAME BxdfNode
140186
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
141187
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)

include/nbl/builtin/hlsl/path_tracing/unidirectional.hlsl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
#define _NBL_BUILTIN_HLSL_PATH_TRACING_UNIDIRECTIONAL_INCLUDED_
66

77
#include <nbl/builtin/hlsl/colorspace/EOTF.hlsl>
8-
#include <nbl/builtin/hlsl/colorspace/encodeCIEXYZ.hlsl>
98
#include <nbl/builtin/hlsl/math/functions.hlsl>
109
#include <nbl/builtin/hlsl/sampling/basic.hlsl>
11-
#include <nbl/builtin/hlsl/bxdf/bxdf_traits.hlsl>
12-
#include <nbl/builtin/hlsl/vector_utils/vector_traits.hlsl>
1310
#include <nbl/builtin/hlsl/path_tracing/concepts.hlsl>
1411

1512
namespace nbl
@@ -22,6 +19,7 @@ namespace path_tracing
2219
template<class RandGen, class Ray, class Intersector, class MaterialSystem, /* class PathGuider, */ class NextEventEstimator, class Accumulator, class Scene
2320
NBL_PRIMARY_REQUIRES(concepts::RandGenerator<RandGen> && concepts::Ray<Ray> &&
2421
concepts::Intersector<Intersector> && concepts::MaterialSystem<MaterialSystem> &&
22+
concepts::UnidirectionalInteractionContract<Ray, Intersector, MaterialSystem> &&
2523
concepts::NextEventEstimator<NextEventEstimator> && concepts::Accumulator<Accumulator> &&
2624
concepts::Scene<Scene>)
2725
struct Unidirectional

0 commit comments

Comments
 (0)