@@ -44,8 +44,6 @@ struct inclusive_scan
44
44
// assert binop_t == BinOp
45
45
using exclusive_scan_op_t = exclusive_scan<Params, binop_t, 1 , native>;
46
46
47
- // NBL_CONSTEXPR_STATIC_INLINE uint32_t ItemsPerInvocation = vector_traits<T>::Dimension;
48
-
49
47
type_t operator ()(NBL_CONST_REF_ARG (type_t) value)
50
48
{
51
49
binop_t binop;
@@ -71,22 +69,24 @@ struct exclusive_scan
71
69
using type_t = typename Params::type_t;
72
70
using scalar_t = typename Params::scalar_t;
73
71
using binop_t = typename Params::binop_t;
74
- using inclusive_scan_op_t = inclusive_scan<Params, binop_t, ItemsPerInvocation, native>;
75
-
76
- // NBL_CONSTEXPR_STATIC_INLINE uint32_t ItemsPerInvocation = vector_traits<T>::Dimension;
72
+ using exclusive_scan_op_t = exclusive_scan<Params, binop_t, 1 , native>;
77
73
78
74
type_t operator ()(type_t value)
79
75
{
80
- inclusive_scan_op_t op;
81
- value = op (value);
76
+ binop_t binop;
77
+ type_t retval;
78
+ retval[0 ] = value[0 ];
79
+ [unroll]
80
+ for (uint32_t i = 1 ; i < ItemsPerInvocation; i++)
81
+ retval[i] = binop (retval[i-1 ], value[i]);
82
82
83
- type_t left = glsl::subgroupShuffleUp<type_t>(value,1 );
83
+ exclusive_scan_op_t op;
84
+ scalar_t exclusive = op (retval[ItemsPerInvocation-1 ]);
84
85
85
- type_t retval;
86
- retval[0 ] = hlsl::mix (binop_t::identity, left[ItemsPerInvocation-1 ], bool (glsl::gl_SubgroupInvocationID ()));
86
+ retval[0 ] = exclusive;
87
87
[unroll]
88
88
for (uint32_t i = 1 ; i < ItemsPerInvocation; i++)
89
- retval[i] = value [i-1 ];
89
+ retval[i] = binop (exclusive,retval [i-1 ]) ;
90
90
return retval;
91
91
}
92
92
};
@@ -99,8 +99,6 @@ struct reduction
99
99
using binop_t = typename Params::binop_t;
100
100
using op_t = reduction<Params, binop_t, 1 , native>;
101
101
102
- // NBL_CONSTEXPR_STATIC_INLINE uint32_t ItemsPerInvocation = vector_traits<T>::Dimension;
103
-
104
102
scalar_t operator ()(NBL_CONST_REF_ARG (type_t) value)
105
103
{
106
104
binop_t binop;
0 commit comments