1
+ #ifndef _NBL_BUILTIN_HLSL_SUBGROUP_ARITHMETIC_PORTABILITY_INCLUDED_
2
+ #define _NBL_BUILTIN_HLSL_SUBGROUP_ARITHMETIC_PORTABILITY_INCLUDED_
3
+
4
+ #ifndef NBL_GL_KHR_shader_subgroup_arithmetic
5
+ #include <nbl/builtin/hlsl/subgroup/basic_portability.hlsl>
6
+ #endif
7
+
8
+ static uint4 WHOLE_WAVE = ~0 ;
9
+
10
+ namespace nbl
11
+ {
12
+ namespace hlsl
13
+ {
14
+ namespace subgroup
15
+ {
16
+
17
+ #ifdef NBL_GL_KHR_shader_subgroup_arithmetic
18
+ namespace native
19
+ {
20
+
21
+ template<class Binop>
22
+ struct reduction;
23
+ template<class Binop>
24
+ struct exclusive_scan;
25
+ template<class Binop>
26
+ struct inclusive_scan;
27
+
28
+ }
29
+ #endif
30
+
31
+ template<class Binop>
32
+ struct reduction
33
+ {
34
+ template<class ScratchAccessor, typename T>
35
+ T operator ()(const T x)
36
+ {
37
+ #ifdef NBL_GL_KHR_shader_subgroup_arithmetic
38
+ return native::reduction<Binop>()(x);
39
+ #else
40
+ portability::reduction<Binop,ScratchAccessor> impl;
41
+ return impl (x);
42
+ #endif
43
+ }
44
+ };
45
+
46
+ template<class Binop>
47
+ struct exclusive_scan
48
+ {
49
+ template<class ScratchAccessor, typename T>
50
+ T operator ()(const T x)
51
+ {
52
+ #ifdef NBL_GL_KHR_shader_subgroup_arithmetic
53
+ return native::exclusive_scan<Binop>()(x);
54
+ #else
55
+ portability::exclusive_scan<Binop,ScratchAccessor> impl;
56
+ return impl (x);
57
+ #endif
58
+ }
59
+ };
60
+
61
+ template<class Binop>
62
+ struct inclusive_scan
63
+ {
64
+ template<class ScratchAccessor, typename T>
65
+ T operator ()(const T x)
66
+ {
67
+ #ifdef NBL_GL_KHR_shader_subgroup_arithmetic
68
+ return native::inclusive_scan<Binop>()(x);
69
+ #else
70
+ portability::inclusive_scan<Binop,ScratchAccessor> impl;
71
+ return impl (x);
72
+ #endif
73
+ }
74
+ };
75
+
76
+ namespace portability
77
+ {
78
+
79
+ // PORTABILITY BINOP DECLARATIONS
80
+ template<class Binop, class ScratchAccessor>
81
+ struct reduction;
82
+ template<class Binop, class ScratchAccessor>
83
+ struct inclusive_scan;
84
+ template<class Binop, class ScratchAccessor>
85
+ struct exclusive_scan;
86
+
87
+ }
88
+
89
+ }
90
+ }
91
+ }
92
+
93
+ #include <nbl/builtin/hlsl/subgroup/arithmetic_portability_impl.hlsl>
94
+
95
+ #endif
0 commit comments