@@ -146,6 +146,7 @@ enum BinaryOpType {
146
146
BinaryOpType_Max,
147
147
BinaryOpType_ScalarMin,
148
148
BinaryOpType_ScalarMax,
149
+ BinaryOpType_AsDouble,
149
150
BinaryOpType_EnumValueCount
150
151
};
151
152
@@ -164,6 +165,7 @@ static const LongVectorOpTypeStringToEnumValue binaryOpTypeStringToEnumMap[] = {
164
165
{L" BinaryOpType_Max" , BinaryOpType_Max},
165
166
{L" BinaryOpType_ScalarMin" , BinaryOpType_ScalarMin},
166
167
{L" BinaryOpType_ScalarMax" , BinaryOpType_ScalarMax},
168
+ {L" BinaryOpType_AsDouble" , BinaryOpType_AsDouble},
167
169
};
168
170
169
171
static_assert (_countof(binaryOpTypeStringToEnumMap) ==
@@ -180,6 +182,7 @@ enum UnaryOpType {
180
182
UnaryOpType_AsInt,
181
183
UnaryOpType_AsInt16,
182
184
UnaryOpType_AsUint,
185
+ UnaryOpType_AsUint_SplitDouble,
183
186
UnaryOpType_AsUint16,
184
187
UnaryOpType_EnumValueCount
185
188
};
@@ -191,6 +194,7 @@ static const LongVectorOpTypeStringToEnumValue unaryOpTypeStringToEnumMap[] = {
191
194
{L" UnaryOpType_AsInt" , UnaryOpType_AsInt},
192
195
{L" UnaryOpType_AsInt16" , UnaryOpType_AsInt16},
193
196
{L" UnaryOpType_AsUint" , UnaryOpType_AsUint},
197
+ {L" UnaryOpType_AsUint_SplitDouble" , UnaryOpType_AsUint_SplitDouble},
194
198
{L" UnaryOpType_AsUint16" , UnaryOpType_AsUint16},
195
199
};
196
200
@@ -327,6 +331,38 @@ unsigned int asUint(const int &A) {
327
331
return LongVector::bit_cast<unsigned int >(A);
328
332
}
329
333
334
+ template <typename DataTypeInT>
335
+ void splitDouble ([[maybe_unused]] const DataTypeInT &A,
336
+ [[maybe_unused]] uint32_t &LowBits,
337
+ [[maybe_unused]] uint32_t &HighBits) {
338
+ LOG_ERROR_FMT_THROW (L" Programmer Error: splitDouble only accepts a double as "
339
+ L" input. Have DataTypeInT: %S" ,
340
+ typeid (DataTypeInT).name ());
341
+ }
342
+
343
+ void splitDouble (const double &A, uint32_t &LowBits, uint32_t &HighBits) {
344
+ uint64_t Bits = 0 ;
345
+ std::memcpy (&Bits, &A, sizeof (Bits));
346
+ LowBits = static_cast <uint32_t >(Bits & 0xFFFFFFFF );
347
+ HighBits = static_cast <uint32_t >(Bits >> 32 );
348
+ }
349
+
350
+ template <typename DataTypeInT>
351
+ double asDouble ([[maybe_unused]] const DataTypeInT &LowBits,
352
+ [[maybe_unused]] const DataTypeInT &HighBits) {
353
+ LOG_ERROR_FMT_THROW (L" Programmer Error: asDouble only accepts two uint32_t "
354
+ L" inputs. Have DataTypeInT : %S" ,
355
+ typeid (DataTypeInT).name ());
356
+ return 0.0 ;
357
+ }
358
+
359
+ double asDouble (const uint32_t &LowBits, const uint32_t &HighBits) {
360
+ uint64_t Bits = (static_cast <uint64_t >(HighBits) << 32 ) | LowBits;
361
+ double Result;
362
+ std::memcpy (&Result, &Bits, sizeof (Result));
363
+ return Result;
364
+ }
365
+
330
366
template <typename LongVectorOpTypeT> struct TestConfigTraits {
331
367
TestConfigTraits (LongVectorOpTypeT OpType) : OpType(OpType) {}
332
368
// LongVectorOpTypeT* Enum values. We don't use a UINT because
@@ -393,9 +429,6 @@ template <typename DataTypeT, typename LongVectorOpTypeT> class TestConfig {
393
429
394
430
bool isAsTypeOp () const { return isAsTypeOp (OpTypeTraits.OpType ); }
395
431
396
- bool hasFunctionDefinition () const ;
397
- std::string getOPERAND2String () const ;
398
-
399
432
// Helpers to get the hlsl type as a string for a given C++ type.
400
433
std::string getHLSLInputTypeString () const ;
401
434
std::string getHLSLOutputTypeString () const ;
@@ -409,6 +442,9 @@ template <typename DataTypeT, typename LongVectorOpTypeT> class TestConfig {
409
442
DataTypeT computeExpectedValue (const DataTypeT &A) const ;
410
443
void
411
444
computeExpectedValuesForAsTypeOp (const std::vector<DataTypeT> &InputVector1);
445
+ void
446
+ computeExpectedValuesForAsTypeOp (const std::vector<DataTypeT> &InputVector1,
447
+ const std::vector<DataTypeT> &InputVector2);
412
448
413
449
void setInputArgsArrayName (const std::wstring &InputArgsArrayName) {
414
450
this ->InputArgsArrayName = InputArgsArrayName;
@@ -451,28 +487,29 @@ template <typename DataTypeT, typename LongVectorOpTypeT> class TestConfig {
451
487
452
488
LongVector::VariantVector &getExpectedVector () { return ExpectedVector; }
453
489
454
- bool verifyOutput (MappedData &ShaderOutData );
490
+ bool verifyOutput (const std::shared_ptr<st::ShaderOpTestResult> &TestResult );
455
491
456
492
private:
457
493
bool isAsTypeOp (LongVector::UnaryOpType OpType) const ;
458
- bool isAsTypeOp (LongVector::BinaryOpType) const { return false ; }
494
+ bool isAsTypeOp (LongVector::BinaryOpType) const ;
459
495
bool isAsTypeOp (LongVector::TrigonometricOpType) const { return false ; }
460
496
461
- std::string HLSLOutputTypeString (LongVector::UnaryOpType OpType) const ;
462
-
463
- bool resolveOutputTypeAndVerifyOutput (MappedData &ShaderOutData);
497
+ bool resolveOutputTypeAndVerifyOutput (
498
+ const std::shared_ptr<st::ShaderOpTestResult> &TestResult);
464
499
465
500
// Templated version to be used when the output data type does not match the
466
501
// input data type.
467
502
template <typename OutputDataTypeT>
468
- bool verifyOutput (MappedData &ShaderOutData );
503
+ bool verifyOutput (const std::shared_ptr<st::ShaderOpTestResult> &TestResult );
469
504
470
505
std::vector<DataTypeT> getInputValueSet (size_t ValueSetIndex) const ;
471
506
472
507
// To be used for the value of -DOPERATOR
473
508
std::string OperatorString;
474
509
// To be used for the value of -DFUNC
475
510
std::string IntrinsicString;
511
+ // Used to add special -D defines to the compiler options.
512
+ std::string SpecialDefines = " " ;
476
513
LongVector::BasicOpType BasicOpType = LongVector::BasicOpType_EnumValueCount;
477
514
float Tolerance = 0.0 ;
478
515
LongVector::ValidationType ValidationType =
0 commit comments