|
| 1 | +// RUN: %dxc -HV 2021 -T cs_6_7 -E main -fcgl %s -spirv | FileCheck %s |
| 2 | + |
| 3 | +template<typename MatT> |
| 4 | +struct matrix_traits; |
| 5 | + |
| 6 | +template<typename T, int32_t N, int32_t M> |
| 7 | +struct matrix_traits<matrix<T,N,M> > |
| 8 | +{ |
| 9 | + static const uint32_t RowCount = N; |
| 10 | + static const uint32_t ColumnCount = M; |
| 11 | +}; |
| 12 | + |
| 13 | +template<typename MatT> |
| 14 | +uint32_t elementCount() |
| 15 | +{ |
| 16 | + return matrix_traits<MatT>::RowCount * matrix_traits<MatT>::ColumnCount; |
| 17 | +} |
| 18 | + |
| 19 | +RWBuffer<int> o; |
| 20 | + |
| 21 | +// Initialize the static members at the start of wrapper |
| 22 | +// CHECK: %main = OpFunction %void None |
| 23 | +// CHECK: OpStore %RowCount %uint_4 |
| 24 | +// CHECK: OpStore %ColumnCount %uint_4 |
| 25 | +// CHECK: OpStore %RowCount_0 %uint_3 |
| 26 | +// CHECK: OpStore %ColumnCount_0 %uint_2 |
| 27 | +// CHECK: OpFunctionEnd |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +// CHECK: %src_main = OpFunction %void None |
| 32 | +[numthreads(64,1,1)] |
| 33 | +void main() |
| 34 | +{ |
| 35 | +// CHECK: OpFunctionCall %uint %elementCount |
| 36 | + o[0] = elementCount<float32_t4x4>(); |
| 37 | +// CHECK: OpFunctionCall %uint %elementCount_0 |
| 38 | + o[1] = elementCount<float32_t3x2>(); |
| 39 | +} |
| 40 | + |
| 41 | +// CHECK: %elementCount = OpFunction %uint None |
| 42 | +// CHECK-NEXT: OpLabel |
| 43 | +// CHECK-NEXT: [[rc:%[0-9]+]] = OpLoad %uint %RowCount |
| 44 | +// CHECK-NEXT: [[cc:%[0-9]+]] = OpLoad %uint %ColumnCount |
| 45 | +// CHECK-NEXT: [[mul:%[0-9]+]] = OpIMul %uint [[rc]] [[cc]] |
| 46 | +// CHECK-NEXT: OpReturnValue [[mul]] |
| 47 | +// CHECK-NEXT: OpFunctionEnd |
| 48 | + |
| 49 | +// CHECK: %elementCount_0 = OpFunction %uint None |
| 50 | +// CHECK-NEXT: %bb_entry_1 = OpLabel |
| 51 | +// CHECK-NEXT: [[rc:%[0-9]+]] = OpLoad %uint %RowCount_0 |
| 52 | +// CHECK-NEXT: [[cc:%[0-9]+]] = OpLoad %uint %ColumnCount_0 |
| 53 | +// CHECK-NEXT: [[mul:%[0-9]+]] = OpIMul %uint [[rc]] [[cc]] |
| 54 | +// CHECK-NEXT: OpReturnValue [[mul]] |
| 55 | +// CHECK-NEXT: OpFunctionEnd |
0 commit comments