Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/dxc/Test/HlslTestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
59 changes: 25 additions & 34 deletions tools/clang/unittests/HLSLExec/LongVectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ void fillLongVectorDataFromShaderBuffer(const MappedData &ShaderBuffer,

template <typename T>
void logLongVector(const std::vector<T> &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;

Expand All @@ -153,7 +152,7 @@ void logLongVector(const std::vector<T> &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 {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -254,7 +253,7 @@ bool doVectorsMatch(const std::vector<T> &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());
}
}

Expand Down Expand Up @@ -449,9 +448,8 @@ InputSets<T> buildTestInputs(size_t VectorSize, const InputSet OpInputSets[3],
size_t Arity) {
InputSets<T> Inputs;

for (size_t I = 0; I < Arity; ++I) {
for (size_t I = 0; I < Arity; ++I)
Inputs.push_back(buildTestInput<T>(OpInputSets[I], VectorSize));
}

return Inputs;
}
Expand Down Expand Up @@ -1056,9 +1054,8 @@ template <OpType OP, typename T> struct ExpectedBuilder {
std::vector<decltype(Op(T()))> 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;
}
Expand All @@ -1069,9 +1066,8 @@ template <OpType OP, typename T> struct ExpectedBuilder {
std::vector<decltype(Op(T(), T()))> 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;
}
Expand All @@ -1082,20 +1078,19 @@ template <OpType OP, typename T> struct ExpectedBuilder {
std::vector<decltype(Op(T(), T(), T()))> 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;
}
};

template <typename T, OpType OP>
void dispatchTest(ID3D12Device *D3DDevice, bool VerboseLogging,
size_t OverrideLongVectorInputSize) {
size_t OverrideInputSize) {
std::vector<size_t> InputVectorSizes;
if (OverrideLongVectorInputSize)
InputVectorSizes.push_back(OverrideLongVectorInputSize);
if (OverrideInputSize)
InputVectorSizes.push_back(OverrideInputSize);
else
InputVectorSizes = {3, 4, 5, 16, 17, 35, 100, 256, 1024};

Expand Down Expand Up @@ -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))
Expand All @@ -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.
Expand All @@ -1219,7 +1210,7 @@ class DxilConf_SM69_Vectorized {
VERIFY_IS_TRUE(
createDevice(&D3DDevice, ExecTestUtils::D3D_SHADER_MODEL_6_9, false));

dispatchTest<T, OP>(D3DDevice, VerboseLogging, OverrideLongVectorInputSize);
dispatchTest<T, OP>(D3DDevice, VerboseLogging, OverrideInputSize);
}

// TernaryMath
Expand Down Expand Up @@ -1689,6 +1680,6 @@ class DxilConf_SM69_Vectorized {
private:
bool Initialized = false;
bool VerboseLogging = false;
size_t OverrideLongVectorInputSize = 0;
size_t OverrideInputSize = 0;
CComPtr<ID3D12Device> D3DDevice;
};
Loading