Skip to content

Commit bb84ad9

Browse files
Merge pull request #875 from Devsh-Graphics-Programming/small-subgroup-arithmetic-opt
minor improve to exclusive scan (less registers)
2 parents 7896216 + c78e8c0 commit bb84ad9

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

include/nbl/builtin/hlsl/subgroup2/arithmetic_portability_impl.hlsl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,8 @@ struct exclusive_scan<Params, BinOp, 1, false>
185185

186186
scalar_t operator()(scalar_t value)
187187
{
188-
value = inclusive_scan<Params, BinOp, 1, false>::__call(value);
189-
// can't risk getting short-circuited, need to store to a var
190-
scalar_t left = glsl::subgroupShuffleUp<scalar_t>(value,1);
191-
// the first invocation doesn't have anything in its left so we set to the binop's identity value for exlusive scan
192-
return hlsl::mix(binop_t::identity, left, bool(glsl::gl_SubgroupInvocationID()));
188+
scalar_t left = hlsl::mix(binop_t::identity, glsl::subgroupShuffleUp<scalar_t>(value,1), bool(glsl::gl_SubgroupInvocationID()));
189+
return inclusive_scan<Params, BinOp, 1, false>::__call(left);
193190
}
194191
};
195192

0 commit comments

Comments
 (0)