@@ -3761,52 +3761,71 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
3761
3761
// QuadReadLaneAt(value,quadLane)
3762
3762
ShaderVariable b;
3763
3763
RDCASSERT (GetShaderVariable (inst.args [2 ], opCode, dxOpCode, b));
3764
- uint32_t lane = UINT32_MAX ;
3764
+ uint32_t lane = ~ 0U ;
3765
3765
if (dxOpCode == DXOp::QuadOp)
3766
3766
{
3767
- QuadOpKind quadOp = (QuadOpKind)b.value .u32v [0 ];
3768
- switch (quadOp)
3767
+ if (m_QuadLaneIndex == ~0U )
3769
3768
{
3770
- case QuadOpKind::ReadAcrossX:
3771
- {
3772
- // 0->1
3773
- // 1->0
3774
- // 2->3
3775
- // 3->2
3776
- if (m_WorkgroupIndex % 2 == 0 )
3777
- lane = m_WorkgroupIndex + 1 ;
3778
- else
3779
- lane = m_WorkgroupIndex - 1 ;
3780
- break ;
3781
- }
3782
- case QuadOpKind::ReadAcrossY:
3769
+ RDCERR (" Quad operation without proper quad neighbours" );
3770
+ lane = m_WorkgroupIndex;
3771
+ }
3772
+ else
3773
+ {
3774
+ QuadOpKind quadOp = (QuadOpKind)b.value .u32v [0 ];
3775
+ switch (quadOp)
3783
3776
{
3784
- // 0->2
3785
- // 1->3
3786
- // 2->0
3787
- // 3->1
3788
- if (m_WorkgroupIndex < 2 )
3789
- lane = m_WorkgroupIndex + 2 ;
3790
- else
3791
- lane = m_WorkgroupIndex - 2 ;
3792
- break ;
3777
+ case QuadOpKind::ReadAcrossX:
3778
+ {
3779
+ // 0->1
3780
+ // 1->0
3781
+ // 2->3
3782
+ // 3->2
3783
+ lane = m_QuadLaneIndex ^ 1 ;
3784
+ break ;
3785
+ }
3786
+ case QuadOpKind::ReadAcrossY:
3787
+ {
3788
+ // 0->2
3789
+ // 1->3
3790
+ // 2->0
3791
+ // 3->1
3792
+ lane = m_QuadLaneIndex ^ 2 ;
3793
+ break ;
3794
+ }
3795
+ case QuadOpKind::ReadAcrossDiagonal:
3796
+ {
3797
+ // 0->3
3798
+ // 1->2
3799
+ // 2->1
3800
+ // 3->0
3801
+ lane = m_QuadLaneIndex ^ 3 ;
3802
+ break ;
3803
+ }
3804
+ default : RDCERR (" Unhandled QuadOpKind %s" , ToStr (quadOp).c_str ()); break ;
3793
3805
}
3794
- case QuadOpKind::ReadAcrossDiagonal:
3806
+ if (lane < 4 )
3807
+ lane = m_QuadNeighbours[lane];
3808
+
3809
+ if (lane == ~0U )
3795
3810
{
3796
- // 0->3
3797
- // 1->2
3798
- // 2->1
3799
- // 3->0
3800
- lane = 3 - m_WorkgroupIndex;
3801
- break ;
3811
+ RDCERR (" QuadOp %s without proper quad neighbours" , ToStr (quadOp).c_str ());
3812
+ lane = m_WorkgroupIndex;
3802
3813
}
3803
- default : RDCERR (" Unhandled QuadOpKind %s" , ToStr (quadOp).c_str ()); break ;
3804
3814
}
3805
3815
}
3806
3816
else if (dxOpCode == DXOp::QuadReadLaneAt)
3807
3817
{
3808
3818
// QuadReadLaneAt(value,quadLane)
3809
3819
lane = b.value .u32v [0 ];
3820
+ RDCASSERT (lane < 4 , lane);
3821
+ lane = RDCMIN (lane, 3U );
3822
+ lane = m_QuadNeighbours[lane];
3823
+
3824
+ if (lane == ~0U )
3825
+ {
3826
+ RDCERR (" QuadReadLaneAt without proper quad neighbours" );
3827
+ lane = m_WorkgroupIndex;
3828
+ }
3810
3829
}
3811
3830
else
3812
3831
{
0 commit comments