@@ -11565,7 +11565,7 @@ template <typename T> class DeterministicNumberGenerator {
1156511565 if constexpr (std::is_same_v<T, int64_t>)
1156611566 return Int64Dist(generator);
1156711567 if constexpr (std::is_same_v<T, float>)
11568- return FloatDist(generator);
11568+ return FloatDist(generator);
1156911569 if constexpr (std::is_same_v<T, double>)
1157011570 return DoubleDist(generator);
1157111571 if constexpr (std::is_same_v<T, uint16_t>)
@@ -11592,9 +11592,9 @@ template <typename T> class DeterministicNumberGenerator {
1159211592 std::uniform_real_distribution<float> FloatDist;
1159311593 std::uniform_real_distribution<double> DoubleDist;
1159411594
11595- // The ranges for generation. A std::uniform_real_distribution can only have
11596- // a range that is equal to the types largest value. This is due to precision
11597- // issues. So instead we define some large values.
11595+ // The ranges for generation. A std::uniform_real_distribution can only have
11596+ // a range that is equal to the types largest value. This is due to precision
11597+ // issues. So instead we define some large values.
1159811598 const float FLOAT_RANGE_MIN = -1e20f;
1159911599 const float FLOAT_RANGE_MAX = 1e20f;
1160011600 const double DOUBLE_RANGE_MIN = -1e100;
@@ -11615,6 +11615,23 @@ bool DoArraysMatch(const std::array<T, N> &ActualValues,
1161511615 if (ActualValues[Index] != ExpectedValues[Index]) {
1161611616 MismatchedIndexes.push_back(Index);
1161711617 }
11618+ } else if constexpr (std::is_same_v<T, HLSLHalf_t>) {
11619+ const DirectX::PackedVector::HALF a = ActualValues[Index].val;
11620+ const DirectX::PackedVector::HALF b = ExpectedValues[Index].val;
11621+ if(!CompareHalfULP(a, b, Tolerance))
11622+ {
11623+ MismatchedIndexes.push_back(Index);
11624+ }
11625+ } else if constexpr (std::is_same_v<T, float>) {
11626+ const int IntTolerance = static_cast<int>(Tolerance);
11627+ if(!CompareFloatULP(ActualValues[Index], ExpectedValues[Index], IntTolerance))
11628+ {
11629+ MismatchedIndexes.push_back(Index);
11630+ }
11631+ } else if constexpr (std::is_same_v<T, double>) {
11632+ Log::Warning(L"Double comparison not implemented yet. Defaulting to simple comparison for now.");
11633+ if(ActualValues[Index] != ExpectedValues[Index])
11634+ MismatchedIndexes.push_back(Index);
1161811635 } else if (Tolerance == 0 && ActualValues[Index] != ExpectedValues[Index]) {
1161911636 MismatchedIndexes.push_back(Index);
1162011637 } else {
@@ -12176,8 +12193,8 @@ void ExecutionTest::LongVectorOpTestBase(
1217612193
1217712194 // We pass these values into the shader and they're requried to compile. So
1217812195 // they need to set to something.
12179- T ClampArgC = 0;
12180- T ClampArgT = 0;
12196+ T ClampArgMin = 0;
12197+ T ClampArgMax = 0;
1218112198 if (TestConfig.OpType == LongVectorOpType_Clamp) {
1218212199 if constexpr (std::is_same_v<T, HLSLBool_t>) {
1218312200 // Attempting to generate a clamp value for HLSLBool_t will result in an
@@ -12186,12 +12203,12 @@ void ExecutionTest::LongVectorOpTestBase(
1218612203 LogErrorFmtThrow(L"Clamp is not supported for HLSLBool_t.");
1218712204 }
1218812205
12189- ClampArgC = NumberGenerator.generate();
12190- ClampArgT = NumberGenerator.generate();
12191- while (ClampArgC >= ClampArgT ) {
12192- // Generate a new value for ClampArgC . It needs to be smaller than
12193- // or equal to ClampArgT .
12194- ClampArgT = NumberGenerator.generate();
12206+ ClampArgMin = NumberGenerator.generate();
12207+ ClampArgMax = NumberGenerator.generate();
12208+ while (ClampArgMin >= ClampArgMax ) {
12209+ // Generate a new value for ClampArgMin . It needs to be smaller than
12210+ // or equal to ClampArgMax .
12211+ ClampArgMax = NumberGenerator.generate();
1219512212 }
1219612213 }
1219712214
@@ -12221,7 +12238,7 @@ void ExecutionTest::LongVectorOpTestBase(
1222112238 {
1222212239 if (TestConfig.OpType == LongVectorOpType_Clamp) {
1222312240 ExpectedVector[Index] =
12224- std::clamp(InputVector1[Index], ClampArgC, ClampArgT );
12241+ std::clamp(InputVector1[Index], ClampArgMin, ClampArgMax );
1222512242 } else if (TestConfig.OpType = LongVectorOpType_Initialize) {
1222612243 ExpectedVector[Index] = InputVector1[Index];
1222712244 } else {
@@ -12252,10 +12269,12 @@ void ExecutionTest::LongVectorOpTestBase(
1225212269 switch (TestConfig.OpType) {
1225312270 case LongVectorOpType_Clamp:
1225412271 CompilerOptions << " -DFUNC_CLAMP=1";
12255- CompilerOptions << " -DCLAMP_ARGC=";
12256- CompilerOptions << ClampArgC;
12257- CompilerOptions << " -DCLAMP_ARGT=";
12258- CompilerOptions << ClampArgT;
12272+ CompilerOptions << " -DCLAMP_ARGMIN=";
12273+ // We need to set the precision for the float values.
12274+ CompilerOptions << std::setprecision(16);
12275+ CompilerOptions << ClampArgMin;
12276+ CompilerOptions << " -DCLAMP_ARGMAX=";
12277+ CompilerOptions << ClampArgMax;
1225912278 break;
1226012279 case LongVectorOpType_Initialize:
1226112280 CompilerOptions << " -DFUNC_INITIALIZE=1";
0 commit comments