Skip to content

Commit 1fefbc4

Browse files
authored
Fix a PIX pass's attempt to set the validator version (#6707)
This pass was attempting to compare different things. The return values of GetDxilVersion are not shader models, but... dxil version. Since the code is trying to upgrade the validator version, I changed this to GetValidatorVersion, to pair with SetValidatorVersion. The previous code was breaking the nvidia driver on workgraphs.
1 parent 49d1ae9 commit 1fefbc4

3 files changed

Lines changed: 134 additions & 2 deletions

File tree

lib/DxilPIXPasses/DxilAnnotateWithVirtualRegister.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ bool DxilAnnotateWithVirtualRegister::runOnModule(llvm::Module &M) {
123123
}
124124
unsigned int Major = 0;
125125
unsigned int Minor = 0;
126-
m_DM->GetDxilVersion(Major, Minor);
127-
if (Major < 6 || (Major == 6 && Minor <= 4)) {
126+
m_DM->GetValidatorVersion(Major, Minor);
127+
if (hlsl::DXIL::CompareVersions(Major, Minor, 1, 4) < 0) {
128128
m_DM->SetValidatorVersion(1, 4);
129129
}
130130

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
; This test tests that a shader with current dxil validator version does not downgrade to 1.4.
2+
; (The annotate-with-virtual-register pass was erroneously doing just this)
3+
4+
; RUN: %dxopt %s -dxil-annotate-with-virtual-regs -hlsl-dxilemit -S | FileCheck %s
5+
6+
; CHECK: !dx.valver = !{![[VALVER:.*]]}
7+
; CHECK-NOT: ![[VALVER]] = !{i32 1, i32 4}
8+
9+
10+
; GENERATED FROM:
11+
; dxc -Emain -Tcs_6_1
12+
13+
14+
; void main()
15+
; {
16+
; }
17+
18+
19+
20+
;
21+
; Input signature:
22+
;
23+
; Name Index Mask Register SysValue Format Used
24+
; -------------------- ----- ------ -------- -------- ------- ------
25+
; no parameters
26+
;
27+
; Output signature:
28+
;
29+
; Name Index Mask Register SysValue Format Used
30+
; -------------------- ----- ------ -------- -------- ------- ------
31+
; no parameters
32+
; shader hash: bcdf90f13d29df9ebdc77539089a75a6
33+
;
34+
; Pipeline Runtime Information:
35+
;
36+
; Compute Shader
37+
; NumThreads=(1,1,1)
38+
;
39+
;
40+
; Buffer Definitions:
41+
;
42+
;
43+
; Resource Bindings:
44+
;
45+
; Name Type Format Dim ID HLSL Bind Count
46+
; ------------------------------ ---------- ------- ----------- ------- -------------- ------
47+
;
48+
target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64"
49+
target triple = "dxil-ms-dx"
50+
51+
define void @main() {
52+
ret void
53+
}
54+
55+
!llvm.ident = !{!0}
56+
!dx.version = !{!1}
57+
!dx.valver = !{!2}
58+
!dx.shaderModel = !{!3}
59+
!dx.entryPoints = !{!4}
60+
61+
!0 = !{!"dxc(private) 1.8.0.4583 (PIX_MemberFunctions, 2f4a01af1-dirty)"}
62+
!1 = !{i32 1, i32 1}
63+
!2 = !{i32 1, i32 8}
64+
!3 = !{!"cs", i32 6, i32 1}
65+
!4 = !{void ()* @main, !"main", null, null, !5}
66+
!5 = !{i32 4, !6}
67+
!6 = !{i32 1, i32 1, i32 1}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
; This test tests that a shader with dxil validator version of 1.3 gets upgraded to 1.4 after the annotate with virtual regs pass
2+
3+
; RUN: %dxopt %s -dxil-annotate-with-virtual-regs -hlsl-dxilemit -S | FileCheck %s
4+
5+
; CHECK: !dx.valver = !{![[VALVER:.*]]}
6+
; CHECK: ![[VALVER]] = !{i32 1, i32 4}
7+
8+
9+
; GENERATED FROM:
10+
; dxc -Emain -Tcs_6_1
11+
; void main()
12+
; {
13+
; }
14+
; AND THEN MANUALLY EDITNG valver to 1.3.
15+
16+
17+
18+
;
19+
; Input signature:
20+
;
21+
; Name Index Mask Register SysValue Format Used
22+
; -------------------- ----- ------ -------- -------- ------- ------
23+
; no parameters
24+
;
25+
; Output signature:
26+
;
27+
; Name Index Mask Register SysValue Format Used
28+
; -------------------- ----- ------ -------- -------- ------- ------
29+
; no parameters
30+
; shader hash: bcdf90f13d29df9ebdc77539089a75a6
31+
;
32+
; Pipeline Runtime Information:
33+
;
34+
; Compute Shader
35+
; NumThreads=(1,1,1)
36+
;
37+
;
38+
; Buffer Definitions:
39+
;
40+
;
41+
; Resource Bindings:
42+
;
43+
; Name Type Format Dim ID HLSL Bind Count
44+
; ------------------------------ ---------- ------- ----------- ------- -------------- ------
45+
;
46+
target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64"
47+
target triple = "dxil-ms-dx"
48+
49+
define void @main() {
50+
ret void
51+
}
52+
53+
!llvm.ident = !{!0}
54+
!dx.version = !{!1}
55+
!dx.valver = !{!2}
56+
!dx.shaderModel = !{!3}
57+
!dx.entryPoints = !{!4}
58+
59+
!0 = !{!"dxc(private) 1.8.0.4583 (PIX_MemberFunctions, 2f4a01af1-dirty)"}
60+
!1 = !{i32 1, i32 1}
61+
!2 = !{i32 1, i32 3}
62+
!3 = !{!"cs", i32 6, i32 1}
63+
!4 = !{void ()* @main, !"main", null, null, !5}
64+
!5 = !{i32 4, !6}
65+
!6 = !{i32 1, i32 1, i32 1}

0 commit comments

Comments
 (0)