2021-01-28 00:59:47 +01:00
|
|
|
float Helper_ShuffleXor(float x, uint index, uint mask, out bool valid)
|
2019-10-31 04:29:22 +01:00
|
|
|
{
|
|
|
|
uint clamp = mask & 0x1fu;
|
|
|
|
uint segMask = (mask >> 8) & 0x1fu;
|
2021-09-19 14:38:39 +02:00
|
|
|
uint minThreadId = $SUBGROUP_INVOCATION$ & segMask;
|
2019-10-31 04:29:22 +01:00
|
|
|
uint maxThreadId = minThreadId | (clamp & ~segMask);
|
2021-09-19 14:38:39 +02:00
|
|
|
uint srcThreadId = $SUBGROUP_INVOCATION$ ^ index;
|
2021-01-28 00:59:47 +01:00
|
|
|
valid = srcThreadId <= maxThreadId;
|
2021-09-19 14:38:39 +02:00
|
|
|
float v = $SUBGROUP_BROADCAST$(x, srcThreadId);
|
2021-08-30 19:02:40 +02:00
|
|
|
return valid ? v : x;
|
2019-10-31 04:29:22 +01:00
|
|
|
}
|