forked from microsoft/DirectXShaderCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add warning when vk::offset is not correctly aligned (microsoft#6694)
We will start issues a warning when `vk::offset` is not correctly aligned to make it easier for users to understand why their spir-v will not validate. Note that we do not treat this as an error because we want to allow someone to have the flexibility to do other things. For example, they could be targeting an API that does not follow any of the existing rules, which is why they are using `vk::offset`. Fixes microsoft#6171
- Loading branch information
Showing
3 changed files
with
52 additions
and
3 deletions.
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
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,33 @@ | ||
// RUN: not %dxc %s -HV 2021 -T cs_6_6 -E main -fspv-target-env=vulkan1.3 -fcgl -spirv 2>&1 | FileCheck %s -check-prefix=WARNING | ||
// RUN: %dxc %s -HV 2021 -T cs_6_6 -E main -fspv-target-env=vulkan1.3 -fcgl -spirv -fvk-use-scalar-layout 2>&1 | FileCheck %s -check-prefix=SCALAR | ||
|
||
struct complex | ||
{ | ||
float r; | ||
float i; | ||
}; | ||
|
||
// When using the default layout, the member should be aligned at a multiple of 16. | ||
// We expect an error | ||
// WARNING: :20:31: warning: The offset provided in the attribute should be 16-byte aligned. | ||
|
||
// When using scalar layout, the member should be placed at offset 8. | ||
// SCALAR: OpMemberDecorate %Error 1 Offset 8 | ||
|
||
struct Error | ||
{ | ||
float2 a; | ||
[[vk::offset(8)]] complex b; | ||
}; | ||
|
||
cbuffer Stuff | ||
{ | ||
Error b[10]; | ||
}; | ||
|
||
[numthreads(1, 1, 1)] | ||
void main() | ||
{ | ||
Error testValue = b[0]; | ||
} | ||
|