SwizzleAdd (NOT TESTED)

This commit is contained in:
Isaac Marovitz 2024-07-24 15:43:53 +01:00 committed by Isaac Marovitz
parent 558752594c
commit fdf7578928
6 changed files with 21 additions and 8 deletions

View file

@ -0,0 +1,7 @@
float swizzleAdd(float x, float y, int mask, uint thread_index_in_simdgroup)
{
float4 xLut = float4(1.0, -1.0, 1.0, 0.0);
float4 yLut = float4(1.0, 1.0, -1.0, 1.0);
int lutIdx = (mask >> (int(thread_index_in_simdgroup & 3u) * 2)) & 3;
return x * xLut[lutIdx] + y * yLut[lutIdx];
}