Skip to content

Commit 81915ad

Browse files
author
joaosaffran
committed
addressing comments
1 parent 58e1789 commit 81915ad

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

llvm/lib/Target/DirectX/DXILRootSignature.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ static bool parseRootDescriptors(LLVMContext *Ctx,
118118
MDNode *RootDescriptorNode) {
119119

120120
if (RootDescriptorNode->getNumOperands() != 5)
121-
return reportError(Ctx, "Invalid format for RootConstants Element");
121+
return reportError(Ctx, "Invalid format for Root Descriptor Element");
122122

123123
std::optional<StringRef> ElementText =
124124
extractMdStringValue(RootDescriptorNode, 0);
125-
assert(!ElementText->empty());
125+
126+
if (!ElementText.has_value())
127+
return reportError(Ctx, "Root Descriptor, first element is not a string.");
126128

127129
dxbc::RootParameterHeader Header;
128130
Header.ParameterType =
@@ -273,9 +275,9 @@ static bool validate(LLVMContext *Ctx, const mcdxbc::RootSignatureDesc &RSD) {
273275
if (!verifyRegisterSpace(Descriptor->RegisterSpace))
274276
return reportValueError(Ctx, "RegisterSpace",
275277
Descriptor->RegisterSpace);
276-
277-
if (!verifyDescriptorFlag(Descriptor->Flags))
278-
return reportValueError(Ctx, "DescriptorFlag", Descriptor->Flags);
278+
if (RSD.Version > 1)
279+
if (!verifyDescriptorFlag(Descriptor->Flags))
280+
return reportValueError(Ctx, "DescriptorFlag", Descriptor->Flags);
279281
}
280282
}
281283

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters.ll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,25 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1212

1313
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
1414
!2 = !{ ptr @main, !3 } ; function, root signature
15-
!3 = !{ !4, !5 } ; list of root signature elements
15+
!3 = !{ !4, !5, !6 } ; list of root signature elements
1616
!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
1717
!5 = !{ !"RootConstants", i32 0, i32 1, i32 2, i32 3 }
18+
!6 = !{ !"RootSRV", i32 1, i32 4, i32 5, i32 6 }
1819

1920
;CHECK-LABEL: Definition for 'main':
2021
;CHECK-NEXT: Flags: 0x000001
2122
;CHECK-NEXT: Version: 2
2223
;CHECK-NEXT: RootParametersOffset: 24
23-
;CHECK-NEXT: NumParameters: 1
24+
;CHECK-NEXT: NumParameters: 2
2425
;CHECK-NEXT: - Parameter Type: 1
2526
;CHECK-NEXT: Shader Visibility: 0
2627
;CHECK-NEXT: Register Space: 2
2728
;CHECK-NEXT: Shader Register: 1
2829
;CHECK-NEXT: Num 32 Bit Values: 3
30+
;CHECK-NEXT: - Parameter Type: 3
31+
;CHECK-NEXT: Shader Visibility: 1
32+
;CHECK-NEXT: Register Space: 5
33+
;CHECK-NEXT: Shader Register: 4
34+
;CHECK-NEXT: Flags: 6
2935
;CHECK-NEXT: NumStaticSamplers: 0
3036
;CHECK-NEXT: StaticSamplersOffset: 0

0 commit comments

Comments
 (0)