@@ -1614,41 +1614,54 @@ template <typename T> T waveMultiPrefixProduct(T A, UINT) {
16141614
16151615template <typename T> struct Op <OpType::WaveMatch, T, 1 > : StrictValidation {};
16161616
1617+ static void WriteExpectedValueForLane (UINT *Dest, const UINT LaneID,
1618+ const std::bitset<128 > &ExpectedValue) {
1619+ std::bitset<128 > Lo32Mask;
1620+ Lo32Mask.set ();
1621+ Lo32Mask >>= 128 - 32 ;
1622+
1623+ UINT Offset = 4 * LaneID;
1624+ for (uint32_t I = 0 ; I < 4 ; I++) {
1625+ uint32_t V = ((ExpectedValue >> (I * 32 )) & Lo32Mask).to_ulong ();
1626+ Dest[Offset++] = V;
1627+ }
1628+ }
1629+
16171630template <typename T> struct ExpectedBuilder <OpType::WaveMatch, T> {
16181631 static std::vector<UINT> buildExpected (Op<OpType::WaveMatch, T, 1 > &,
1619- const InputSets<T> &,
1632+ const InputSets<T> &Inputs ,
16201633 const UINT WaveSize) {
1621- // For this test, the shader arranges it so that lane 0 is different from
1622- // all the other lanes. Besides that all other lines write their result of
1623- // WaveMatch as well.
1634+ // This test sets lanes (0, min(VectorSize/2, WaveSize/2), and
1635+ // min(VectorSize-1, WaveSize-1)) to unique values and has them modify the
1636+ // vector at their respective indices. Remaining lanes remain unchanged.
1637+ DXASSERT_NOMSG (Inputs.size () == 1 );
16241638
1639+ const UINT VectorSize = static_cast <UINT>(Inputs[0 ].size ());
16251640 std::vector<UINT> Expected;
16261641 Expected.assign (WaveSize * 4 , 0 );
16271642
1628- const UINT LowWaves = std::min (64U , WaveSize);
1629- const UINT HighWaves = WaveSize - LowWaves;
1630-
1631- const uint64_t LowWaveMask =
1632- (LowWaves < 64 ) ? (1ULL << LowWaves) - 1 : ~0ULL ;
1643+ const UINT MidLaneID = std::min (VectorSize / 2 , WaveSize / 2 );
1644+ const UINT LastLaneID = std::min (VectorSize - 1 , WaveSize - 1 );
16331645
1634- const uint64_t HighWaveMask =
1635- (HighWaves < 64 ) ? (1ULL << HighWaves) - 1 : ~0ULL ;
1646+ // Use a std::bitset<128> to represent the uint4 returned by WaveMatch as
1647+ // its convenient this way in c++
1648+ std::bitset<128 > DefaultExpectedValue;
16361649
1637- const uint64_t LowExpected = ~ 1ULL & LowWaveMask;
1638- const uint64_t HighExpected = ~ 0ULL & HighWaveMask ;
1650+ for (UINT I = 0 ; I < WaveSize; ++I)
1651+ DefaultExpectedValue. set (I) ;
16391652
1640- Expected[0 ] = 1 ;
1641- Expected[1 ] = 0 ;
1642- Expected[2 ] = 0 ;
1643- Expected[3 ] = 0 ;
1653+ DefaultExpectedValue.reset (0 );
1654+ DefaultExpectedValue.reset (MidLaneID);
1655+ DefaultExpectedValue.reset (LastLaneID);
16441656
1645- // all lanes other than the first one have the same result
1646- for (UINT I = 1 ; I < WaveSize; ++I) {
1647- const UINT Index = I * 4 ;
1648- Expected[Index] = static_cast <UINT>(LowExpected);
1649- Expected[Index + 1 ] = static_cast <UINT>(LowExpected >> 32 );
1650- Expected[Index + 2 ] = static_cast <UINT>(HighExpected);
1651- Expected[Index + 3 ] = static_cast <UINT>(HighExpected >> 32 );
1657+ for (UINT LaneID = 0 ; LaneID < WaveSize; ++LaneID) {
1658+ if (LaneID == 0 || LaneID == MidLaneID || LaneID == LastLaneID) {
1659+ std::bitset<128 > ExpectedValue (0 );
1660+ ExpectedValue.set (LaneID);
1661+ WriteExpectedValueForLane (Expected.data (), LaneID, ExpectedValue);
1662+ continue ;
1663+ }
1664+ WriteExpectedValueForLane (Expected.data (), LaneID, DefaultExpectedValue);
16521665 }
16531666
16541667 return Expected;
0 commit comments