@@ -132,32 +132,32 @@ void LongVector::OpTest::dispatchTestByDataType(
132
132
using namespace WEX ::Common;
133
133
134
134
if (DataType == L" bool" )
135
- dispatchTestByVectorSize <HLSLBool_t>(OpType, Handler);
135
+ dispatchTestByVectorLength <HLSLBool_t>(OpType, Handler);
136
136
else if (DataType == L" int16" )
137
- dispatchTestByVectorSize <int16_t >(OpType, Handler);
137
+ dispatchTestByVectorLength <int16_t >(OpType, Handler);
138
138
else if (DataType == L" int32" )
139
- dispatchTestByVectorSize <int32_t >(OpType, Handler);
139
+ dispatchTestByVectorLength <int32_t >(OpType, Handler);
140
140
else if (DataType == L" int64" )
141
- dispatchTestByVectorSize <int64_t >(OpType, Handler);
141
+ dispatchTestByVectorLength <int64_t >(OpType, Handler);
142
142
else if (DataType == L" uint16" )
143
- dispatchTestByVectorSize <uint16_t >(OpType, Handler);
143
+ dispatchTestByVectorLength <uint16_t >(OpType, Handler);
144
144
else if (DataType == L" uint32" )
145
- dispatchTestByVectorSize <uint32_t >(OpType, Handler);
145
+ dispatchTestByVectorLength <uint32_t >(OpType, Handler);
146
146
else if (DataType == L" uint64" )
147
- dispatchTestByVectorSize <uint64_t >(OpType, Handler);
147
+ dispatchTestByVectorLength <uint64_t >(OpType, Handler);
148
148
else if (DataType == L" float16" )
149
- dispatchTestByVectorSize <HLSLHalf_t>(OpType, Handler);
149
+ dispatchTestByVectorLength <HLSLHalf_t>(OpType, Handler);
150
150
else if (DataType == L" float32" )
151
- dispatchTestByVectorSize <float >(OpType, Handler);
151
+ dispatchTestByVectorLength <float >(OpType, Handler);
152
152
else if (DataType == L" float64" )
153
- dispatchTestByVectorSize <double >(OpType, Handler);
153
+ dispatchTestByVectorLength <double >(OpType, Handler);
154
154
else
155
155
VERIFY_FAIL (
156
156
String ().Format (L" DataType: %s is not recognized." , DataType.c_str ()));
157
157
}
158
158
159
159
template <typename DataTypeT, typename LongVectorOpTypeT>
160
- void LongVector::OpTest::dispatchTestByVectorSize (
160
+ void LongVector::OpTest::dispatchTestByVectorLength (
161
161
LongVectorOpTypeT opType, TableParameterHandler &Handler) {
162
162
WEX::TestExecution::SetVerifyOutput verifySettings (
163
163
WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
@@ -180,21 +180,36 @@ void LongVector::OpTest::dispatchTestByVectorSize(
180
180
TestConfig.setInputValueSet2 (InputValueSet2);
181
181
}
182
182
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
+
184
195
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);
186
200
}
187
201
}
188
202
189
203
template <typename DataTypeT, typename LongVectorOpTypeT>
190
204
void LongVector::OpTest::testBaseMethod (
191
- LongVector::TestConfig<DataTypeT, LongVectorOpTypeT> &TestConfig,
192
- size_t VectorSizeToTest) {
205
+ LongVector::TestConfig<DataTypeT, LongVectorOpTypeT> &TestConfig) {
193
206
WEX::TestExecution::SetVerifyOutput verifySettings (
194
207
WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
195
208
209
+ const size_t VectorLengthToTest = TestConfig.getLengthToTest ();
210
+
196
211
hlsl_test::LogCommentFmt (L" Running LongVectorOpTestBase<%S, %zu>" ,
197
- typeid (DataTypeT).name (), VectorSizeToTest );
212
+ typeid (DataTypeT).name (), VectorLengthToTest );
198
213
199
214
bool LogInputs = false ;
200
215
WEX::TestExecution::RuntimeParameters::TryGetValue (L" LongVectorLogInputs" ,
@@ -214,9 +229,9 @@ void LongVector::OpTest::testBaseMethod(
214
229
}
215
230
216
231
std::vector<DataTypeT> InputVector1;
217
- InputVector1.reserve (VectorSizeToTest );
232
+ InputVector1.reserve (VectorLengthToTest );
218
233
std::vector<DataTypeT> InputVector2; // May be unused, but must be defined.
219
- InputVector2.reserve (VectorSizeToTest );
234
+ InputVector2.reserve (VectorLengthToTest );
220
235
std::vector<DataTypeT> ScalarInput; // May be unused, but must be defined.
221
236
const bool IsVectorBinaryOp =
222
237
TestConfig.isBinaryOp () && !TestConfig.isScalarOp ();
@@ -233,7 +248,7 @@ void LongVector::OpTest::testBaseMethod(
233
248
234
249
// Fill the input vectors with values from the value set. Repeat the values
235
250
// 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++) {
237
252
InputVector1.push_back (
238
253
InputVector1ValueSet[Index % InputVector1ValueSet.size ()]);
239
254
@@ -242,16 +257,12 @@ void LongVector::OpTest::testBaseMethod(
242
257
InputVector2ValueSet[Index % InputVector2ValueSet.size ()]);
243
258
}
244
259
245
- std::vector<DataTypeT> ExpectedVector;
246
- ExpectedVector.reserve (VectorSizeToTest);
247
260
if (IsVectorBinaryOp)
248
- ExpectedVector =
249
- computeExpectedValues (InputVector1, InputVector2, TestConfig);
261
+ computeExpectedValues (InputVector1, InputVector2, TestConfig);
250
262
else if (TestConfig.isScalarOp ())
251
- ExpectedVector =
252
- computeExpectedValues (InputVector1, ScalarInput[0 ], TestConfig);
263
+ computeExpectedValues (InputVector1, ScalarInput[0 ], TestConfig);
253
264
else // Must be a unary op
254
- ExpectedVector = computeExpectedValues (InputVector1, TestConfig);
265
+ computeExpectedValues (InputVector1, TestConfig);
255
266
256
267
if (LogInputs) {
257
268
logLongVector<DataTypeT>(InputVector1, L" InputVector1" );
@@ -264,8 +275,7 @@ void LongVector::OpTest::testBaseMethod(
264
275
265
276
// We have to construct the string outside of the lambda. Otherwise it's
266
277
// 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 ();
269
279
270
280
// The name of the shader we want to use in ShaderOpArith.xml. Could also add
271
281
// logic to set this name in ShaderOpArithTable.xml so we can use different
@@ -331,11 +341,10 @@ void LongVector::OpTest::testBaseMethod(
331
341
MappedData ShaderOutData;
332
342
TestResult->Test ->GetReadBackData (" OutputVector" , &ShaderOutData);
333
343
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));
341
350
}
0 commit comments