Skip to content

Commit 1abaf59

Browse files
disambiguate spirv_intrinsics header names and show how to exchange one literal for an enum
1 parent 9254e55 commit 1abaf59

File tree

10 files changed

+50
-13
lines changed

10 files changed

+50
-13
lines changed

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/arithmetic.hlsl"
7+
#include "nbl/builtin/hlsl/spirv_intrinsics/subgroup/arithmetic.hlsl"
88

99
namespace nbl
1010
{

include/nbl/builtin/hlsl/glsl_compat/subgroup_ballot.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_BALLOT_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_GLSL_COMPAT_SUBGROUP_BALLOT_INCLUDED_
66

7-
#include "nbl/builtin/hlsl/spirv_intrinsics/ballot.hlsl"
7+
#include "nbl/builtin/hlsl/spirv_intrinsics/subgroup_ballot.hlsl"
88

99
namespace nbl
1010
{

include/nbl/builtin/hlsl/glsl_compat/subgroup_basic.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_BASIC_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_GLSL_COMPAT_SUBGROUP_BASIC_INCLUDED_
66

7-
#include "nbl/builtin/hlsl/spirv_intrinsics/core.hlsl"
7+
#include "nbl/builtin/hlsl/spirv_intrinsics/subgroup_basic.hlsl"
88

99
namespace nbl
1010
{

include/nbl/builtin/hlsl/glsl_compat/subgroup_shuffle.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_SHUFFLE_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_GLSL_COMPAT_SUBGROUP_SHUFFLE_INCLUDED_
66

7-
#include "nbl/builtin/hlsl/spirv_intrinsics/shuffle.hlsl"
7+
#include "nbl/builtin/hlsl/spirv_intrinsics/subgroup_shuffle.hlsl"
88

99
namespace nbl
1010
{

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_CORE_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_CORE_INCLUDED_
66

7+
8+
#include "spirv/1.2/spirv.hpp"
9+
10+
711
namespace nbl
812
{
913
namespace hlsl
1014
{
1115
namespace spirv
1216
{
13-
[[vk::ext_instruction(/* OpGroupNonUniformElect */ 333)]]
14-
bool subgroupElect(uint executionScope);
1517

1618
#pragma region ATOMICS
1719
template<typename T>
1820
T atomicAdd([[vk::ext_reference]] T ptr, uint memoryScope, uint memorySemantics, T value);
1921
template<>
20-
[[vk::ext_instruction(/* OpAtomicIAdd */ 234)]]
22+
[[vk::ext_instruction(spv::OpAtomicIAdd)]]
2123
int atomicAdd([[vk::ext_reference]] int ptr, uint memoryScope, uint memorySemantics, int value);
2224
template<>
2325
[[vk::ext_instruction(/* OpAtomicIAdd */ 234)]]

include/nbl/builtin/hlsl/spirv_intrinsics/arithmetic.hlsl renamed to include/nbl/builtin/hlsl/spirv_intrinsics/subgroup_arithmetic.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4-
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_ARITHMETIC_INCLUDED_
5-
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_ARITHMETIC_INCLUDED_
4+
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_SUBGROUP_ARITHMETIC_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_SUBGROUP_ARITHMETIC_INCLUDED_
66

77
// For all WaveMultiPrefix* ops, an example can be found here https://github.com/microsoft/DirectXShaderCompiler/blob/4e5440e1ee1f30d1164f90445611328293de08fa/tools/clang/test/HLSLFileCheck/hlsl/intrinsics/wave/prefix/sm_6_5_wave.hlsl
88
// However, we prefer to implement them with SPIRV intrinsics to avoid DXC changes in the compiler's emitted code

include/nbl/builtin/hlsl/spirv_intrinsics/ballot.hlsl renamed to include/nbl/builtin/hlsl/spirv_intrinsics/subgroup_ballot.hlsl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4-
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_BALLOT_INCLUDED_
5-
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_BALLOT_INCLUDED_
4+
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_SUBGROUP_BALLOT_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_SUBGROUP_BALLOT_INCLUDED_
6+
7+
8+
#include "nbl/builtin/hlsl/spirv_intrinsics/core.hlsl"
9+
610

711
namespace nbl
812
{
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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_SPIRV_INTRINSICS_SUBGROUP_BASIC_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_SUBGROUP_BASIC_INCLUDED_
6+
7+
8+
#include "nbl/builtin/hlsl/spirv_intrinsics/core.hlsl"
9+
10+
11+
namespace nbl
12+
{
13+
namespace hlsl
14+
{
15+
namespace spirv
16+
{
17+
18+
[[vk::ext_instruction(/* OpGroupNonUniformElect */ 333)]]
19+
bool subgroupElect(uint executionScope);
20+
21+
}
22+
}
23+
}
24+
25+
#endif

include/nbl/builtin/hlsl/spirv_intrinsics/shuffle.hlsl renamed to include/nbl/builtin/hlsl/spirv_intrinsics/subgroup_shuffle.hlsl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4-
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_SHUFFLE_INCLUDED_
5-
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_SHUFFLE_INCLUDED_
4+
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_SUBGROUP_SHUFFLE_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_SUBGROUP_SHUFFLE_INCLUDED_
6+
7+
8+
#include "nbl/builtin/hlsl/spirv_intrinsics/core.hlsl"
9+
610

711
namespace nbl
812
{

src/nbl/builtin/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/intrinsics.h")
261261

262262
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/bit.hlsl")
263263

264+
# TODO: add `glsl_compat`, `spirv_intrinsics` and `subgroup` contents
265+
264266
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/math/quadrature/gauss_legendre/gauss_legendre.hlsl")
265267
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/math/quadrature/gauss_legendre/impl.hlsl")
266268

0 commit comments

Comments
 (0)