@@ -16,26 +16,26 @@ namespace subgroup2
16
16
namespace impl
17
17
{
18
18
19
- template<template< class > class Binop, typename T, int32_t ItemsPerInvocation , bool native>
19
+ template<class Binop, bool native>
20
20
struct inclusive_scan
21
21
{
22
- using type_t = typename T ;
23
- using par_type_t = conditional_t<ItemsPerInvocation < 2 , type_t, vector <type_t, ItemsPerInvocation> > ;
24
- using binop_t = Binop<type_t >;
25
- using binop_par_t = Binop<par_type_t >;
22
+ using type_t = typename Binop::type_t ;
23
+ using scalar_t = typename Binop::scalar_t ;
24
+ using binop_t = Binop<scalar_t >;
25
+ using binop_par_t = Binop<type_t >;
26
26
using exclusive_scan_op_t = subgroup::impl::exclusive_scan<binop_t, native>;
27
27
28
- par_type_t operator ()(NBL_CONST_REF_ARG (par_type_t ) value)
28
+ type_t operator ()(NBL_CONST_REF_ARG (type_t ) value)
29
29
{
30
30
binop_t binop;
31
- par_type_t retval;
31
+ type_t retval;
32
32
retval[0 ] = value[0 ];
33
33
[unroll (ItemsPerInvocation-1 )]
34
34
for (uint32_t i = 1 ; i < ItemsPerInvocation; i++)
35
35
retval[i] = binop (retval[i-1 ], value[i]);
36
36
37
37
exclusive_scan_op_t op;
38
- type_t exclusive = op (retval[ItemsPerInvocation-1 ]);
38
+ scalar_t exclusive = op (retval[ItemsPerInvocation-1 ]);
39
39
40
40
[unroll (ItemsPerInvocation)]
41
41
for (uint32_t i = 0 ; i < ItemsPerInvocation; i++)
@@ -44,23 +44,23 @@ struct inclusive_scan
44
44
}
45
45
};
46
46
47
- template<template< class > class Binop, typename T, int32_t ItemsPerInvocation , bool native>
47
+ template<class Binop, bool native>
48
48
struct exclusive_scan
49
49
{
50
- using type_t = typename T ;
51
- using par_type_t = conditional_t<ItemsPerInvocation < 2 , type_t, vector <type_t, ItemsPerInvocation> > ;
52
- using binop_t = Binop<type_t >;
53
- using binop_par_t = Binop<par_type_t >;
50
+ using type_t = typename Binop::type_t ;
51
+ using scalar_t = typename Binop::scalar_t ;
52
+ using binop_t = Binop<scalar_t >;
53
+ using binop_par_t = Binop<type_t >;
54
54
using inclusive_scan_op_t = subgroup2::impl::inclusive_scan<binop_par_t, native>;
55
55
56
- par_type_t operator ()(NBL_CONST_REF_ARG (par_type_t ) value)
56
+ type_t operator ()(NBL_CONST_REF_ARG (type_t ) value)
57
57
{
58
58
inclusive_scan_op_t op;
59
59
value = op (value);
60
60
61
- par_type_t left = glsl::subgroupShuffleUp<par_type_t >(value,1 );
61
+ type_t left = glsl::subgroupShuffleUp<type_t >(value,1 );
62
62
63
- par_type_t retval;
63
+ type_t retval;
64
64
retval[0 ] = bool (glsl::gl_SubgroupInvocationID ()) ? left[ItemsPerInvocation-1 ] : binop_t::identity;
65
65
[unroll (ItemsPerInvocation-1 )]
66
66
for (uint32_t i = 1 ; i < ItemsPerInvocation; i++)
@@ -69,21 +69,21 @@ struct exclusive_scan
69
69
}
70
70
};
71
71
72
- template<template< class > class Binop, typename T, int32_t ItemsPerInvocation , bool native>
72
+ template<class Binop, bool native>
73
73
struct reduction
74
74
{
75
- using type_t = typename T ;
76
- using par_type_t = conditional_t<ItemsPerInvocation < 2 , type_t, vector <type_t, ItemsPerInvocation> > ;
77
- using binop_t = Binop<type_t >;
78
- using binop_par_t = Binop<par_type_t >;
75
+ using type_t = typename Binop::type_t ;
76
+ using scalar_t = typename Binop::scalar_t ;
77
+ using binop_t = Binop<scalar_t >;
78
+ using binop_par_t = Binop<type_t >;
79
79
using op_t = subgroup::impl::reduction<binop_par_t, native>;
80
80
81
- type_t operator ()(NBL_CONST_REF_ARG (par_type_t ) value)
81
+ scalar_t operator ()(NBL_CONST_REF_ARG (type_t ) value)
82
82
{
83
83
binop_t binop;
84
84
op_t op;
85
- par_type_t result = op (value);
86
- type_t retval;
85
+ type_t result = op (value);
86
+ scalar_t retval;
87
87
[unroll (ItemsPerInvocation-1 )]
88
88
for (uint32_t i = 0 ; i < ItemsPerInvocation; i++)
89
89
retval += binop (retval, result[i]);
0 commit comments