@@ -56,10 +56,10 @@ static std::optional<uint32_t> extractMdIntValue(MDNode *Node,
56
56
return std::nullopt;
57
57
}
58
58
59
- static std::optional<APFloat > extractMdFloatValue (MDNode *Node,
60
- unsigned int OpId) {
59
+ static std::optional<float > extractMdFloatValue (MDNode *Node,
60
+ unsigned int OpId) {
61
61
if (auto *CI = mdconst::dyn_extract<ConstantFP>(Node->getOperand (OpId).get ()))
62
- return CI->getValue ();
62
+ return CI->getValueAPF (). convertToFloat ();
63
63
return std::nullopt;
64
64
}
65
65
@@ -295,8 +295,8 @@ static bool parseStaticSampler(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
295
295
else
296
296
return reportError (Ctx, " Invalid value for AddressW" );
297
297
298
- if (std::optional<APFloat > Val = extractMdFloatValue (StaticSamplerNode, 5 ))
299
- Sampler.MipLODBias = Val-> convertToFloat () ;
298
+ if (std::optional<float > Val = extractMdFloatValue (StaticSamplerNode, 5 ))
299
+ Sampler.MipLODBias = * Val;
300
300
else
301
301
return reportError (Ctx, " Invalid value for MipLODBias" );
302
302
@@ -315,13 +315,13 @@ static bool parseStaticSampler(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
315
315
else
316
316
return reportError (Ctx, " Invalid value for ComparisonFunc " );
317
317
318
- if (std::optional<APFloat > Val = extractMdFloatValue (StaticSamplerNode, 9 ))
319
- Sampler.MinLOD = Val-> convertToFloat () ;
318
+ if (std::optional<float > Val = extractMdFloatValue (StaticSamplerNode, 9 ))
319
+ Sampler.MinLOD = * Val;
320
320
else
321
321
return reportError (Ctx, " Invalid value for MinLOD" );
322
322
323
- if (std::optional<APFloat > Val = extractMdFloatValue (StaticSamplerNode, 10 ))
324
- Sampler.MaxLOD = Val-> convertToFloat () ;
323
+ if (std::optional<float > Val = extractMdFloatValue (StaticSamplerNode, 10 ))
324
+ Sampler.MaxLOD = * Val;
325
325
else
326
326
return reportError (Ctx, " Invalid value for MaxLOD" );
327
327
@@ -493,33 +493,29 @@ static bool verifyDescriptorRangeFlag(uint32_t Version, uint32_t Type,
493
493
}
494
494
495
495
static bool verifySamplerFilter (uint32_t Value) {
496
- dxbc::StaticSamplerFilter Filter = dxbc::StaticSamplerFilter (Value);
497
-
498
- dxbc::StaticSamplerFilter Mask = dxbc::StaticSamplerFilter::MIN_MAG_MIP_POINT;
499
-
500
- #define STATIC_SAMPLER_FILTER (Num, Val ) Mask |= dxbc::StaticSamplerFilter::Val;
496
+ switch (Value) {
497
+ #define STATIC_SAMPLER_FILTER (Num, Val ) \
498
+ case llvm::to_underlying (dxbc::StaticSamplerFilter::Val):
501
499
#include " llvm/BinaryFormat/DXContainerConstants.def"
502
-
503
- return popcount (llvm::to_underlying (Filter & Mask)) == 1 ;
500
+ return true ;
501
+ }
502
+ return false ;
504
503
}
505
504
506
505
// Values allowed here:
507
506
// https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_texture_address_mode#syntax
508
507
static bool verifyAddress (uint32_t Address) {
509
508
switch (Address) {
510
- case llvm::to_underlying (dxbc::TextureAddressMode::Border):
511
- case llvm::to_underlying (dxbc::TextureAddressMode::Clamp):
512
- case llvm::to_underlying (dxbc::TextureAddressMode::Mirror):
513
- case llvm::to_underlying (dxbc::TextureAddressMode::MirrorOnce):
514
- case llvm::to_underlying (dxbc::TextureAddressMode::Wrap):
509
+ #define TEXTURE_ADDRESS_MODE (Num, Val ) \
510
+ case llvm::to_underlying (dxbc::TextureAddressMode::Val):
511
+ #include " llvm/BinaryFormat/DXContainerConstants.def"
515
512
return true ;
516
513
}
517
-
518
514
return false ;
519
515
}
520
516
521
517
static bool verifyMipLODBias (float MipLODBias) {
522
- return MipLODBias >= -16 .f && MipLODBias <= 16 . f ;
518
+ return MipLODBias >= -16 .f && MipLODBias <= 15 . 99f ;
523
519
}
524
520
525
521
static bool verifyMaxAnisotropy (uint32_t MaxAnisotropy) {
@@ -528,26 +524,19 @@ static bool verifyMaxAnisotropy(uint32_t MaxAnisotropy) {
528
524
529
525
static bool verifyComparisonFunc (uint32_t ComparisonFunc) {
530
526
switch (ComparisonFunc) {
531
- case llvm::to_underlying (dxbc::SamplersComparisonFunction::Never):
532
- case llvm::to_underlying (dxbc::SamplersComparisonFunction::Less):
533
- case llvm::to_underlying (dxbc::SamplersComparisonFunction::Equal):
534
- case llvm::to_underlying (dxbc::SamplersComparisonFunction::LessEqual):
535
- case llvm::to_underlying (dxbc::SamplersComparisonFunction::Greater):
536
- case llvm::to_underlying (dxbc::SamplersComparisonFunction::NotEqual):
537
- case llvm::to_underlying (dxbc::SamplersComparisonFunction::GreaterEqual):
538
- case llvm::to_underlying (dxbc::SamplersComparisonFunction::Always):
527
+ #define COMPARISON_FUNCTION (Num, Val ) \
528
+ case llvm::to_underlying (dxbc::SamplersComparisonFunction::Val):
529
+ #include " llvm/BinaryFormat/DXContainerConstants.def"
539
530
return true ;
540
531
}
541
532
return false ;
542
533
}
543
534
544
535
static bool verifyBorderColor (uint32_t BorderColor) {
545
536
switch (BorderColor) {
546
- case llvm::to_underlying (dxbc::SamplersBorderColor::TransparentBlack):
547
- case llvm::to_underlying (dxbc::SamplersBorderColor::OpaqueBlack):
548
- case llvm::to_underlying (dxbc::SamplersBorderColor::OpaqueWhite):
549
- case llvm::to_underlying (dxbc::SamplersBorderColor::OpaqueBlackUint):
550
- case llvm::to_underlying (dxbc::SamplersBorderColor::OpaqueWhiteUint):
537
+ #define STATIC_BORDER_COLOR (Num, Val ) \
538
+ case llvm::to_underlying (dxbc::SamplersBorderColor::Val):
539
+ #include " llvm/BinaryFormat/DXContainerConstants.def"
551
540
return true ;
552
541
}
553
542
return false ;
0 commit comments