Skip to content

Commit 2507ea3

Browse files
author
joaosaffran
committed
address comment
1 parent c31af32 commit 2507ea3

16 files changed

+27
-83
lines changed

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ inline bool isValidShaderVisibility(uint32_t V) {
218218
#define STATIC_SAMPLER_FILTER(Val, Enum) Enum = Val,
219219
enum class StaticSamplerFilter : uint32_t {
220220
#include "DXContainerConstants.def"
221+
222+
LLVM_MARK_AS_BITMASK_ENUM(MAXIMUM_ANISOTROPIC)
221223
};
222224

223225
#define TEXTURE_ADDRESS_MODE(Val, Enum) Enum = Val,

llvm/lib/Target/DirectX/DXILRootSignature.cpp

Lines changed: 9 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -497,73 +497,15 @@ static bool verifyDescriptorRangeFlag(uint32_t Version, uint32_t Type,
497497
return (Flags & ~Mask) == FlagT::NONE;
498498
}
499499

500-
static bool verifySamplerFilter(uint32_t Filter) {
501-
switch (Filter) {
502-
case llvm::to_underlying(dxbc::StaticSamplerFilter::MIN_MAG_MIP_POINT):
503-
case llvm::to_underlying(dxbc::StaticSamplerFilter::MIN_MAG_POINT_MIP_LINEAR):
504-
case llvm::to_underlying(
505-
dxbc::StaticSamplerFilter::MIN_POINT_MAG_LINEAR_MIP_POINT):
506-
case llvm::to_underlying(dxbc::StaticSamplerFilter::MIN_POINT_MAG_MIP_LINEAR):
507-
case llvm::to_underlying(dxbc::StaticSamplerFilter::MIN_LINEAR_MAG_MIP_POINT):
508-
case llvm::to_underlying(
509-
dxbc::StaticSamplerFilter::MIN_LINEAR_MAG_POINT_MIP_LINEAR):
510-
case llvm::to_underlying(dxbc::StaticSamplerFilter::MIN_MAG_LINEAR_MIP_POINT):
511-
case llvm::to_underlying(dxbc::StaticSamplerFilter::MIN_MAG_MIP_LINEAR):
512-
case llvm::to_underlying(dxbc::StaticSamplerFilter::ANISOTROPIC):
513-
case llvm::to_underlying(
514-
dxbc::StaticSamplerFilter::COMPARISON_MIN_MAG_MIP_POINT):
515-
case llvm::to_underlying(
516-
dxbc::StaticSamplerFilter::COMPARISON_MIN_MAG_POINT_MIP_LINEAR):
517-
case llvm::to_underlying(
518-
dxbc::StaticSamplerFilter::COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT):
519-
case llvm::to_underlying(
520-
dxbc::StaticSamplerFilter::COMPARISON_MIN_POINT_MAG_MIP_LINEAR):
521-
case llvm::to_underlying(
522-
dxbc::StaticSamplerFilter::COMPARISON_MIN_LINEAR_MAG_MIP_POINT):
523-
case llvm::to_underlying(
524-
dxbc::StaticSamplerFilter::COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR):
525-
case llvm::to_underlying(
526-
dxbc::StaticSamplerFilter::COMPARISON_MIN_MAG_LINEAR_MIP_POINT):
527-
case llvm::to_underlying(
528-
dxbc::StaticSamplerFilter::COMPARISON_MIN_MAG_MIP_LINEAR):
529-
case llvm::to_underlying(dxbc::StaticSamplerFilter::COMPARISON_ANISOTROPIC):
530-
case llvm::to_underlying(
531-
dxbc::StaticSamplerFilter::MINIMUM_MIN_MAG_MIP_POINT):
532-
case llvm::to_underlying(
533-
dxbc::StaticSamplerFilter::MINIMUM_MIN_MAG_POINT_MIP_LINEAR):
534-
case llvm::to_underlying(
535-
dxbc::StaticSamplerFilter::MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT):
536-
case llvm::to_underlying(
537-
dxbc::StaticSamplerFilter::MINIMUM_MIN_POINT_MAG_MIP_LINEAR):
538-
case llvm::to_underlying(
539-
dxbc::StaticSamplerFilter::MINIMUM_MIN_LINEAR_MAG_MIP_POINT):
540-
case llvm::to_underlying(
541-
dxbc::StaticSamplerFilter::MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR):
542-
case llvm::to_underlying(
543-
dxbc::StaticSamplerFilter::MINIMUM_MIN_MAG_LINEAR_MIP_POINT):
544-
case llvm::to_underlying(
545-
dxbc::StaticSamplerFilter::MINIMUM_MIN_MAG_MIP_LINEAR):
546-
case llvm::to_underlying(dxbc::StaticSamplerFilter::MINIMUM_ANISOTROPIC):
547-
case llvm::to_underlying(
548-
dxbc::StaticSamplerFilter::MAXIMUM_MIN_MAG_MIP_POINT):
549-
case llvm::to_underlying(
550-
dxbc::StaticSamplerFilter::MAXIMUM_MIN_MAG_POINT_MIP_LINEAR):
551-
case llvm::to_underlying(
552-
dxbc::StaticSamplerFilter::MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT):
553-
case llvm::to_underlying(
554-
dxbc::StaticSamplerFilter::MAXIMUM_MIN_POINT_MAG_MIP_LINEAR):
555-
case llvm::to_underlying(
556-
dxbc::StaticSamplerFilter::MAXIMUM_MIN_LINEAR_MAG_MIP_POINT):
557-
case llvm::to_underlying(
558-
dxbc::StaticSamplerFilter::MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR):
559-
case llvm::to_underlying(
560-
dxbc::StaticSamplerFilter::MAXIMUM_MIN_MAG_LINEAR_MIP_POINT):
561-
case llvm::to_underlying(
562-
dxbc::StaticSamplerFilter::MAXIMUM_MIN_MAG_MIP_LINEAR):
563-
case llvm::to_underlying(dxbc::StaticSamplerFilter::MAXIMUM_ANISOTROPIC):
564-
return true;
565-
}
566-
return false;
500+
static bool verifySamplerFilter(uint32_t Value) {
501+
dxbc::StaticSamplerFilter Filter = dxbc::StaticSamplerFilter(Value);
502+
503+
dxbc::StaticSamplerFilter Mask = dxbc::StaticSamplerFilter::MIN_MAG_MIP_POINT;
504+
505+
#define STATIC_SAMPLER_FILTER(Num, Val) Mask |= dxbc::StaticSamplerFilter::Val;
506+
#include "llvm/BinaryFormat/DXContainerConstants.def"
507+
508+
return popcount(llvm::to_underlying(Filter & Mask)) == 1;
567509
}
568510

569511
// Values allowed here:

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressU.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1414

1515

1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
17-
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
1919
!5 = !{ !"StaticSampler", i32 4, i32 666, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressV.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1414

1515

1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
17-
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
1919
!5 = !{ !"StaticSampler", i32 4, i32 2, i32 666, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressW.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1414

1515

1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
17-
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
1919
!5 = !{ !"StaticSampler", i32 4, i32 2, i32 3, i32 666, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-BorderColor.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1414

1515

1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
17-
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
1919
!5 = !{ !"StaticSampler", i32 4, i32 2, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 666, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-ComparisonFunc.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1414

1515

1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
17-
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
1919
!5 = !{ !"StaticSampler", i32 4, i32 2, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 666, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-Filter.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
target triple = "dxil-unknown-shadermodel6.0-compute"
55

6-
; CHECK: error: Invalid value for Filter: 666
6+
; CHECK: error: Invalid value for Filter: 45
77
; CHECK-NOT: Root Signature Definitions
88

99
define void @main() #0 {
@@ -14,6 +14,6 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1414

1515

1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
17-
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
19-
!5 = !{ !"StaticSampler", i32 666, i32 2, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }
19+
!5 = !{ !"StaticSampler", i32 45, i32 2, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MaxAnisotropy.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1414

1515

1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
17-
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
1919
!5 = !{ !"StaticSampler", i32 4, i32 2, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 666, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-MaxLod.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1414

1515

1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
17-
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
1919
!5 = !{ !"StaticSampler", i32 4, i32 2, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 0x7FF8000000000000, i32 42, i32 0, i32 0 }

0 commit comments

Comments
 (0)