-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[DirectX] Validate registers are bound to root signature #146785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joaosaffran
merged 121 commits into
llvm:main
from
joaosaffran:validation/check-descriptors-are-bound
Aug 28, 2025
Merged
Changes from 103 commits
Commits
Show all changes
121 commits
Select commit
Hold shift + click to select a range
0e8828c
refactoring
2edd215
refactoring
242545e
clean up
3f8dec4
format
3b1ce3b
formating
f5720af
fix import issues
ea54904
formating
a49aa19
refactoring
d90676f
init refactoring
a04eb9f
adding validation
5994b8f
clean
e8b14bf
implementing
8f40e83
finish implementing && fix tests
28350b2
fix issue
4fd2e0b
sync parent
e25ee87
sync parent
881dd36
address comments
8779ee9
Merge branch 'refactoring/updating-return-root-sig-analysis' into val…
c16f15b
fix test
c7d5be7
format
cc5afae
address changes
571a0ef
fix tests
974d4bc
Merge branch 'refactoring/updating-return-root-sig-analysis' into val…
e0bc862
add preserved
b5a0b32
addressing comments
00a74af
Merge branch 'main' into validation/check-descriptors-are-bound
5ccb842
updating
5423aba
format
a7637a7
adding tests
da42c0c
clean up
edb015d
address comments
9f3888e
adding root constants
578a03b
clean
b4a0e16
moving code arround
ef14638
clean
662c3a8
addressing comments
260633c
address comments
d42f156
Merge branch 'main' into validation/check-descriptors-are-bound
9ee3a4b
Merge branch 'main' into validation/check-descriptors-are-bound
6db6224
update code
04658b8
cleanup
adf3feb
address comments from inbelic
c95ce68
refactoring
af6aa53
add tests
29eb893
cleanup
ed4c553
clean
28fb609
clean up
fc338b5
Merge branch 'validation/overlapping-ranges' into validation/check-de…
f5b5b3e
clean
03d571a
clean?
ef51048
format
21675e6
formating
403972d
addressing comments from bogner and inbelic
joaosaffran-zz 0f0435d
clean up
joaosaffran-zz e841a98
clean up
joaosaffran-zz ae6d67a
fix build
joaosaffran-zz 41f32bd
fix tests
joaosaffran-zz 47662f0
Merge branch 'validation/overlapping-ranges' into validation/check-de…
6da5fb0
format
6f3d019
Merge branch 'main' into validation/overlapping-ranges
971ad57
Merge branch 'main' into validation/overlapping-ranges
db73d71
update
3b04c2d
address comment from inbelic
1ddffc3
address comments 2
db0008e
addressing comments from inbelic
0c72dcf
addressing inbelic comments
b4e5fb4
adding test
4a655a5
addressing comments from bogner
cc94561
addressing comments
98f48d2
address comments
eb334b8
refactoring
06c0da4
addressing comments
d58606f
Merge branch 'main' into validation/overlapping-ranges
74980c8
fix test
d376abf
address comments
4abb40d
Merge branch 'validation/overlapping-ranges' into validation/check-de…
bb44eef
fix test
1cf2d1e
Merge branch 'main' into validation/check-descriptors-are-bound
373d871
clean up
d2750d7
format
6db8d93
refactoring to not create extra space
joaosaffran e3a65b6
remove copy of binding
joaosaffran e902add
making BindingRange const
joaosaffran 9a6d64c
doing it again for other isBound
joaosaffran 15b7592
adding DXILResourceTypeMap
joaosaffran 11b9fb2
updating error messages and tests
joaosaffran 0442b99
refactoring isBound to follow first suggestion
joaosaffran 82bdf82
adding limits tests
joaosaffran 9f18475
using find
joaosaffran 964d165
add siggested test
joaosaffran e5ca2d6
Merge branch 'main' into validation/check-descriptors-are-bound
joaosaffran 84f449b
fixing range bug
joaosaffran 4d0fbbe
format
joaosaffran 1ef79ad
refactor hlsl binding to support non free bindings
joaosaffran 485e9b6
clean up
joaosaffran 1945403
adding consecutive range fail test
joaosaffran acd966a
removing double public
joaosaffran 8d2a9d1
remove dangling public
joaosaffran 939b6aa
refactor to use bogner suggestions
joaosaffran 4f7856f
forgot to check clang
joaosaffran 2c8b999
clean up 1
joaosaffran f866fa9
clean up 2
joaosaffran 741960e
clean up 3?
joaosaffran b275160
adding space got readability
joaosaffran a6a0ab7
adding comment
joaosaffran df3f096
removing calculateBindingInfo
joaosaffran b9eee70
removing calculateBoundRegs
joaosaffran 3c2119f
removing regex from tests
joaosaffran 9541ba3
remove immutable pass from preserved
joaosaffran 1836e43
clean up
joaosaffran 6726f1d
clean up 2
joaosaffran 6254024
clean up 3
joaosaffran c87c1c0
clean up 4
joaosaffran 239bf83
clean up 5
joaosaffran ad3d595
clean up 6
joaosaffran 263ced2
clean up 7
joaosaffran c8ce514
formating 1
joaosaffran e2ddf4d
formating 2
joaosaffran 4f90c8f
changing function name and signature
joaosaffran 7a7c0bf
Merge branch 'main' into validation/check-descriptors-are-bound
joaosaffran 5443a62
updating tests
joaosaffran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joaosaffran marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
llvm/test/CodeGen/DirectX/rootsignature-validation-binding-limits-upperbound.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; RUN: opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s | ||
; This is a valid code, it checks the limits of a binding space | ||
; CHECK-NOT: error: .* | ||
bogner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
%__cblayout_CB = type <{ float }> | ||
|
||
@CB.str = private unnamed_addr constant [3 x i8] c"CB\00", align 1 | ||
|
||
define void @CSMain() "hlsl.shader"="compute" { | ||
entry: | ||
%CB = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 5, i32 0, i1 false, ptr nonnull @CB.str) | ||
ret void | ||
} | ||
|
||
!dx.rootsignatures = !{!0} | ||
|
||
!0 = !{ptr @CSMain, !1, i32 2} | ||
!1 = !{!2} | ||
!2 = !{!"DescriptorTable", i32 0, !3} | ||
!3 = !{!"CBV", i32 5, i32 0, i32 0, i32 0, i32 4} |
22 changes: 22 additions & 0 deletions
22
llvm/test/CodeGen/DirectX/rootsignature-validation-binding-limits.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
; RUN: opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s | ||
; This is a valid code, it checks the limits of a binding space | ||
|
||
; CHECK-NOT: error: .* | ||
bogner marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
%__cblayout_CB = type <{ float }> | ||
|
||
@CB.str = private unnamed_addr constant [3 x i8] c"CB\00", align 1 | ||
|
||
define void @CSMain() "hlsl.shader"="compute" { | ||
entry: | ||
%CB = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 0, i32 4294967294, i32 1, i32 0, i1 false, ptr nonnull @CB.str) | ||
%CB1 = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false, ptr nonnull @CB.str) | ||
ret void | ||
} | ||
|
||
!dx.rootsignatures = !{!0} | ||
|
||
!0 = !{ptr @CSMain, !1, i32 2} | ||
!1 = !{!2, !3} | ||
!2 = !{!"RootCBV", i32 0, i32 4294967294, i32 0, i32 4} | ||
!3 = !{!"RootCBV", i32 0, i32 0, i32 0, i32 4} |
18 changes: 18 additions & 0 deletions
18
llvm/test/CodeGen/DirectX/rootsignature-validation-fail-cbv-binding.ll
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also add a couple tests for when it doesn't fail validation. For instance the cases:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s | ||
; CHECK: error: CBV register 2 in space 666 does not have a binding in the Root Signature | ||
|
||
%__cblayout_CB = type <{ float }> | ||
|
||
@CB.str = private unnamed_addr constant [3 x i8] c"CB\00", align 1 | ||
|
||
define void @CSMain() "hlsl.shader"="compute" { | ||
entry: | ||
%CB = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 666, i32 2, i32 1, i32 0, i1 false, ptr nonnull @CB.str) | ||
ret void | ||
} | ||
|
||
!dx.rootsignatures = !{!0} | ||
|
||
!0 = !{ptr @CSMain, !1, i32 2} | ||
!1 = !{!2} | ||
!2 = !{!"RootConstants", i32 0, i32 2, i32 0, i32 4} |
19 changes: 19 additions & 0 deletions
19
llvm/test/CodeGen/DirectX/rootsignature-validation-fail-consecutive-ranges.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s | ||
; CHECK: CBV register 3 in space 0 does not have a binding in the Root Signature | ||
%__cblayout_CB = type <{ float }> | ||
|
||
@CB.str = private unnamed_addr constant [3 x i8] c"CB\00", align 1 | ||
|
||
define void @CSMain() "hlsl.shader"="compute" { | ||
entry: | ||
%CB = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 0, i32 3, i32 6, i32 0, i1 false, ptr nonnull @CB.str) | ||
ret void | ||
} | ||
|
||
!dx.rootsignatures = !{!0} | ||
|
||
!0 = !{ptr @CSMain, !1, i32 2} | ||
!1 = !{!2} | ||
!2 = !{!"DescriptorTable", i32 0, !3, !4} | ||
!3 = !{!"CBV", i32 5, i32 2, i32 0, i32 0, i32 4} | ||
!4 = !{!"CBV", i32 4, i32 7, i32 0, i32 10, i32 4} |
18 changes: 18 additions & 0 deletions
18
llvm/test/CodeGen/DirectX/rootsignature-validation-fail-sampler-binding.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s | ||
; CHECK: error: Sampler register 3 in space 2 does not have a binding in the Root Signature | ||
|
||
@Smp.str = private unnamed_addr constant [4 x i8] c"Smp\00", align 1 | ||
|
||
|
||
define void @CSMain() "hlsl.shader"="compute" { | ||
entry: | ||
%Sampler = call target("dx.Sampler", 0) @llvm.dx.resource.handlefrombinding(i32 2, i32 3, i32 1, i32 0, i1 false, ptr nonnull @Smp.str) | ||
ret void | ||
} | ||
|
||
!dx.rootsignatures = !{!0} | ||
|
||
!0 = !{ptr @CSMain, !1, i32 2} | ||
!1 = !{!2} | ||
!2 = !{!"DescriptorTable", i32 0, !3} | ||
!3 = !{!"Sampler", i32 1, i32 42, i32 0, i32 -1, i32 0} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.