-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPIRV] Round the stride to be a multiple of the alignment. (#6967)
We currently pick the size of a struct to be the stride of the array elements when doing scalar layout. This is not correct because this could cause the struct to not be correctly aligned. This is fixed by rounding the size of the struct up to a mutliple of the alignment. Fixes #6947
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// RUN: %dxc -T cs_6_2 -E main %s -fvk-use-scalar-layout -spirv | FileCheck %s | ||
|
||
// Check that the array stride and offsets are corrects. The uint64_t has alignment | ||
// 8 and the struct has size 12. So the stride should be the smallest multiple of 8 | ||
// greater than or equal to 12, which is 16. | ||
|
||
// CHECK-DAG: OpMemberDecorate %Data 0 Offset 0 | ||
// CHECK-DAG: OpMemberDecorate %Data 1 Offset 8 | ||
// CHECK-DAG: OpDecorate %_runtimearr_Data ArrayStride 16 | ||
// CHECK-DAG: OpMemberDecorate %type_RWStructuredBuffer_Data 0 Offset 0 | ||
struct Data { | ||
uint64_t y; | ||
uint x; | ||
}; | ||
RWStructuredBuffer<Data> buffer; | ||
|
||
[numthreads(1, 1, 1)] | ||
void main() | ||
{ | ||
buffer[0].x = 5; | ||
} |