2021-01-27 23:59:47 +00:00
|
|
|
float Helper_ShuffleUp(float x, uint index, uint mask, out bool valid)
|
2019-10-31 03:29:22 +00:00
|
|
|
{
|
|
|
|
uint segMask = (mask >> 8) & 0x1fu;
|
2021-09-19 12:38:39 +00:00
|
|
|
uint minThreadId = $SUBGROUP_INVOCATION$ & segMask;
|
|
|
|
uint srcThreadId = $SUBGROUP_INVOCATION$ - index;
|
2021-08-30 17:02:40 +00:00
|
|
|
valid = int(srcThreadId) >= int(minThreadId);
|
2021-09-19 12:38:39 +00:00
|
|
|
float v = $SUBGROUP_BROADCAST$(x, srcThreadId);
|
2021-08-30 17:02:40 +00:00
|
|
|
return valid ? v : x;
|
2019-10-31 03:29:22 +00:00
|
|
|
}
|