-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPIR-V] Add capability trimming pass (#5518)
This new optimization passes determines the required capabilities for a module, and strips unneeded capabilities. This means if some dead-code uses a capability, it won't be added as a requirement for the module anymore. This interacts with `[[vk::ext_capabilities]]` and [[vk::ext_extension]]` attributes, as the extension/capability they declare could be stripped if not required. Still markes as draft for now as there are inconsistencies with debug instruction I need to figure out: - if 2 DebugScope are generated, SPIRV-Tools squash them into 1. - seems like we started to generated the wrong ones, but test didn't saw the 2 conflicting scopes, only checked the first one.
- Loading branch information
Showing
13 changed files
with
107 additions
and
15 deletions.
There are no files selected for viewing
Submodule SPIRV-Tools
updated
15 files
+5 −1 | .github/workflows/autoroll.yml | |
+4 −4 | CONTRIBUTING.md | |
+3 −3 | DEPS | |
+1 −1 | docs/downloads.md | |
+2 −2 | docs/projects.md | |
+5 −0 | include/spirv-tools/libspirv.h | |
+10 −6 | source/assembly_grammar.cpp | |
+19 −45 | source/operand.cpp | |
+8 −3 | source/opt/decoration_manager.cpp | |
+4 −3 | source/opt/decoration_manager.h | |
+299 −101 | source/opt/trim_capabilities_pass.cpp | |
+48 −11 | source/opt/trim_capabilities_pass.h | |
+38 −2 | test/operand_capabilities_test.cpp | |
+694 −43 | test/opt/trim_capabilities_pass_test.cpp | |
+12 −8 | test/val/val_image_test.cpp |
This file contains 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 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 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 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 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
2 changes: 1 addition & 1 deletion
2
tools/clang/test/CodeGenSPIRV/empty-struct-interface.vs.hlsl2spv
This file contains 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 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 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 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
13 changes: 13 additions & 0 deletions
13
tools/clang/test/CodeGenSPIRV_Lit/capability.trimmed.o3.hlsl
This file contains 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,13 @@ | ||
// RUN: %dxc -T ps_6_0 -E main -O3 %s -spirv | FileCheck %s | ||
|
||
Texture1D <float4> t : register(t1); | ||
SamplerState gSampler : register(s2); | ||
|
||
// CHECK-NOT: OpCapability MinLod | ||
|
||
float4 main(uint clamp : A) : SV_Target { | ||
if (clamp < 0) { | ||
return t.Sample(gSampler, 0.5f, 2, float(clamp)); | ||
} | ||
return float4(0, 0, 0, 0); | ||
} |
12 changes: 12 additions & 0 deletions
12
tools/clang/test/CodeGenSPIRV_Lit/capability.untrimmed.fcgl.hlsl
This file contains 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,12 @@ | ||
// RUN: %dxc -T cs_6_0 -E main -fcgl %s -spirv | FileCheck %s | ||
|
||
// DXC generates by default all capabilities, and calls a specific pass | ||
// to trim unwanted capabilities. This is done to prevent code duplication | ||
// between the optimizer, and DXC. | ||
// -fcgl is used for debug purposed, and disable all passes, even | ||
// legalization. So if -fcgl is called, the capability should be present, | ||
// event if unused. | ||
|
||
// CHECK: OpCapability MinLod | ||
[numthreads(1, 1, 1)] | ||
void main() { } |
13 changes: 13 additions & 0 deletions
13
tools/clang/test/CodeGenSPIRV_Lit/capability.untrimmed.o0.hlsl
This file contains 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,13 @@ | ||
// RUN: %dxc -T ps_6_0 -E main -O0 %s -spirv | FileCheck %s | ||
|
||
Texture1D <float4> t : register(t1); | ||
SamplerState gSampler : register(s2); | ||
|
||
// CHECK: OpCapability MinLod | ||
|
||
float4 main(uint clamp : A) : SV_Target { | ||
if (clamp < 0) { | ||
return t.Sample(gSampler, 0.5f, 2, float(clamp)); | ||
} | ||
return float4(0, 0, 0, 0); | ||
} |