Skip to content

Commit efee44e

Browse files
Merge pull request #573 from Devsh-Graphics-Programming/merge_kpentaris_hlsl
Update SPIRV-Headers fork and merge test from kpentaris
2 parents 56354d0 + 6b62f9e commit efee44e

File tree

9 files changed

+182
-12
lines changed

9 files changed

+182
-12
lines changed

3rdparty/dxc/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ if(NBL_EMBED_BUILTIN_RESOURCES)
172172
include("${NBL_ROOT_PATH}/src/nbl/builtin/utils.cmake")
173173

174174
# SPIRV Header in builtin resources, nbl paths as aliases
175-
LIST_BUILTIN_RESOURCE(SPIRV_RESOURCES_TO_EMBED "1.2/spirv.h")
176-
LIST_BUILTIN_RESOURCE(SPIRV_RESOURCES_TO_EMBED "1.2/spirv.hpp")
175+
LIST_BUILTIN_RESOURCE(SPIRV_RESOURCES_TO_EMBED "unified1/spirv.h")
176+
LIST_BUILTIN_RESOURCE(SPIRV_RESOURCES_TO_EMBED "unified1/spirv.hpp")
177177

178178
ADD_CUSTOM_BUILTIN_RESOURCES(dxcBuiltinResourceData SPIRV_RESOURCES_TO_EMBED "${_SPIRV_BR_BUNDLE_SEARCH_DIRECTORY_}" "spirv" "spirv::builtin" "${_SPIRV_BR_OUTPUT_DIRECTORY_HEADER_}" "${_SPIRV_BR_OUTPUT_DIRECTORY_SOURCE_}" "STATIC" "INTERNAL")
179179
endif()

include/nbl/builtin/hlsl/binops.hlsl

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
// Copyright (C) 2022 - 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_BINOPS_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_BINOPS_INCLUDED_
6+
7+
namespace nbl
8+
{
9+
namespace hlsl
10+
{
11+
namespace binops
12+
{
13+
template<typename T>
14+
struct bitwise_and
15+
{
16+
T operator()(const T lhs, const T rhs)
17+
{
18+
return lhs&rhs;
19+
}
20+
21+
static T identity()
22+
{
23+
return ~0;
24+
}
25+
};
26+
27+
template<typename T>
28+
struct bitwise_or
29+
{
30+
T operator()(const T lhs, const T rhs)
31+
{
32+
return lhs|rhs;
33+
}
34+
35+
static T identity()
36+
{
37+
return 0;
38+
}
39+
};
40+
41+
template<typename T>
42+
struct bitwise_xor
43+
{
44+
T operator()(const T lhs, const T rhs)
45+
{
46+
return lhs^rhs;
47+
}
48+
49+
static T identity()
50+
{
51+
return 0;
52+
}
53+
};
54+
55+
template<typename T>
56+
struct add
57+
{
58+
T operator()(const T lhs, const T rhs)
59+
{
60+
return lhs+rhs;
61+
}
62+
63+
static T identity()
64+
{
65+
return 0;
66+
}
67+
};
68+
69+
template<typename T>
70+
struct mul
71+
{
72+
T operator()(const T lhs, const T rhs)
73+
{
74+
return lhs*rhs;
75+
}
76+
77+
static T identity()
78+
{
79+
return 1;
80+
}
81+
};
82+
83+
template<typename T>
84+
struct comparator_lt_t
85+
{
86+
bool operator()(const T lhs, const T rhs)
87+
{
88+
return lhs<rhs;
89+
}
90+
};
91+
92+
template<typename T>
93+
struct comparator_gt_t
94+
{
95+
bool operator()(const T lhs, const T rhs)
96+
{
97+
return lhs>rhs;
98+
}
99+
};
100+
101+
template<typename T>
102+
struct comparator_lte_t
103+
{
104+
bool operator()(const T lhs, const T rhs)
105+
{
106+
return lhs<=rhs;
107+
}
108+
};
109+
110+
template<typename T>
111+
struct comparator_gte_t
112+
{
113+
bool operator()(const T lhs, const T rhs)
114+
{
115+
return lhs>=rhs;
116+
}
117+
};
118+
119+
template<typename T>
120+
struct min
121+
{
122+
T operator()(const T lhs, const T rhs)
123+
{
124+
comparator_lt_t<T> comp;
125+
return comp(lhs, rhs) ? lhs : rhs;
126+
}
127+
128+
static T identity()
129+
{
130+
return ~0;
131+
}
132+
};
133+
134+
template<typename T>
135+
struct max
136+
{
137+
T operator()(const T lhs, const T rhs)
138+
{
139+
comparator_gt_t<T> comp;
140+
return comp(lhs, rhs) ? lhs : rhs;
141+
}
142+
143+
static T identity()
144+
{
145+
return 0;
146+
}
147+
};
148+
149+
}
150+
}
151+
}
152+
153+
#endif

include/nbl/builtin/hlsl/glsl_compat/subgroup_arithmetic.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#ifndef _NBL_BUILTIN_HLSL_GLSL_COMPAT_SUBGROUP_ARITHMETIC_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_GLSL_COMPAT_SUBGROUP_ARITHMETIC_INCLUDED_
66

7-
#include "nbl/builtin/hlsl/spirv_intrinsics/subgroup/arithmetic.hlsl"
7+
#include "nbl/builtin/hlsl/spirv_intrinsics/subgroup_arithmetic.hlsl"
88

99
namespace nbl
1010
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_CORE_INCLUDED_
66

77

8-
#include "spirv/1.2/spirv.hpp"
8+
#include "spirv/unified1/spirv.hpp"
99

1010

1111
namespace nbl

include/nbl/video/CVulkanCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace nbl::video
66
{
77

8-
static constexpr uint32_t MinimumVulkanApiVersion = VK_MAKE_API_VERSION(0, 1, 1, 0);
8+
static constexpr uint32_t MinimumVulkanApiVersion = VK_MAKE_API_VERSION(0, 1, 3, 0);
99

1010
static inline asset::E_FORMAT getFormatFromVkFormat(VkFormat in)
1111
{

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static tcpp::TInputStreamUniquePtr getInputStreamInclude(
110110
std::string re(IShaderCompiler::PREPROC_DIRECTIVE_DISABLER);
111111
re.append("error ");
112112
re.append(requestedSource);
113-
re.append(" not found");
113+
re.append(" not found\n");
114114
includeStack.push_back(includeStack.back());
115115
return tcpp::TInputStreamUniquePtr(new tcpp::StringInputStream(re));
116116
}
@@ -260,7 +260,7 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
260260
}
261261
else
262262
{
263-
return tcpp::TInputStreamUniquePtr(new tcpp::StringInputStream(std::string("#error No include handler")));
263+
return tcpp::TInputStreamUniquePtr(new tcpp::StringInputStream(std::string("#error No include handler\n")));
264264
}
265265
};
266266
info.mOnPopIncludeCallback = [&]() {
@@ -379,7 +379,8 @@ core::smart_refctd_ptr<ICPUShader> CHLSLCompiler::compileToSPIRV(const char* cod
379379
L"-Zpr", // Packs matrices in row-major order by default
380380
L"-enable-16bit-types",
381381
L"-fvk-use-scalar-layout",
382-
L"-Wno-c++11-extensions"
382+
L"-Wno-c++11-extensions",
383+
L"-fspv-target-env=vulkan1.3"
383384
};
384385

385386
// If a custom SPIR-V optimizer is specified, use that instead of DXC's spirv-opt.

src/nbl/builtin/CMakeLists.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,22 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/fft.glsl")
180180
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/shuffle.glsl")
181181
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/shuffle_relative.glsl")
182182
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/workgroup/vote.glsl")
183+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup/arithmetic_portability.hlsl")
184+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup/arithmetic_portability_impl.hlsl")
185+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup/ballot.hlsl")
186+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/subgroup/basic.hlsl")
187+
#glsl compat
188+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/glsl_compat/core.hlsl")
189+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/glsl_compat/subgroup_arithmetic.hlsl")
190+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/glsl_compat/subgroup_ballot.hlsl")
191+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/glsl_compat/subgroup_basic.hlsl")
192+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/glsl_compat/subgroup_shuffle.hlsl")
193+
#spirv intrinsics
194+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/core.hlsl")
195+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_arithmetic.hlsl")
196+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_ballot.hlsl")
197+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_basic.hlsl")
198+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_shuffle.hlsl")
183199
#transform_tree
184200
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/transform_tree/global_transform_update.comp")
185201
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "glsl/transform_tree/global_transform_and_normal_matrix_update.comp")
@@ -261,11 +277,11 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/intrinsics.h")
261277

262278
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/bit.hlsl")
263279

264-
# TODO: add `glsl_compat`, `spirv_intrinsics` and `subgroup` contents
265-
266280
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/math/quadrature/gauss_legendre/gauss_legendre.hlsl")
267281
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/math/quadrature/gauss_legendre/impl.hlsl")
268282

283+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/binops.hlsl")
284+
269285
macro(NBL_ADD_BUILTIN_RESOURCES _TARGET_) # internal & Nabla only, must be added with the macro to properly propagate scope
270286
ADD_CUSTOM_BUILTIN_RESOURCES("${_TARGET_}" NBL_RESOURCES_TO_EMBED "${NBL_ROOT_PATH}/include" "nbl/builtin" "nbl::builtin" "${NBL_ROOT_PATH_BINARY}/include" "${NBL_ROOT_PATH_BINARY}/src" "STATIC" "INTERNAL")
271287
endmacro()

0 commit comments

Comments
 (0)