@@ -11251,7 +11251,7 @@ struct hlslBool_t
1125111251 return static_cast<bool>(val) != static_cast<bool>(other.val);
1125211252 }
1125311253
11254- // So we can construct strings using std::wostream
11254+ // So we can construct std::wstrings using std::wostream
1125511255 friend std::wostream& operator<<(std::wostream& os, const hlslBool_t& obj) {
1125611256 os << static_cast<bool>(obj.val);
1125711257 return os;
@@ -11260,7 +11260,8 @@ struct hlslBool_t
1126011260 int32_t val = 0;
1126111261};
1126211262
11263- // No native float16 type in C++. So we use uint16_t to represent it.
11263+ // No native float16 type in C++ until C++23 . So we use uint16_t to represent
11264+ // it. Simple little wrapping struct to help handle the right behavior.
1126411265struct hlslHalf_t
1126511266{
1126611267 hlslHalf_t() : val(0) {}
@@ -11291,20 +11292,18 @@ struct hlslHalf_t
1129111292 return hlslHalf_t(val - other.val);
1129211293 }
1129311294
11294- // So we can construct strings using std::wostream
11295+ // So we can construct std::wstrings using std::wostream
1129511296 friend std::wostream& operator<<(std::wostream& os, const hlslHalf_t& obj) {
11297+ // long is larger than half. This is a safe cast.
1129611298 os << static_cast<long>(obj.val);
1129711299 return os;
1129811300 }
1129911301
1130011302 uint16_t val = 0;
1130111303};
1130211304
11303- // TODOLongVec : Need to change the members to vectors. But when I did that the
11304- // copy logic to read back from the shader buffer fails. Needs to fix that
11305- // before checking in PR.
11306- // SLongVectorBinaryOp is used in ShaderOpArithTable.xml. The shader program
11307- // uses the struct defintion to read from the input global buffer.
11305+ // SLongVectorBinaryOp is used in ShaderOpArithTable.xml. The shaders for these
11306+ // tests use the struct defintion to read from the input global buffer.
1130811307template <typename T, std::size_t N>
1130911308struct SLongVectorBinaryOp {
1131011309 T scalarInput;
@@ -11317,44 +11316,51 @@ struct SLongVectorBinaryOp {
1131711316// vec2 == Expected vector
1131811317template <typename T>
1131911318bool DoVectorsMatch(const std::vector<T>& vec1, const std::vector<T>& vec2, double tolerance) {
11320- // Sanity check. Ensure both vectors have the same size
11321- if (vec1.size() != vec2.size()) {
11322- VERIFY_IS_TRUE(false, L"Vectors are of different sizes!");
11323- return false;
11324- }
11325-
11326- // Stash mismatched indexes for easy failure logging later
11327- std::vector<size_t> mismatchedIndexes;
11328- for (size_t i = 0; i < vec1.size(); ++i) {
11329- if (tolerance == 0 && vec1[i] != vec2[i]) {
11330- mismatchedIndexes.push_back(i);
11331- } else if constexpr (std::is_same_v<T, hlslBool_t>) {
11332- // Compiler was very picky and wanted an explicit case for any T that
11333- // doesn't implement the operators in the below else. ( > and -). It
11334- // wouldn't accept putting this constexpr as an or case in the above if.
11335- if (vec1[i] != vec2[i]) {
11336- mismatchedIndexes.push_back(i);
11337- }
11338- } else {
11339- T diff = vec1[i] > vec2[i] ? vec1[i] - vec2[i] : vec2[i] - vec1[i];
11340- if (diff > tolerance) {
11341- mismatchedIndexes.push_back(i);
11342- }
11319+ // Sanity check. Ensure both vectors have the same size
11320+ if (vec1.size() != vec2.size()) {
11321+ VERIFY_IS_TRUE(false, L"Vectors are of different sizes!");
11322+ return false;
11323+ }
11324+
11325+ // Stash mismatched indexes for easy failure logging later
11326+ std::vector<size_t> mismatchedIndexes;
11327+ for (size_t i = 0; i < vec1.size(); ++i) {
11328+ if constexpr (std::is_same_v<T, hlslBool_t>) {
11329+ // Compiler was very picky and wanted an explicit case for any T that
11330+ // doesn't implement the operators in the below else. ( > and -). It
11331+ // wouldn't accept putting this constexpr as an or case in the above if.
11332+ if (vec1[i] != vec2[i]) {
11333+ mismatchedIndexes.push_back(i);
11334+ }
11335+ else if (tolerance == 0 && vec1[i] != vec2[i]) {
11336+ mismatchedIndexes.push_back(i);
11337+ } else if constexpr (std::is_same_v<T, hlslBool_t>) {
11338+ // Compiler was very picky and wanted an explicit case for any T that
11339+ // doesn't implement the operators in the below else. ( > and -). It
11340+ // wouldn't accept putting this constexpr as an or case in the above if.
11341+ if (vec1[i] != vec2[i]) {
11342+ mismatchedIndexes.push_back(i);
11343+ }
11344+ } else {
11345+ T diff = vec1[i] > vec2[i] ? vec1[i] - vec2[i] : vec2[i] - vec1[i];
11346+ if (diff > tolerance) {
11347+ mismatchedIndexes.push_back(i);
1134311348 }
1134411349 }
11350+ }
1134511351
11346- // Print the mismatched indexes and their corresponding elements
11347- if (!mismatchedIndexes.empty()) {
11348- for (size_t index : mismatchedIndexes) {
11349- std::wstringstream wss(L"");
11350- wss << L"Mismatch at Index: " << index;
11351- wss << L" Actual Value:" << vec1[index] << ",";
11352- wss << L" Expected Value:" << vec2[index];
11353- WEX::Logging::Log::Error(wss.str().c_str());
11354- }
11352+ // Print the mismatched indexes and their corresponding elements
11353+ if (!mismatchedIndexes.empty()) {
11354+ for (size_t index : mismatchedIndexes) {
11355+ std::wstringstream wss(L"");
11356+ wss << L"Mismatch at Index: " << index;
11357+ wss << L" Actual Value:" << vec1[index] << ",";
11358+ wss << L" Expected Value:" << vec2[index];
11359+ WEX::Logging::Log::Error(wss.str().c_str());
1135511360 }
11361+ }
1135611362
11357- return mismatchedIndexes.empty();
11363+ return mismatchedIndexes.empty();
1135811364}
1135911365
1136011366template <typename T>
@@ -11421,11 +11427,6 @@ std::string GetHLSLTypeString() {
1142111427 return "uint32_t";
1142211428 } else if (std::is_same_v<T, uint64_t>) {
1142311429 return "uint64_t";
11424- // TODOLONGVEC: Need special logic for these types in C++
11425- //} else if (std::is_same_v<T, packed_int16_t>) {
11426- // return "packed_int16_t";
11427- //} else if (std::is_same_v<T, packed_uint16_t>) {
11428- // return "packed_uint16_t";
1142911430 } else {
1143011431 std::string errStr("GetHLSLTypeString() Unsupported type: ");
1143111432 errStr.append(typeid(T).name());
@@ -11447,11 +11448,10 @@ template <typename T>
1144711448std::vector<std::vector<T>> parseStringsToNumbers(const std::vector<WEX::Common::String>* input) {
1144811449 std::vector<std::vector<T>> result = {};
1144911450 if (input == nullptr || input->empty()) {
11450- return result;
11451+ return result;
1145111452 }
1145211453
1145311454 for (const auto& wexStr : *input) {
11454-
1145511455 std::wstring wStr(wexStr);
1145611456 std::wstringstream wss(wStr);
1145711457 std::wstring number;
@@ -11463,77 +11463,76 @@ std::vector<std::vector<T>> parseStringsToNumbers(const std::vector<WEX::Common:
1146311463 result.push_back(vec);
1146411464 }
1146511465
11466- // Sanity check for bad test data.
11466+ // Sanity check for bad XML test data.
1146711467 VERIFY_IS_TRUE(result.size() == input->size(), L"Result vector size does not match input vector size.");
1146811468
1146911469 return result;
1147011470}
1147111471
1147211472TEST_F(ExecutionTest, LongVector_BinaryOpTest_bool) {
1147311473 WEX::TestExecution::SetVerifyOutput verifySettings(
11474- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11474+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1147511475 LongVectorBinaryOpTestBase<hlslBool_t>();
1147611476}
1147711477
1147811478TEST_F(ExecutionTest, LongVector_BinaryOpTest_float16) {
1147911479 WEX::TestExecution::SetVerifyOutput verifySettings(
11480- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11481-
11480+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1148211481 LongVectorBinaryOpTestBase<hlslHalf_t>();
1148311482}
1148411483
1148511484TEST_F(ExecutionTest, LongVector_BinaryOpTest_float32) {
1148611485 WEX::TestExecution::SetVerifyOutput verifySettings(
11487- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11486+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1148811487 LongVectorBinaryOpTestBase<float>();
1148911488}
1149011489
1149111490TEST_F(ExecutionTest, LongVector_BinaryOpTest_float64) {
1149211491 WEX::TestExecution::SetVerifyOutput verifySettings(
11493- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11492+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1149411493 LongVectorBinaryOpTestBase<double>();
1149511494}
1149611495
1149711496TEST_F(ExecutionTest, LongVector_BinaryOpTest_int16) {
1149811497 WEX::TestExecution::SetVerifyOutput verifySettings(
11499- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11498+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1150011499 LongVectorBinaryOpTestBase<int16_t>();
1150111500}
1150211501
1150311502TEST_F(ExecutionTest, LongVector_BinaryOpTest_int32) {
1150411503 WEX::TestExecution::SetVerifyOutput verifySettings(
11505- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11504+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1150611505 LongVectorBinaryOpTestBase<int32_t>();
1150711506}
1150811507
1150911508TEST_F(ExecutionTest, LongVector_BinaryOpTest_int64) {
1151011509 WEX::TestExecution::SetVerifyOutput verifySettings(
11511- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11510+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1151211511 LongVectorBinaryOpTestBase<int64_t>();
1151311512}
1151411513
1151511514TEST_F(ExecutionTest, LongVector_BinaryOpTest_uint16) {
1151611515 WEX::TestExecution::SetVerifyOutput verifySettings(
11517- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11516+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1151811517 LongVectorBinaryOpTestBase<uint16_t>();
1151911518}
1152011519
1152111520TEST_F(ExecutionTest, LongVector_BinaryOpTest_uint32) {
1152211521 WEX::TestExecution::SetVerifyOutput verifySettings(
11523- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11522+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1152411523 LongVectorBinaryOpTestBase<uint32_t>();
1152511524}
1152611525
1152711526TEST_F(ExecutionTest, LongVector_BinaryOpTest_uint64) {
1152811527 WEX::TestExecution::SetVerifyOutput verifySettings(
11529- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11528+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1153011529 LongVectorBinaryOpTestBase<uint64_t>();
1153111530}
1153211531
1153311532template <typename T>
1153411533void ExecutionTest::LongVectorBinaryOpTestBase() {
1153511534 WEX::TestExecution::SetVerifyOutput verifySettings(
11536- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11535+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1153711536 LongVectorBinaryOpTestBase<T, 4>();
1153811537 LongVectorBinaryOpTestBase<T, 5>();
1153911538 LongVectorBinaryOpTestBase<T, 16>();
@@ -11547,7 +11546,7 @@ void ExecutionTest::LongVectorBinaryOpTestBase() {
1154711546template <typename T, std::size_t N>
1154811547void ExecutionTest::LongVectorBinaryOpTestBase() {
1154911548 WEX::TestExecution::SetVerifyOutput verifySettings(
11550- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11549+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1155111550
1155211551 LogCommentFmt(L"Running LongVectorBinaryOpTestBase<%S, %zu>", typeid(T).name(), N);
1155311552
@@ -11573,7 +11572,7 @@ void ExecutionTest::LongVectorBinaryOpTestBase() {
1157311572 // test method.
1157411573 const int tableSize = sizeof(LongVectorBinaryOpParameters) / sizeof(TableParameter);
1157511574 TableParameterHandler handler(LongVectorBinaryOpParameters, tableSize);
11576-
11575+
1157711576 CW2A Target(handler.GetTableParamByName(L"ShaderOp.Target")->m_str);
1157811577 CW2A Text(handler.GetTableParamByName(L"ShaderOp.Text")->m_str);
1157911578
@@ -11734,62 +11733,62 @@ struct SLongVectorUnaryOp {
1173411733
1173511734TEST_F(ExecutionTest, LongVector_UnaryOpTest_float16) {
1173611735 WEX::TestExecution::SetVerifyOutput verifySettings(
11737- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11736+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1173811737 LongVectorUnaryOpTestBase<hlslHalf_t>();
1173911738}
1174011739
1174111740TEST_F(ExecutionTest, LongVector_UnaryOpTest_float32) {
1174211741 WEX::TestExecution::SetVerifyOutput verifySettings(
11743- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11742+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1174411743 LongVectorUnaryOpTestBase<float>();
1174511744}
1174611745
1174711746TEST_F(ExecutionTest, LongVector_UnaryOpTest_float64) {
1174811747 WEX::TestExecution::SetVerifyOutput verifySettings(
11749- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11748+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1175011749 LongVectorUnaryOpTestBase<double>();
1175111750}
1175211751
1175311752TEST_F(ExecutionTest, LongVector_UnaryOpTest_int16) {
1175411753 WEX::TestExecution::SetVerifyOutput verifySettings(
11755- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11754+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1175611755 LongVectorUnaryOpTestBase<int16_t>();
1175711756}
1175811757
1175911758TEST_F(ExecutionTest, LongVector_UnaryOpTest_int32) {
1176011759 WEX::TestExecution::SetVerifyOutput verifySettings(
11761- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11760+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1176211761 LongVectorUnaryOpTestBase<int32_t>();
1176311762}
1176411763
1176511764TEST_F(ExecutionTest, LongVector_UnaryOpTest_int64) {
1176611765 WEX::TestExecution::SetVerifyOutput verifySettings(
11767- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11766+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1176811767 LongVectorUnaryOpTestBase<int64_t>();
1176911768}
1177011769
1177111770TEST_F(ExecutionTest, LongVector_UnaryOpTest_uint16) {
1177211771 WEX::TestExecution::SetVerifyOutput verifySettings(
11773- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11772+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1177411773 LongVectorUnaryOpTestBase<uint16_t>();
1177511774}
1177611775
1177711776TEST_F(ExecutionTest, LongVector_UnaryOpTest_uint32) {
1177811777 WEX::TestExecution::SetVerifyOutput verifySettings(
11779- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11778+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1178011779 LongVectorUnaryOpTestBase<uint32_t>();
1178111780}
1178211781
1178311782TEST_F(ExecutionTest, LongVector_UnaryOpTest_uint64) {
1178411783 WEX::TestExecution::SetVerifyOutput verifySettings(
11785- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11784+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1178611785 LongVectorUnaryOpTestBase<uint64_t>();
1178711786}
1178811787
1178911788template <typename T>
1179011789void ExecutionTest::LongVectorUnaryOpTestBase() {
1179111790 WEX::TestExecution::SetVerifyOutput verifySettings(
11792- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11791+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1179311792
1179411793 LongVectorUnaryOpTestBase<T, 4>();
1179511794 LongVectorUnaryOpTestBase<T, 5>();
@@ -11804,7 +11803,7 @@ void ExecutionTest::LongVectorUnaryOpTestBase() {
1180411803template <typename T, std::size_t N>
1180511804void ExecutionTest::LongVectorUnaryOpTestBase() {
1180611805 WEX::TestExecution::SetVerifyOutput verifySettings(
11807- WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
11806+ WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
1180811807
1180911808 LogCommentFmt(L"Running LongVectorUnaryOpTestBase<%S, %zu>", typeid(T).name(), N);
1181011809
@@ -11947,8 +11946,7 @@ void ExecutionTest::LongVectorUnaryOpTestBase() {
1194711946
1194811947 // Cast the buffer back into an array of the structs we expect.
1194911948 SLongVectorUnaryOp<T, N> *pPrimitive = (SLongVectorUnaryOp<T, N>*)data.data();
11950- for(size_t i = 0; i < inputVectorCount; i++)
11951- {
11949+ for(size_t i = 0; i < inputVectorCount; i++) {
1195211950 SLongVectorUnaryOp<T, N> *p = &pPrimitive[i];
1195311951 std::vector<T> vecOutput(p->vecOutput.begin(), p->vecOutput.end());
1195411952
0 commit comments