diff --git a/include/dxc/Test/HlslTestUtils.h b/include/dxc/Test/HlslTestUtils.h index dd89fda676..d16a1a251b 100644 --- a/include/dxc/Test/HlslTestUtils.h +++ b/include/dxc/Test/HlslTestUtils.h @@ -260,6 +260,14 @@ inline void LogErrorFmt(const wchar_t *fmt, ...) { WEX::Logging::Log::Error(buf.data()); } +inline void LogWarningFmt(const wchar_t *fmt, ...) { + va_list args; + va_start(args, fmt); + std::wstring buf(vFormatToWString(fmt, args)); + va_end(args); + WEX::Logging::Log::Warning(buf.data()); +} + inline void LogErrorFmtThrow(const char *fileName, int line, const wchar_t *fmt, ...) { va_list args; diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index 76b3130b69..a45b4baaa5 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -135,8 +135,7 @@ void fillLongVectorDataFromShaderBuffer(const MappedData &ShaderBuffer, template void logLongVector(const std::vector &Values, const std::wstring &Name) { - WEX::Logging::Log::Comment( - WEX::Common::String().Format(L"LongVector Name: %s", Name.c_str())); + hlsl_test::LogCommentFmt(L"LongVector Name: %s", Name.c_str()); const size_t LoggingWidth = 40; @@ -153,7 +152,7 @@ void logLongVector(const std::vector &Values, const std::wstring &Name) { } Wss << L" ]"; - WEX::Logging::Log::Comment(Wss.str().c_str()); + hlsl_test::LogCommentFmt(Wss.str().c_str()); } enum class ValidationType { @@ -182,7 +181,7 @@ bool doValuesMatch(HLSLHalf_t A, HLSLHalf_t B, float Tolerance, case ValidationType::Ulp: return CompareHalfULP(A.Val, B.Val, Tolerance); default: - WEX::Logging::Log::Error( + hlsl_test::LogErrorFmt( L"Invalid ValidationType. Expecting Epsilon or ULP."); return false; } @@ -199,7 +198,7 @@ bool doValuesMatch(float A, float B, float Tolerance, return CompareFloatULP(A, B, IntTolerance); }; default: - WEX::Logging::Log::Error( + hlsl_test::LogErrorFmt( L"Invalid ValidationType. Expecting Epsilon or ULP."); return false; } @@ -216,7 +215,7 @@ bool doValuesMatch(double A, double B, float Tolerance, return CompareDoubleULP(A, B, IntTolerance); }; default: - WEX::Logging::Log::Error( + hlsl_test::LogErrorFmt( L"Invalid ValidationType. Expecting Epsilon or ULP."); return false; } @@ -254,7 +253,7 @@ bool doVectorsMatch(const std::vector &ActualValues, Wss << L"Mismatch at Index: " << Index; Wss << L" Actual Value:" << ActualValues[Index] << ","; Wss << L" Expected Value:" << ExpectedValues[Index]; - WEX::Logging::Log::Error(Wss.str().c_str()); + hlsl_test::LogErrorFmt(Wss.str().c_str()); } } @@ -449,9 +448,8 @@ InputSets buildTestInputs(size_t VectorSize, const InputSet OpInputSets[3], size_t Arity) { InputSets Inputs; - for (size_t I = 0; I < Arity; ++I) { + for (size_t I = 0; I < Arity; ++I) Inputs.push_back(buildTestInput(OpInputSets[I], VectorSize)); - } return Inputs; } @@ -1056,9 +1054,8 @@ template struct ExpectedBuilder { std::vector Expected; Expected.reserve(Inputs[0].size()); - for (size_t I = 0; I < Inputs[0].size(); ++I) { + for (size_t I = 0; I < Inputs[0].size(); ++I) Expected.push_back(Op(Inputs[0][I])); - } return Expected; } @@ -1069,9 +1066,8 @@ template struct ExpectedBuilder { std::vector Expected; Expected.reserve(Inputs[0].size()); - for (size_t I = 0; I < Inputs[0].size(); ++I) { + for (size_t I = 0; I < Inputs[0].size(); ++I) Expected.push_back(Op(Inputs[0][I], Inputs[1][I])); - } return Expected; } @@ -1082,9 +1078,8 @@ template struct ExpectedBuilder { std::vector Expected; Expected.reserve(Inputs[0].size()); - for (size_t I = 0; I < Inputs[0].size(); ++I) { + for (size_t I = 0; I < Inputs[0].size(); ++I) Expected.push_back(Op(Inputs[0][I], Inputs[1][I], Inputs[2][I])); - } return Expected; } @@ -1092,10 +1087,10 @@ template struct ExpectedBuilder { template void dispatchTest(ID3D12Device *D3DDevice, bool VerboseLogging, - size_t OverrideLongVectorInputSize) { + size_t OverrideInputSize) { std::vector InputVectorSizes; - if (OverrideLongVectorInputSize) - InputVectorSizes.push_back(OverrideLongVectorInputSize); + if (OverrideInputSize) + InputVectorSizes.push_back(OverrideInputSize); else InputVectorSizes = {3, 4, 5, 16, 17, 35, 100, 256, 1024}; @@ -1163,8 +1158,6 @@ class DxilConf_SM69_Vectorized { L"Unable to enable shader experimental mode - 0x%08x.", HR); else if (HR == S_FALSE) hlsl_test::LogCommentFmt(L"Experimental mode not enabled."); - else - hlsl_test::LogCommentFmt(L"Experimental mode enabled."); HR = enableDebugLayer(); if (FAILED(HR)) @@ -1177,27 +1170,25 @@ class DxilConf_SM69_Vectorized { WEX::TestExecution::RuntimeParameters::TryGetValue(L"VerboseLogging", VerboseLogging); if (VerboseLogging) - WEX::Logging::Log::Comment( - L"Verbose logging is enabled for this test."); + hlsl_test::LogCommentFmt(L"Verbose logging is enabled for this test."); else - WEX::Logging::Log::Comment( - L"Verbose logging is disabled for this test."); + hlsl_test::LogCommentFmt(L"Verbose logging is disabled for this test."); - WEX::TestExecution::RuntimeParameters::TryGetValue( - L"LongVectorInputSize", OverrideLongVectorInputSize); + WEX::TestExecution::RuntimeParameters::TryGetValue(L"InputSize", + OverrideInputSize); bool IsRITP = false; WEX::TestExecution::RuntimeParameters::TryGetValue(L"RITP", IsRITP); if (IsRITP) { - if (!OverrideLongVectorInputSize) + if (!OverrideInputSize) // Help keep test runtime down for RITP runs - OverrideLongVectorInputSize = 10; + OverrideInputSize = 10; else - WEX::Logging::Log::Warning(WEX::Common::String().Format( - L"RITP is enabled but LongVectorInputSize is also set. Will use " - L"the LongVectorInputSize value: %d.", - OverrideLongVectorInputSize)); + hlsl_test::LogWarningFmt( + L"RITP is enabled but InputSize is also set. Will use the" + L"InputSize value: %d.", + OverrideInputSize); } // Only skip unsupported tests for RITP runs. @@ -1219,7 +1210,7 @@ class DxilConf_SM69_Vectorized { VERIFY_IS_TRUE( createDevice(&D3DDevice, ExecTestUtils::D3D_SHADER_MODEL_6_9, false)); - dispatchTest(D3DDevice, VerboseLogging, OverrideLongVectorInputSize); + dispatchTest(D3DDevice, VerboseLogging, OverrideInputSize); } // TernaryMath @@ -1689,6 +1680,6 @@ class DxilConf_SM69_Vectorized { private: bool Initialized = false; bool VerboseLogging = false; - size_t OverrideLongVectorInputSize = 0; + size_t OverrideInputSize = 0; CComPtr D3DDevice; };