-
Notifications
You must be signed in to change notification settings - Fork 25
[VULKAN] Add support for specialization constants #499
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
7 commits
Select commit
Hold shift + click to select a range
754ca1f
[VULKAN] Add support for specialization constants
s-perron daae43b
Add error for invalid strings
s-perron 1d12749
Add test for multiple spec constants in the HLSL.
s-perron ed1f8ed
Add error if the same spec id is defined twice.
s-perron 3809f85
Merge branch 'main' into spec_const
s-perron 880ae6a
XFAIL tests with short and double.
s-perron de3c3cd
Change error message.
s-perron 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
39 changes: 39 additions & 0 deletions
39
test/Feature/SpecializationConstant/duplicate_spec_id.test
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,39 @@ | ||
| #--- duplicate_spec_id.hlsl | ||
| [[vk::constant_id(0)]] | ||
| const int spec_int_A = 0; | ||
| [[vk::constant_id(0)]] | ||
| const int spec_int_B = 0; | ||
|
|
||
| RWStructuredBuffer<int> Out : register(u0, space0); | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main(uint GI : SV_GroupIndex) { | ||
| Out[0] = spec_int_A; | ||
| Out[1] = spec_int_B; | ||
| } | ||
| #--- duplicate_spec_id.yaml | ||
| --- | ||
| Shaders: | ||
| - Stage: Compute | ||
| Entry: main | ||
| DispatchSize: [1, 1, 1] | ||
| SpecializationConstants: | ||
| - { ConstantID: 0, Value: 123, Type: Int32 } | ||
| Buffers: | ||
| - { Name: Out, Format: Int32, Stride: 4, FillSize: 8 } | ||
| DescriptorSets: | ||
| - Resources: | ||
| - Name: Out | ||
| Kind: RWStructuredBuffer | ||
| DirectXBinding: { Register: 0, Space: 0 } | ||
| VulkanBinding: { Binding: 0 } | ||
| ... | ||
| #--- end | ||
|
|
||
| # REQUIRES: Vulkan | ||
|
|
||
| # RUN: split-file %s %t | ||
| # RUN: %dxc_target -T cs_6_2 -Fo %t.o %t/duplicate_spec_id.hlsl | ||
| # RUN: %offloader %t/duplicate_spec_id.yaml %t.o | FileCheck %s | ||
|
|
||
| # CHECK: Data: [ 123, 123 ] |
37 changes: 37 additions & 0 deletions
37
test/Feature/SpecializationConstant/duplicate_spec_id_in_config.test
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,37 @@ | ||
| #--- duplicate_spec_id_in_config.hlsl | ||
| [[vk::constant_id(0)]] | ||
| const int spec_int = 0; | ||
|
|
||
| RWStructuredBuffer<int> Out : register(u0, space0); | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main(uint GI : SV_GroupIndex) { | ||
| Out[GI] = spec_int; | ||
| } | ||
| #--- duplicate_spec_id_in_config.yaml | ||
| --- | ||
| Shaders: | ||
| - Stage: Compute | ||
| Entry: main | ||
| DispatchSize: [1, 1, 1] | ||
| SpecializationConstants: | ||
| - { ConstantID: 0, Value: 123, Type: Int32 } | ||
| - { ConstantID: 0, Value: 456, Type: Int32 } | ||
| Buffers: | ||
| - { Name: Out, Format: Int32, Stride: 4, FillSize: 4 } | ||
| DescriptorSets: | ||
| - Resources: | ||
| - Name: Out | ||
| Kind: RWStructuredBuffer | ||
| DirectXBinding: { Register: 0, Space: 0 } | ||
| VulkanBinding: { Binding: 0 } | ||
| ... | ||
| #--- end | ||
|
|
||
| # REQUIRES: Vulkan | ||
|
|
||
| # RUN: split-file %s %t | ||
| # RUN: %dxc_target -T cs_6_2 -Fo %t.o %t/duplicate_spec_id_in_config.hlsl | ||
| # RUN: not %offloader %t/duplicate_spec_id_in_config.yaml %t.o 2>&1 | FileCheck %s | ||
|
|
||
| # CHECK: gpu-exec: error: Test configuration contains multiple entries for specialization constant ID 0. |
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,35 @@ | ||
| #--- invalid_bool.hlsl | ||
| [[vk::constant_id(0)]] | ||
| const bool spec_bool = false; | ||
| RWStructuredBuffer<uint> OutBool : register(u0, space0); | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main(uint GI : SV_GroupIndex) { | ||
| OutBool[GI] = (uint)spec_bool; | ||
| } | ||
| #--- invalid_bool.yaml | ||
| --- | ||
| Shaders: | ||
| - Stage: Compute | ||
| Entry: main | ||
| DispatchSize: [1, 1, 1] | ||
| SpecializationConstants: | ||
| - { ConstantID: 0, Value: "not a number", Type: Bool } | ||
| Buffers: | ||
| - { Name: OutBool, Format: Int32, Stride: 4, FillSize: 4 } | ||
| DescriptorSets: | ||
| - Resources: | ||
| - Name: OutBool | ||
| Kind: RWStructuredBuffer | ||
| DirectXBinding: { Register: 0, Space: 0 } | ||
| VulkanBinding: { Binding: 0 } | ||
| ... | ||
| #--- end | ||
|
|
||
| # REQUIRES: Vulkan | ||
|
|
||
| # RUN: split-file %s %t | ||
| # RUN: %dxc_target -T cs_6_2 -Fo %t.o %t/invalid_bool.hlsl | ||
| # RUN: not %offloader %t/invalid_bool.yaml %t.o 2>&1 | FileCheck %s | ||
|
|
||
| # CHECK: Invalid bool value for specialization constant 'not a number' |
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.