-
Notifications
You must be signed in to change notification settings - Fork 888
[SPIRV] Add -fspv-flatten-resource-array-bindings-only #8705
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
Open
Youssef Abusamra (l3rp)
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
l3rp:spv-array-flatten-binding-only
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+77
−2
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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
27 changes: 27 additions & 0 deletions
27
...clang/test/CodeGenSPIRV/vk.binding.cl.flatten-array-bindings-only.example1-optimized.hlsl
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,27 @@ | ||
| // RUN: %dxc -T ps_6_0 -E main -fspv-flatten-resource-array-bindings-only -O3 %s -spirv | FileCheck %s | ||
|
|
||
| // The array is NOT split into individual variables (unlike | ||
| // -fspv-flatten-resource-arrays): MyTextures/MySamplers stay as single | ||
| // array variables, each with a single Binding decoration, but the binding | ||
| // numbers reserved for them still account for the full array size. | ||
| // CHECK: OpDecorate %MyTextures Binding 0 | ||
| // CHECK: OpDecorate %AnotherTexture Binding 5 | ||
| // CHECK: OpDecorate %NextTexture Binding 6 | ||
| // CHECK: OpDecorate %MySamplers Binding 7 | ||
| // CHECK-NOT: MyTextures_0_ | ||
| // CHECK-NOT: MySamplers_0_ | ||
| Texture2D MyTextures[5] : register(t0); | ||
| Texture2D NextTexture; // This is suppose to be t6. | ||
|
|
||
| Texture2D AnotherTexture : register(t5); | ||
| SamplerState MySamplers[2]; | ||
|
|
||
| [unroll] | ||
| float4 main(float2 TexCoord : TexCoord) : SV_Target0 | ||
| { | ||
| float4 result = 0; | ||
| for (uint i = 0; i < 5; ++i) | ||
| result += MyTextures[i].Sample(MySamplers[i < 3 ? 0 : 1], TexCoord); | ||
| result += AnotherTexture.Sample(MySamplers[1], TexCoord); | ||
| result += NextTexture.Sample(MySamplers[1], TexCoord); | ||
| return result; | ||
| } | ||
23 changes: 23 additions & 0 deletions
23
tools/clang/test/CodeGenSPIRV/vk.binding.cl.flatten-array-bindings-only.example1.hlsl
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,23 @@ | ||
| // RUN: %dxc -T ps_6_0 -E main -fspv-flatten-resource-array-bindings-only -fcgl %s -spirv | FileCheck %s | ||
|
|
||
| // CHECK: OpDecorate %MyTextures Binding 0 | ||
| // CHECK: OpDecorate %AnotherTexture Binding 5 | ||
| // CHECK: OpDecorate %NextTexture Binding 6 | ||
| // CHECK: OpDecorate %MySamplers Binding 7 | ||
| Texture2D MyTextures[5] : register(t0); | ||
| Texture2D NextTexture; // This is suppose to be t6. | ||
|
|
||
| Texture2D AnotherTexture : register(t5); | ||
| SamplerState MySamplers[2]; | ||
|
|
||
| float4 main(float2 TexCoord : TexCoord) : SV_Target0 | ||
| { | ||
| float4 result = | ||
| MyTextures[0].Sample(MySamplers[0], TexCoord) + | ||
| MyTextures[1].Sample(MySamplers[0], TexCoord) + | ||
| MyTextures[2].Sample(MySamplers[0], TexCoord) + | ||
| MyTextures[3].Sample(MySamplers[1], TexCoord) + | ||
| MyTextures[4].Sample(MySamplers[1], TexCoord) + | ||
| AnotherTexture.Sample(MySamplers[1], TexCoord) + | ||
| NextTexture.Sample(MySamplers[1], TexCoord); | ||
| return result; | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate to bikeshed over naming, but I don't think what this does can be described as flattening even though it shares some behavior with the flag that does.
Perhaps something like
spv-dx-resource-array-binding? I'm open to other suggestions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-fspv-flatten-resource-arraysis for when non uniform resource accesses are unsupported AFAIK, anOpSwitchwith an array element per case is generated when a non compile time constant is used.I think
-fspv-dx-resource-array-bindingwould be less "obvious" though?