-
Notifications
You must be signed in to change notification settings - Fork 18.4k
[DirectX] Add shader flags for heap resources #216461
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
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
04956d9
[DirectX] Add support for heap resources to `DXILResourceMap`.
hekota 46ded03
[DirectX] Add shader flags for heap resources
hekota a045cb5
Update size check in DXILShaderFlags
hekota 63816eb
add test to verify that heap resources do not appear in printed resou…
hekota 19f456a
code review feedback
hekota 2e1e167
code review feedback - update test comments
hekota eef596c
coder review feedback - switch ResourceBinding and HeapID to std::var…
hekota 078a20e
update include
hekota c8ed1b4
Remove bool argument from llvm.dx.resource.handlefromheap (per https:…
hekota 1117fa8
Merge branch 'users/hekota/pr216454-dyn-red-heap-index-id' of https:/…
hekota 2b64e78
Add heap resource handling for ResMayNotAlias, Max64UAV, and hasUAVsA…
hekota 1c6004a
Merge branch 'main' of https://github.com/llvm/llvm-project into dyn-…
hekota b6f6a49
clang-format
hekota 594992f
Merge branch 'main' of https://github.com/llvm/llvm-project into dyn-…
hekota 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
Some comments aren't visible on the classic Files Changed page.
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
42 changes: 42 additions & 0 deletions
42
llvm/test/CodeGen/DirectX/ShaderFlags/heap-resources-max64uavs.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,42 @@ | ||
| ; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s | ||
| ; RUN: llc %s -disable-dxil-remove-unused-resources --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC | ||
|
|
||
| ; This test verifies that the Max64UAVs flag is *not* set if there | ||
| ; are 9 or more heap UAVs, since a heap UAVs do not count. | ||
|
|
||
| target triple = "dxil-pc-shadermodel6.6-library" | ||
|
|
||
| ; CHECK: Combined Shader Flags for Module | ||
| ; CHECK-NEXT: Shader Flags Value: 0x40000000 | ||
|
|
||
| ; CHECK: Note: shader requires additional functionality: | ||
| ; CHECK-NOT: 64 UAV slots | ||
| ; CHECK: Resource descriptor heap indexing | ||
|
|
||
| ; CHECK: Function test : 0x40000000 | ||
| define void @test() "hlsl.export" { | ||
|
|
||
| %1 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefromheap(i32 0) | ||
| %2 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefromheap(i32 1) | ||
| %3 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefromheap(i32 2) | ||
| %4 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefromheap(i32 3) | ||
| %5 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefromheap(i32 4) | ||
| %6 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefromheap(i32 5) | ||
| %7 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefromheap(i32 6) | ||
| %8 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefromheap(i32 7) | ||
| %9 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefromheap(i32 8) | ||
|
|
||
| ret void | ||
| } | ||
|
|
||
| !dx.valver = !{!0} | ||
| !0 = !{i32 1, i32 8} | ||
|
|
||
| ; DXC: - Name: SFI0 | ||
| ; DXC-NEXT: Size: 8 | ||
| ; DXC-NEXT: Flags: | ||
| ; DXC: Max64UAVs: false | ||
| ; DXC: ResourceDescriptorHeapIndexing: true | ||
| ; DXC: SamplerDescriptorHeapIndexing: false | ||
| ; DXC: NextUnusedBit: false | ||
|
|
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,52 @@ | ||
| ; RUN: opt -S --passes="print-dx-shader-flags" -mtriple=dxil-pc-shadermodel6.6-library 2>&1 %s | FileCheck %s --check-prefixes=CHECK,CHECK-66 | ||
| ; RUN: opt -S --passes="print-dx-shader-flags" -mtriple=dxil-pc-shadermodel6.7-library 2>&1 %s | FileCheck %s --check-prefixes=CHECK,CHECK-67 | ||
| ; RUN: llc %s -disable-dxil-remove-unused-resources -mtriple=dxil-pc-shadermodel6.7-library --filetype=obj -o - | \ | ||
| ; RUN: obj2yaml | FileCheck %s --check-prefix=DXC | ||
|
|
||
| ; This test makes sure that the shader flag 'Resource descriptor heap indexing' | ||
| ; is set when the shader uses llvm.dx.resource.handlefromheap intrinsic to get | ||
| ; a resource from a resource descriptor heap, and that the shader flag | ||
| ; `Sampler descriptor heap indexing` is set when the shader uses the same | ||
| ; intrinsic to get a sampler from a sampler descriptor heap. | ||
|
|
||
| ; It also checks that the flag "Any UAV may not alias any other UAV" is set for | ||
| ; a function that uses a heap UAV resource, but only for shader model 6.7 and higher. | ||
|
|
||
| ; CHECK: Combined Shader Flags for Module | ||
| ; CHECK-66: Shader Flags Value: 0xc0000000 | ||
| ; CHECK-67: Shader Flags Value: 0x2c0000000 | ||
|
|
||
| ; CHECK: Note: shader requires additional functionality: | ||
| ; CHECK: Resource descriptor heap indexing | ||
| ; CHECK: Sampler descriptor heap indexing | ||
|
|
||
| ; CHECK: Note: extra DXIL module flags: | ||
| ; CHECK-67: Any UAV may not alias any other UAV | ||
| ; | ||
| ; CHECK-66: Function test_1 : 0x40000000 | ||
| ; CHECK-67: Function test_1 : 0x240000000 | ||
| define void @test_1() "hlsl.export" { | ||
| ; RWBuffer<float4> Buf = ResourceDescriptorHeap[3] | ||
| %typed = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0) | ||
| @llvm.dx.resource.handlefromheap.tdx.TypedBuffer_v4f32_1_0_0(i32 3) | ||
| ret void | ||
| } | ||
|
|
||
| ; CHECK: Function test_2 : 0x80000000 | ||
| define void @test_2() "hlsl.export" { | ||
| ; SamplerState Samp = SamplerDescriptorHeap[100]; | ||
| %samp = call target("dx.Sampler", 0) | ||
| @llvm.dx.resource.handlefromheap.tdx.Sampler_0(i32 100) | ||
| ret void | ||
| } | ||
|
|
||
| !dx.valver = !{!0} | ||
| !0 = !{i32 1, i32 8} | ||
|
|
||
| ; DXC: - Name: SFI0 | ||
| ; DXC-NEXT: Size: 8 | ||
| ; DXC-NEXT: Flags: | ||
| ; DXC: ResourceDescriptorHeapIndexing: true | ||
| ; DXC: SamplerDescriptorHeapIndexing: true | ||
| ; DXC: NextUnusedBit: false | ||
|
|
36 changes: 36 additions & 0 deletions
36
llvm/test/CodeGen/DirectX/ShaderFlags/uavs-at-every-stage-vs-heap.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,36 @@ | ||
| ; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s | ||
| ; TODO: Remove this comment and add 'RUN' to the line below once vertex shaders are supported by llc | ||
| ; llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC | ||
|
|
||
| ; This test ensures that a Vertex shader with a UAV resource from heap | ||
| ; does *not* set the module and shader feature flag UAVsAtEveryStage. | ||
|
|
||
| target triple = "dxil-pc-shadermodel6.5-vertex" | ||
|
|
||
| ; CHECK: Combined Shader Flags for Module | ||
| ; CHECK-NOT: Shader Flags Value: 0x400000000 | ||
|
|
||
| ; CHECK: Note: shader requires additional functionality: | ||
| ; CHECK-NOT: UAVs at every shader stage | ||
| ; CHECK: Resource descriptor heap indexing | ||
|
|
||
| ; CHECK: Function VSMain : 0x40000000 | ||
| define void @VSMain() { | ||
| ; RWBuffer<float> Buf : register(u0, space0) | ||
| %buf0 = call target("dx.TypedBuffer", float, 1, 0, 1) | ||
| @llvm.dx.resource.handlefromheap.tdx.TypedBuffer_f32_1_0t(i32 7) | ||
| ret void | ||
| } | ||
|
|
||
| !dx.valver = !{!1} | ||
| !1 = !{i32 1, i32 8} | ||
|
|
||
| !llvm.module.flags = !{!0} | ||
| !0 = !{i32 1, !"dx.resmayalias", i32 1} | ||
|
|
||
| ; DXC: - Name: SFI0 | ||
| ; DXC-NEXT: Size: 8 | ||
| ; DXC-NEXT: Flags: | ||
| ; DXC: UAVsAtEveryStage: false | ||
| ; DXC: NextUnusedBit: false | ||
| ; DXC: ... |
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.