@@ -132,32 +132,32 @@ void LongVector::OpTest::dispatchTestByDataType(
132132 using namespace WEX ::Common;
133133
134134 if (DataType == L" bool" )
135- dispatchTestByVectorSize <HLSLBool_t>(OpType, Handler);
135+ dispatchTestByVectorLength <HLSLBool_t>(OpType, Handler);
136136 else if (DataType == L" int16" )
137- dispatchTestByVectorSize <int16_t >(OpType, Handler);
137+ dispatchTestByVectorLength <int16_t >(OpType, Handler);
138138 else if (DataType == L" int32" )
139- dispatchTestByVectorSize <int32_t >(OpType, Handler);
139+ dispatchTestByVectorLength <int32_t >(OpType, Handler);
140140 else if (DataType == L" int64" )
141- dispatchTestByVectorSize <int64_t >(OpType, Handler);
141+ dispatchTestByVectorLength <int64_t >(OpType, Handler);
142142 else if (DataType == L" uint16" )
143- dispatchTestByVectorSize <uint16_t >(OpType, Handler);
143+ dispatchTestByVectorLength <uint16_t >(OpType, Handler);
144144 else if (DataType == L" uint32" )
145- dispatchTestByVectorSize <uint32_t >(OpType, Handler);
145+ dispatchTestByVectorLength <uint32_t >(OpType, Handler);
146146 else if (DataType == L" uint64" )
147- dispatchTestByVectorSize <uint64_t >(OpType, Handler);
147+ dispatchTestByVectorLength <uint64_t >(OpType, Handler);
148148 else if (DataType == L" float16" )
149- dispatchTestByVectorSize <HLSLHalf_t>(OpType, Handler);
149+ dispatchTestByVectorLength <HLSLHalf_t>(OpType, Handler);
150150 else if (DataType == L" float32" )
151- dispatchTestByVectorSize <float >(OpType, Handler);
151+ dispatchTestByVectorLength <float >(OpType, Handler);
152152 else if (DataType == L" float64" )
153- dispatchTestByVectorSize <double >(OpType, Handler);
153+ dispatchTestByVectorLength <double >(OpType, Handler);
154154 else
155155 VERIFY_FAIL (
156156 String ().Format (L" DataType: %s is not recognized." , DataType.c_str ()));
157157}
158158
159159template <typename DataTypeT, typename LongVectorOpTypeT>
160- void LongVector::OpTest::dispatchTestByVectorSize (
160+ void LongVector::OpTest::dispatchTestByVectorLength (
161161 LongVectorOpTypeT opType, TableParameterHandler &Handler) {
162162 WEX::TestExecution::SetVerifyOutput verifySettings (
163163 WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
@@ -180,21 +180,36 @@ void LongVector::OpTest::dispatchTestByVectorSize(
180180 TestConfig.setInputValueSet2 (InputValueSet2);
181181 }
182182
183- std::vector<size_t > InputVectorSizes = {3 , 4 , 5 , 16 , 17 , 35 , 100 , 256 , 1024 };
183+ // Manual override to test a specific vector size. Convenient for debugging
184+ // issues.
185+ size_t InputSizeToTestOverride = 0 ;
186+ WEX::TestExecution::RuntimeParameters::TryGetValue (L" LongVectorInputSize" ,
187+ InputSizeToTestOverride);
188+
189+ std::vector<size_t > InputVectorSizes;
190+ if (InputSizeToTestOverride)
191+ InputVectorSizes.push_back (InputSizeToTestOverride);
192+ else
193+ InputVectorSizes = {3 , 4 , 5 , 16 , 17 , 35 , 100 , 256 , 1024 };
194+
184195 for (auto SizeToTest : InputVectorSizes) {
185- testBaseMethod<DataTypeT, LongVectorOpTypeT>(TestConfig, SizeToTest);
196+ // We could create a new config for each test case with the new length, but
197+ // that feels wasteful. Instead, we just update the length to test.
198+ TestConfig.setLengthToTest (SizeToTest);
199+ testBaseMethod<DataTypeT, LongVectorOpTypeT>(TestConfig);
186200 }
187201}
188202
189203template <typename DataTypeT, typename LongVectorOpTypeT>
190204void LongVector::OpTest::testBaseMethod (
191- LongVector::TestConfig<DataTypeT, LongVectorOpTypeT> &TestConfig,
192- size_t VectorSizeToTest) {
205+ LongVector::TestConfig<DataTypeT, LongVectorOpTypeT> &TestConfig) {
193206 WEX::TestExecution::SetVerifyOutput verifySettings (
194207 WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
195208
209+ const size_t VectorLengthToTest = TestConfig.getLengthToTest ();
210+
196211 hlsl_test::LogCommentFmt (L" Running LongVectorOpTestBase<%S, %zu>" ,
197- typeid (DataTypeT).name (), VectorSizeToTest );
212+ typeid (DataTypeT).name (), VectorLengthToTest );
198213
199214 bool LogInputs = false ;
200215 WEX::TestExecution::RuntimeParameters::TryGetValue (L" LongVectorLogInputs" ,
@@ -214,9 +229,9 @@ void LongVector::OpTest::testBaseMethod(
214229 }
215230
216231 std::vector<DataTypeT> InputVector1;
217- InputVector1.reserve (VectorSizeToTest );
232+ InputVector1.reserve (VectorLengthToTest );
218233 std::vector<DataTypeT> InputVector2; // May be unused, but must be defined.
219- InputVector2.reserve (VectorSizeToTest );
234+ InputVector2.reserve (VectorLengthToTest );
220235 std::vector<DataTypeT> ScalarInput; // May be unused, but must be defined.
221236 const bool IsVectorBinaryOp =
222237 TestConfig.isBinaryOp () && !TestConfig.isScalarOp ();
@@ -233,7 +248,7 @@ void LongVector::OpTest::testBaseMethod(
233248
234249 // Fill the input vectors with values from the value set. Repeat the values
235250 // when we reach the end of the value set.
236- for (size_t Index = 0 ; Index < VectorSizeToTest ; Index++) {
251+ for (size_t Index = 0 ; Index < VectorLengthToTest ; Index++) {
237252 InputVector1.push_back (
238253 InputVector1ValueSet[Index % InputVector1ValueSet.size ()]);
239254
@@ -242,16 +257,12 @@ void LongVector::OpTest::testBaseMethod(
242257 InputVector2ValueSet[Index % InputVector2ValueSet.size ()]);
243258 }
244259
245- std::vector<DataTypeT> ExpectedVector;
246- ExpectedVector.reserve (VectorSizeToTest);
247260 if (IsVectorBinaryOp)
248- ExpectedVector =
249- computeExpectedValues (InputVector1, InputVector2, TestConfig);
261+ computeExpectedValues (InputVector1, InputVector2, TestConfig);
250262 else if (TestConfig.isScalarOp ())
251- ExpectedVector =
252- computeExpectedValues (InputVector1, ScalarInput[0 ], TestConfig);
263+ computeExpectedValues (InputVector1, ScalarInput[0 ], TestConfig);
253264 else // Must be a unary op
254- ExpectedVector = computeExpectedValues (InputVector1, TestConfig);
265+ computeExpectedValues (InputVector1, TestConfig);
255266
256267 if (LogInputs) {
257268 logLongVector<DataTypeT>(InputVector1, L" InputVector1" );
@@ -264,8 +275,7 @@ void LongVector::OpTest::testBaseMethod(
264275
265276 // We have to construct the string outside of the lambda. Otherwise it's
266277 // cleaned up when the lambda finishes executing but before the shader runs.
267- std::string CompilerOptionsString =
268- TestConfig.getCompilerOptionsString (VectorSizeToTest);
278+ std::string CompilerOptionsString = TestConfig.getCompilerOptionsString ();
269279
270280 // The name of the shader we want to use in ShaderOpArith.xml. Could also add
271281 // logic to set this name in ShaderOpArithTable.xml so we can use different
@@ -331,11 +341,10 @@ void LongVector::OpTest::testBaseMethod(
331341 MappedData ShaderOutData;
332342 TestResult->Test ->GetReadBackData (" OutputVector" , &ShaderOutData);
333343
334- std::vector<DataTypeT> OutputVector;
335- fillLongVectorDataFromShaderBuffer<DataTypeT>(ShaderOutData, OutputVector,
336- VectorSizeToTest);
337-
338- VERIFY_SUCCEEDED (doVectorsMatch<DataTypeT>(OutputVector, ExpectedVector,
339- TestConfig.getTolerance (),
340- TestConfig.getValidationType ()));
344+ // The TestConfig object help handles more complicated verification cases. We
345+ // pass in the MappedData instead of the typed data because the TestConfig may
346+ // need to resolve the output type for test cases where the return type of the
347+ // intrinsic being tested does not match the input type, such as the AsType*
348+ // intrinsics (AsInt, AsInt16, AsFloat, ... etc).
349+ VERIFY_SUCCEEDED (TestConfig.verifyOutput (ShaderOutData));
341350}
0 commit comments