Skip to content

Commit bb1a61f

Browse files
author
joaosaffran
committed
add tests
1 parent 3e6b07e commit bb1a61f

File tree

5 files changed

+111
-1
lines changed

5 files changed

+111
-1
lines changed

llvm/lib/Target/DirectX/DXILRootSignature.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ static bool parseDescriptorTable(LLVMContext *Ctx,
236236
return reportError(Ctx, "Invalid value for ShaderVisibility");
237237

238238
mcdxbc::DescriptorTable Table;
239+
Header.ParameterType =
240+
llvm::to_underlying(dxbc::RootParameterType::DescriptorTable);
239241

240242
for (unsigned int I = 2; I < DescriptorTableNode->getNumOperands(); I++) {
241243
MDNode *Element = dyn_cast<MDNode>(DescriptorTableNode->getOperand(I));
@@ -312,7 +314,7 @@ static bool verifyRegisterValue(uint32_t RegisterValue) {
312314
}
313315

314316
static bool verifyRegisterSpace(uint32_t RegisterSpace) {
315-
return !(RegisterSpace >= 0xFFFFFFF0 && RegisterSpace <= 0xFFFFFFFF);
317+
return !(RegisterSpace >= 0xFFFFFFF0 && RegisterSpace < 0xFFFFFFFF);
316318
}
317319

318320
static bool verifyDescriptorFlag(uint32_t Flags) { return (Flags & ~0xE) == 0; }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: not opt -passes='print<dxil-root-signature>' %s -S -o - 2>&1 | FileCheck %s
2+
3+
target triple = "dxil-unknown-shadermodel6.0-compute"
4+
5+
; CHECK: error: Invalid value for DescriptorFlag: 22
6+
; CHECK-NOT: Root Signature Definitions
7+
8+
define void @main() #0 {
9+
entry:
10+
ret void
11+
}
12+
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
13+
14+
15+
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
16+
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!3 = !{ !5 } ; list of root signature elements
18+
!5 = !{ !"DescriptorTable", i32 0, !6, !7 }
19+
!6 = !{ !"SRV", i32 0, i32 0, i32 -1, i32 -1, i32 22 }
20+
!7 = !{ !"UAV", i32 5, i32 1, i32 10, i32 5, i32 2 }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: not opt -passes='print<dxil-root-signature>' %s -S -o - 2>&1 | FileCheck %s
2+
3+
target triple = "dxil-unknown-shadermodel6.0-compute"
4+
5+
; CHECK: error: Invalid value for RangeType: 4
6+
; CHECK-NOT: Root Signature Definitions
7+
8+
define void @main() #0 {
9+
entry:
10+
ret void
11+
}
12+
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
13+
14+
15+
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
16+
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!3 = !{ !5 } ; list of root signature elements
18+
!5 = !{ !"DescriptorTable", i32 0, !6, !7 }
19+
!6 = !{ !"Invalid", i32 0, i32 0, i32 -1, i32 -1, i32 4 }
20+
!7 = !{ !"UAV", i32 5, i32 1, i32 10, i32 5, i32 2 }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: not opt -passes='print<dxil-root-signature>' %s -S -o - 2>&1 | FileCheck %s
2+
3+
target triple = "dxil-unknown-shadermodel6.0-compute"
4+
5+
; CHECK: error: Invalid value for RegisterSpace: 4294967280
6+
; CHECK-NOT: Root Signature Definitions
7+
8+
define void @main() #0 {
9+
entry:
10+
ret void
11+
}
12+
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
13+
14+
15+
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
16+
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!3 = !{ !5 } ; list of root signature elements
18+
!5 = !{ !"DescriptorTable", i32 0, !6, !7 }
19+
!6 = !{ !"SRV", i32 0, i32 0, i32 10, i32 -1, i32 4 }
20+
!7 = !{ !"UAV", i32 5, i32 1, i32 4294967280, i32 5, i32 2 }
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; RUN: opt %s -dxil-embed -dxil-globals -S -o - | FileCheck %s
2+
; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
3+
4+
target triple = "dxil-unknown-shadermodel6.0-compute"
5+
6+
; CHECK: @dx.rts0 = private constant [92 x i8] c"{{.*}}", section "RTS0", align 4
7+
8+
define void @main() #0 {
9+
entry:
10+
ret void
11+
}
12+
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
13+
14+
15+
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
16+
!2 = !{ ptr @main, !3 } ; function, root signature
17+
!3 = !{ !5 } ; list of root signature elements
18+
!5 = !{ !"DescriptorTable", i32 0, !6, !7 }
19+
!6 = !{ !"SRV", i32 0, i32 0, i32 -1, i32 -1, i32 4 }
20+
!7 = !{ !"UAV", i32 5, i32 1, i32 10, i32 5, i32 2 }
21+
22+
; DXC: - Name: RTS0
23+
; DXC-NEXT: Size: 92
24+
; DXC-NEXT: RootSignature:
25+
; DXC-NEXT: Version: 2
26+
; DXC-NEXT: NumRootParameters: 1
27+
; DXC-NEXT: RootParametersOffset: 24
28+
; DXC-NEXT: NumStaticSamplers: 0
29+
; DXC-NEXT: StaticSamplersOffset: 0
30+
; DXC-NEXT: Parameters:
31+
; DXC-NEXT: - ParameterType: 0
32+
; DXC-NEXT: ShaderVisibility: 0
33+
; DXC-NEXT: Table:
34+
; DXC-NEXT: NumRanges: 2
35+
; DXC-NEXT: RangesOffset: 44
36+
; DXC-NEXT: Ranges:
37+
; DXC-NEXT: - RangeType: 0
38+
; DXC-NEXT: NumDescriptors: 0
39+
; DXC-NEXT: BaseShaderRegister: 0
40+
; DXC-NEXT: RegisterSpace: 4294967295
41+
; DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
42+
; DXC-NEXT: DATA_VOLATILE: true
43+
; DXC-NEXT: - RangeType: 1
44+
; DXC-NEXT: NumDescriptors: 5
45+
; DXC-NEXT: BaseShaderRegister: 1
46+
; DXC-NEXT: RegisterSpace: 10
47+
; DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
48+
; DXC-NEXT: DESCRIPTORS_VOLATILE: true

0 commit comments

Comments
 (0)