-
Notifications
You must be signed in to change notification settings - Fork 900
[SPIRV] Use scalar rules for BDA alignment #8576
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
Chris B (llvm-beanz)
wants to merge
5
commits into
microsoft:main
Choose a base branch
from
llvm-beanz:8572
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.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
52590ff
[SPIRV] Use scalar rules for BDA alignment
llvm-beanz b380271
clang-format
llvm-beanz 3e064ef
Update release notes
llvm-beanz 079c985
Merge remote-tracking branch 'origin/main' into 8572
llvm-beanz b5a8aed
Put the release note in the right place
llvm-beanz 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
154 changes: 154 additions & 0 deletions
154
tools/clang/test/CodeGenSPIRV/intrinsics.vkrawbufferload.64bit-align.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,154 @@ | ||
| // RUN: %dxc -T cs_6_2 -E main -enable-16bit-types -fcgl %s -spirv | FileCheck %s | ||
|
|
||
| // Test that vk::RawBufferLoad/Store with 64-bit types uses alignment 8 | ||
| // when no explicit alignment is specified. | ||
|
|
||
| struct StructWith64BitMember { | ||
| uint64_t member; | ||
| }; | ||
|
|
||
| struct StructWithDoubleMember { | ||
| double member; | ||
| }; | ||
|
|
||
| // Mixes of 16-bit, 32-bit and 64-bit scalar members. The required alignment is | ||
| // the largest scalar alignment within the structure. | ||
| struct StructWithMixedScalars { | ||
| uint16_t a; | ||
| uint b; | ||
| uint64_t c; | ||
| }; | ||
|
|
||
| // A 16-bit/32-bit mix without any 64-bit member: the largest scalar alignment | ||
| // is 4, so alignment 4 is used. | ||
| struct StructWith16And32BitScalars { | ||
| uint16_t a; | ||
| float b; | ||
| }; | ||
|
|
||
| // A structure with only 16-bit members. The largest scalar alignment is 2, so | ||
| // alignment 2 is used: nothing in the Vulkan spec requires a larger minimum. | ||
| struct StructWithOnly16BitScalars { | ||
| uint16_t a; | ||
| half b; | ||
| }; | ||
|
|
||
| // A structure containing vectors of 16-bit, 32-bit and 64-bit elements. The | ||
| // 64-bit vector forces alignment 8. | ||
| struct StructWithMixedVectors { | ||
| half2 a; | ||
| float3 b; | ||
| double2 c; | ||
| }; | ||
|
|
||
| // A structure containing matrices. The 64-bit matrix forces alignment 8. | ||
| struct StructWithMixedMatrices { | ||
| float2x2 a; | ||
| double2x2 b; | ||
| }; | ||
|
|
||
| uint64_t Address; | ||
|
|
||
| [numthreads(1, 1, 1)] | ||
| void main() { | ||
| // CHECK: [[addr:%[0-9]+]] = OpLoad %ulong | ||
| // CHECK: [[buf:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_ulong | ||
| // CHECK-NEXT: [[load:%[0-9]+]] = OpLoad %ulong [[buf]] Aligned 8 | ||
| uint64_t scalar = vk::RawBufferLoad<uint64_t>(Address); | ||
|
|
||
| // CHECK: [[buf_1:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_double | ||
| // CHECK-NEXT: [[load_1:%[0-9]+]] = OpLoad %double [[buf_1]] Aligned 8 | ||
| double dbl = vk::RawBufferLoad<double>(Address); | ||
|
|
||
| // CHECK: [[buf_2:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWith64BitMember | ||
| // CHECK-NEXT: [[load_2:%[0-9]+]] = OpLoad %StructWith64BitMember{{[^ ]*}} [[buf_2]] Aligned 8 | ||
| StructWith64BitMember s1 = vk::RawBufferLoad<StructWith64BitMember>(Address); | ||
|
|
||
| // CHECK: [[buf_3:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithDoubleMember | ||
| // CHECK-NEXT: [[load_3:%[0-9]+]] = OpLoad %StructWithDoubleMember{{[^ ]*}} [[buf_3]] Aligned 8 | ||
| StructWithDoubleMember s2 = vk::RawBufferLoad<StructWithDoubleMember>(Address); | ||
|
|
||
| // Stores should also use alignment 8 for 64-bit types. | ||
| // CHECK: [[buf_4:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_ulong | ||
| // CHECK-NEXT: OpStore [[buf_4]] {{%[0-9]+}} Aligned 8 | ||
| vk::RawBufferStore<uint64_t>(Address, scalar); | ||
|
|
||
| // CHECK: [[buf_5:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_double | ||
| // CHECK-NEXT: OpStore [[buf_5]] {{%[0-9]+}} Aligned 8 | ||
| vk::RawBufferStore<double>(Address, dbl); | ||
|
|
||
| // CHECK: [[buf_6:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWith64BitMember | ||
| // CHECK: OpStore [[buf_6]] {{%[0-9]+}} Aligned 8 | ||
| vk::RawBufferStore<StructWith64BitMember>(Address, s1); | ||
|
|
||
| // CHECK: [[buf_7:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithDoubleMember | ||
| // CHECK: OpStore [[buf_7]] {{%[0-9]+}} Aligned 8 | ||
| vk::RawBufferStore<StructWithDoubleMember>(Address, s2); | ||
|
|
||
| // A structure mixing 16-bit, 32-bit and 64-bit scalars uses alignment 8 | ||
| // because of its 64-bit member. | ||
| // CHECK: [[buf_8:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithMixedScalars | ||
| // CHECK-NEXT: [[load_8:%[0-9]+]] = OpLoad %StructWithMixedScalars{{[^ ]*}} [[buf_8]] Aligned 8 | ||
| StructWithMixedScalars s3 = vk::RawBufferLoad<StructWithMixedScalars>(Address); | ||
|
|
||
| // A structure mixing only 16-bit and 32-bit scalars uses alignment 4. | ||
| // CHECK: [[buf_9:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWith16And32BitScalars | ||
| // CHECK-NEXT: [[load_9:%[0-9]+]] = OpLoad %StructWith16And32BitScalars{{[^ ]*}} [[buf_9]] Aligned 4 | ||
| StructWith16And32BitScalars s4 = vk::RawBufferLoad<StructWith16And32BitScalars>(Address); | ||
|
|
||
| // A structure with only 16-bit scalars has scalar alignment 2, which is the | ||
| // minimum required by the Vulkan spec for such an access. | ||
| // CHECK: [[buf_10:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithOnly16BitScalars | ||
| // CHECK-NEXT: [[load_10:%[0-9]+]] = OpLoad %StructWithOnly16BitScalars{{[^ ]*}} [[buf_10]] Aligned 2 | ||
| StructWithOnly16BitScalars s5 = vk::RawBufferLoad<StructWithOnly16BitScalars>(Address); | ||
|
|
||
| // A structure containing 16-bit, 32-bit and 64-bit vectors uses alignment 8 | ||
| // because of its 64-bit vector member. | ||
| // CHECK: [[buf_11:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithMixedVectors | ||
| // CHECK-NEXT: [[load_11:%[0-9]+]] = OpLoad %StructWithMixedVectors{{[^ ]*}} [[buf_11]] Aligned 8 | ||
| StructWithMixedVectors s6 = vk::RawBufferLoad<StructWithMixedVectors>(Address); | ||
|
|
||
| // A structure containing 32-bit and 64-bit matrices uses alignment 8 because | ||
| // of its 64-bit matrix member. | ||
| // CHECK: [[buf_12:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithMixedMatrices | ||
| // CHECK-NEXT: [[load_12:%[0-9]+]] = OpLoad %StructWithMixedMatrices{{[^ ]*}} [[buf_12]] Aligned 8 | ||
| StructWithMixedMatrices s7 = vk::RawBufferLoad<StructWithMixedMatrices>(Address); | ||
|
|
||
| // Stores use the same computed alignments as loads. | ||
| // CHECK: [[buf_13:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithMixedScalars | ||
| // CHECK: OpStore [[buf_13]] {{%[0-9]+}} Aligned 8 | ||
| vk::RawBufferStore<StructWithMixedScalars>(Address, s3); | ||
|
|
||
| // CHECK: [[buf_14:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWith16And32BitScalars | ||
| // CHECK: OpStore [[buf_14]] {{%[0-9]+}} Aligned 4 | ||
| vk::RawBufferStore<StructWith16And32BitScalars>(Address, s4); | ||
|
|
||
| // CHECK: [[buf_15:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithOnly16BitScalars | ||
| // CHECK: OpStore [[buf_15]] {{%[0-9]+}} Aligned 2 | ||
| vk::RawBufferStore<StructWithOnly16BitScalars>(Address, s5); | ||
|
|
||
| // CHECK: [[buf_16:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithMixedVectors | ||
| // CHECK: OpStore [[buf_16]] {{%[0-9]+}} Aligned 8 | ||
| vk::RawBufferStore<StructWithMixedVectors>(Address, s6); | ||
|
|
||
| // CHECK: [[buf_17:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_StructWithMixedMatrices | ||
| // CHECK: OpStore [[buf_17]] {{%[0-9]+}} Aligned 8 | ||
| vk::RawBufferStore<StructWithMixedMatrices>(Address, s7); | ||
|
|
||
| // A 16-bit scalar requires only 2-byte alignment. | ||
| // CHECK: [[buf_18:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_ushort | ||
| // CHECK-NEXT: [[load_18:%[0-9]+]] = OpLoad %ushort [[buf_18]] Aligned 2 | ||
| uint16_t u16 = vk::RawBufferLoad<uint16_t>(Address); | ||
|
|
||
| // CHECK: [[buf_19:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_half | ||
| // CHECK-NEXT: [[load_19:%[0-9]+]] = OpLoad %half [[buf_19]] Aligned 2 | ||
| half h = vk::RawBufferLoad<half>(Address); | ||
|
|
||
| // CHECK: [[buf_20:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_ushort | ||
| // CHECK: OpStore [[buf_20]] {{%[0-9]+}} Aligned 2 | ||
| vk::RawBufferStore<uint16_t>(Address, u16); | ||
|
|
||
| // CHECK: [[buf_21:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_half | ||
| // CHECK: OpStore [[buf_21]] {{%[0-9]+}} Aligned 2 | ||
| vk::RawBufferStore<half>(Address, h); | ||
| } |
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
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.
This should point to #8572, I think?