|
| 1 | +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ |
| 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 |
| 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 |
| 8 | + |
| 9 | + |
| 10 | +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 |
| 16 | +}; |
| 17 | + |
| 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 | +}; |
| 24 | + |
| 25 | +struct S3 { |
| 26 | + half a; // 2 bytes + 6 bytes pad or 4 bytes + 4 bytes pad |
| 27 | + uint64_t b; // 8 bytes |
| 28 | +}; |
| 29 | + |
| 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 |
| 35 | +}; |
| 36 | + |
| 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; |
| 42 | +} |
| 43 | + |
| 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; |
| 48 | +} |
| 49 | + |
| 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 | + |
| 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 | +} |
0 commit comments