-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Closed
Labels
Description
I'm seeing invalid SPIRV generation for cases where LLVM's switch lowering is generating switch tables. This reproduces whether you use a switch statement explicitly or an if/else if/else chain.
StructuredBuffer<int> InInt : register(t0);
RWStructuredBuffer<int> OutBroadcast : register(u1);
RWStructuredBuffer<int> OutShift : register(u2);
RWStructuredBuffer<int> OutMix : register(u3);
[numthreads(4,1,1)]
void main(uint3 TID : SV_GroupThreadID) {
OutBroadcast[TID.x] = WaveReadLaneAt(InInt[TID.x], 2);
uint PosShiftIndex = (TID.x + 1) % 4;
int PosValue = WaveReadLaneAt(InInt[TID.x], PosShiftIndex);
uint NegShiftIndex = (TID.x - 1) % 4;
int NegValue = WaveReadLaneAt(InInt[TID.x], NegShiftIndex);
OutShift[TID.x] = PosValue + NegValue;
uint MixIndex = 0;
#if SWITCH
switch (TID.x) {
case 0:
MixIndex = 2;
break;
case 1:
MixIndex = 3;
break;
case 2:
MixIndex = 1;
break;
default:
break;
}
#else
if (TID.x == 0)
MixIndex = 2;
else if (TID.x == 1)
MixIndex = 3;
else if (TID.x == 2)
MixIndex = 1;
#endif
OutMix[TID.x] = WaveReadLaneAt(InInt[TID.x], MixIndex);
}