@@ -1704,6 +1704,23 @@ bool ThreadState::JumpToBlock(const Block *target, bool divergencePoint)
1704
1704
return true ;
1705
1705
}
1706
1706
1707
+ void ThreadState::GetSubgroupActiveLanes (const rdcarray<bool > &activeMask,
1708
+ const rdcarray<ThreadState> &workgroup,
1709
+ rdcarray<uint32_t > &activeLanes) const
1710
+ {
1711
+ const uint32_t firstLaneInSub = m_WorkgroupIndex - m_SubgroupIdx;
1712
+ for (uint32_t lane = firstLaneInSub; lane < firstLaneInSub + m_GlobalState.subgroupSize ; lane++)
1713
+ {
1714
+ // wave operations exclude helpers
1715
+ if (activeMask[lane])
1716
+ {
1717
+ if (!m_GlobalState.waveOpsIncludeHelpers && workgroup[lane - firstLaneInSub].m_Helper )
1718
+ continue ;
1719
+ activeLanes.push_back (lane - firstLaneInSub);
1720
+ }
1721
+ }
1722
+ }
1723
+
1707
1724
bool ThreadState::ExecuteInstruction (DebugAPIWrapper *apiWrapper,
1708
1725
const rdcarray<ThreadState> &workgroup,
1709
1726
const rdcarray<bool > &activeMask)
@@ -3647,12 +3664,24 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
3647
3664
break ;
3648
3665
}
3649
3666
// Wave/Subgroup Operations
3667
+ case DXOp::WaveGetLaneCount:
3668
+ {
3669
+ result.value .u32v [0 ] = m_GlobalState.subgroupSize ;
3670
+ break ;
3671
+ }
3650
3672
case DXOp::WaveGetLaneIndex:
3651
3673
{
3652
- // SV_PrimitiveID
3653
3674
result.value .u32v [0 ] = m_SubgroupIdx;
3654
3675
break ;
3655
3676
}
3677
+ case DXOp::WaveIsFirstLane:
3678
+ {
3679
+ // determine active lane indices in our subgroup
3680
+ rdcarray<uint32_t > activeLanes;
3681
+ GetSubgroupActiveLanes (activeMask, workgroup, activeLanes);
3682
+ result.value .u32v [0 ] = (m_WorkgroupIndex == activeLanes[0 ]) ? 1 : 0 ;
3683
+ break ;
3684
+ }
3656
3685
case DXOp::WaveActiveOp:
3657
3686
{
3658
3687
// WaveActiveOp(value,op,sop)
@@ -3666,19 +3695,7 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
3666
3695
3667
3696
// determine active lane indices in our subgroup
3668
3697
rdcarray<uint32_t > activeLanes;
3669
-
3670
- const uint32_t firstLaneInSub = m_WorkgroupIndex - m_SubgroupIdx;
3671
- for (uint32_t lane = firstLaneInSub; lane < firstLaneInSub + m_GlobalState.subgroupSize ;
3672
- lane++)
3673
- {
3674
- // wave operations exclude helpers
3675
- if (activeMask[lane])
3676
- {
3677
- if (!m_GlobalState.waveOpsIncludeHelpers && workgroup[lane - firstLaneInSub].m_Helper )
3678
- continue ;
3679
- activeLanes.push_back (lane - firstLaneInSub);
3680
- }
3681
- }
3698
+ GetSubgroupActiveLanes (activeMask, workgroup, activeLanes);
3682
3699
3683
3700
ShaderVariable accum;
3684
3701
RDCASSERT (GetShaderVariable (inst.args [1 ], opCode, dxOpCode, accum));
@@ -4023,8 +4040,6 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
4023
4040
case DXOp::EmitThenCutStream:
4024
4041
4025
4042
// Wave/Subgroup Operations
4026
- case DXOp::WaveIsFirstLane:
4027
- case DXOp::WaveGetLaneCount:
4028
4043
case DXOp::WaveAnyTrue:
4029
4044
case DXOp::WaveAllTrue:
4030
4045
case DXOp::WaveActiveAllEqual:
0 commit comments