|
| 1 | +// RUN: %dxc %s -fcgl -spirv -T ps_6_8 -fspv-target-env=vulkan1.1spirv1.4 | FileCheck %s |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +struct WithBool { |
| 6 | + bool b; |
| 7 | +}; |
| 8 | + |
| 9 | +struct StructWithBool { |
| 10 | + WithBool wb; |
| 11 | +}; |
| 12 | + |
| 13 | +struct StructWithoutBool { |
| 14 | + int a; |
| 15 | +}; |
| 16 | + |
| 17 | +struct OuterStruct { |
| 18 | + StructWithBool a[2]; |
| 19 | + WithBool b; |
| 20 | + StructWithoutBool c; |
| 21 | + StructWithoutBool d[2]; |
| 22 | +} S; |
| 23 | + |
| 24 | + |
| 25 | +// CHECK: %GetStruct = OpFunction %OuterStruct_0 None %34 |
| 26 | +// CHECK: %bb_entry_0 = OpLabel |
| 27 | +// CHECK: [[ld:%[0-9]+]] = OpLoad %OuterStruct %39 |
| 28 | + |
| 29 | +// The array `a` must be split up because it contains a bool that needs a |
| 30 | +// conversion from int to bool. |
| 31 | +// CHECK: [[arr_with_bool:%[0-9]+]] = OpCompositeExtract %_arr_StructWithBool_uint_2 [[ld]] 0 |
| 32 | +// CHECK: [[struct_with_bool:%[0-9]+]] = OpCompositeExtract %StructWithBool [[arr_with_bool]] 0 |
| 33 | +// CHECK: [[with_bool:%[0-9]+]] = OpCompositeExtract %WithBool [[struct_with_bool]] 0 |
| 34 | +// CHECK: [[int:%[0-9]+]] = OpCompositeExtract %uint [[with_bool]] 0 |
| 35 | +// CHECK: [[bool:%[0-9]+]] = OpINotEqual %bool [[int]] %uint_0 |
| 36 | +// CHECK: [[with_bool:%[0-9]+]] = OpCompositeConstruct %WithBool_0 [[bool]] |
| 37 | +// CHECK: [[struct_with_bool:%[0-9]+]] = OpCompositeConstruct %StructWithBool_0 [[with_bool]] |
| 38 | + |
| 39 | +// Skip second element of the array. It is more of the same. |
| 40 | +// CHECK: [[a:%[0-9]+]] = OpCompositeConstruct %_arr_StructWithBool_0_uint_2 [[struct_with_bool]] {{%.*}} |
| 41 | + |
| 42 | +// The struct `b` must be split up for the same reason. |
| 43 | +// CHECK: [[with_bool:%[0-9]+]] = OpCompositeExtract %WithBool [[ld]] 1 |
| 44 | +// CHECK: [[int:%[0-9]+]] = OpCompositeExtract %uint [[with_bool]] 0 |
| 45 | +// CHECK: [[bool:%[0-9]+]] = OpINotEqual %bool [[int]] %uint_0 |
| 46 | +// CHECK: [[b:%[0-9]+]] = OpCompositeConstruct %WithBool_0 [[bool]] |
| 47 | + |
| 48 | +// The struct `c` can use OpCopyLogical. |
| 49 | +// CHECK: %59 = OpCompositeExtract %StructWithoutBool [[ld]] 2 |
| 50 | +// CHECK: [[c:%[0-9]+]] = OpCopyLogical %StructWithoutBool_0 %59 |
| 51 | + |
| 52 | +// The array `d` can use OpCopyLogical. |
| 53 | +// CHECK: %61 = OpCompositeExtract %_arr_StructWithoutBool_uint_2 [[ld]] 3 |
| 54 | +// CHECK: [[d:%[0-9]+]] = OpCopyLogical %_arr_StructWithoutBool_0_uint_2 %61 |
| 55 | + |
| 56 | +// CHECK: [[r:%[0-9]+]] = OpCompositeConstruct %OuterStruct_0 [[a]] [[b]] [[c]] [[d]] |
| 57 | +// CHECK: OpStore {{%.*}} [[r]] |
| 58 | +// CHECK: OpFunctionEnd |
| 59 | + |
| 60 | +OuterStruct GetStruct() { return S; } |
| 61 | + |
| 62 | +uint main() : SV_TARGET |
| 63 | +{ |
| 64 | + GetStruct(); |
| 65 | + return 0; |
| 66 | +} |
| 67 | + |
0 commit comments