|
1 | 1 | // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ |
2 | 2 | // RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ |
3 | | -// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefix=CHECK-HALF |
| 3 | +// RUN: -fsyntax-only -verify -verify-ignore-unexpected=warning |
4 | 4 |
|
5 | | -// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ |
6 | | -// RUN: dxil-pc-shadermodel6.3-library %s \ |
7 | | -// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefix=CHECK-FLOAT |
| 5 | +struct S0 { |
| 6 | + half a; |
| 7 | + half b; |
| 8 | + half c; |
| 9 | + half d; |
| 10 | + half e; |
| 11 | + half f; |
| 12 | + half g; |
| 13 | + half h; |
| 14 | +}; |
| 15 | + |
| 16 | +cbuffer CB0Pass { |
| 17 | + S0 s0p : packoffset(c0.x); |
| 18 | + float f0p : packoffset(c1.x); |
| 19 | +} |
8 | 20 |
|
| 21 | +cbuffer CB0Fail { |
| 22 | + S0 s0f : packoffset(c0.x); |
| 23 | + float f0f : packoffset(c0.w); |
| 24 | + // expected-error@-1 {{packoffset overlap between 'f0f', 's0f'}} |
| 25 | +} |
9 | 26 |
|
10 | 27 | struct S1 { |
11 | | - half a; // 2 bytes + 2 bytes pad or 4 bytes |
12 | | - float b; // 4 bytes |
13 | | - half c; // 2 bytes + 2 bytes pad or 4 bytes |
14 | | - float d; // 4 bytes |
15 | | - double e; // 8 bytes |
| 28 | + float a; |
| 29 | + double b; |
| 30 | + float c; |
16 | 31 | }; |
17 | 32 |
|
18 | | -struct S2 { |
19 | | - half a; // 2 bytes or 4 bytes |
20 | | - half b; // 2 bytes or 4 bytes |
21 | | - float e; // 4 bytes or 4 bytes + 4 padding |
22 | | - double f; // 8 bytes |
23 | | -}; |
| 33 | +cbuffer CB1Pass { |
| 34 | + S1 s1p : packoffset(c0.x); |
| 35 | + float f1p : packoffset(c1.y); |
| 36 | +} |
24 | 37 |
|
25 | | -struct S3 { |
26 | | - half a; // 2 bytes + 6 bytes pad or 4 bytes + 4 bytes pad |
27 | | - uint64_t b; // 8 bytes |
28 | | -}; |
| 38 | +cbuffer CB1Fail { |
| 39 | + S1 s1f : packoffset(c0.x); |
| 40 | + float f1f : packoffset(c1.x); |
| 41 | + // expected-error@-1 {{packoffset overlap between 'f1f', 's1f'}} |
| 42 | +} |
29 | 43 |
|
30 | | -struct S4 { |
31 | | - float a; // 4 bytes |
32 | | - half b; // 2 bytes or 4 bytes |
33 | | - half c; // 2 bytes or 4 bytes + 4 bytes pad |
34 | | - double d; // 8 bytes |
| 44 | +struct S2 { |
| 45 | + float3 a; |
| 46 | + float2 b; |
35 | 47 | }; |
36 | 48 |
|
37 | | - |
38 | | -cbuffer CB0 { |
39 | | - // CHECK-HALF: @CB0.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB0, 24, 0)) |
40 | | - // CHECK-FLOAT: @CB0.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB0, 24, 0)) |
41 | | - S1 s1; |
| 49 | +cbuffer CB2Pass { |
| 50 | + S2 s2p : packoffset(c0.x); |
| 51 | + float f2p : packoffset(c1.z); |
42 | 52 | } |
43 | 53 |
|
44 | | -cbuffer CB1 { |
45 | | - // CHECK-HALF: @CB1.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB1, 16, 0)) |
46 | | - // CHECK-FLOAT: @CB1.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB1, 24, 0)) |
47 | | - S2 s2; |
| 54 | +cbuffer CB2Fail { |
| 55 | + S2 s2f : packoffset(c0.x); |
| 56 | + float f2f : packoffset(c1.y); |
| 57 | + // expected-error@-1 {{packoffset overlap between 'f2f', 's2f'}} |
48 | 58 | } |
49 | 59 |
|
50 | | -cbuffer CB2 { |
51 | | - // CHECK-HALF: @CB2.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 16, 0)) |
52 | | - // CHECK-FLOAT: @CB2.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 16, 0)) |
53 | | - S3 s3; |
54 | | -} |
55 | 60 |
|
56 | | -cbuffer CB3 { |
57 | | - // CHECK-HALF: @CB3.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB3, 16, 0)) |
58 | | - // CHECK-FLOAT: @CB3.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB3, 24, 0)) |
59 | | - S4 s4; |
60 | | -} |
| 61 | +#if 0 |
| 62 | +struct S3 { |
| 63 | + float3 a; |
| 64 | + float b; |
| 65 | +}; |
| 66 | + |
| 67 | +struct S4 { |
| 68 | + float2 a; |
| 69 | + float2 b; |
| 70 | +}; |
| 71 | +#endif |
0 commit comments