templateSubscripts.hlsl 562 B

123456789101112131415161718192021222324
  1. // RUN: %dxc -T ps_6_0 -enable-templates %s | FileCheck %s
  2. // Test applying the [] subscript operator in a templated function.
  3. // With the side effect of testing passing matrices, arrays, and vectors as params.
  4. template<typename T>
  5. float4 subscript(T t0) {
  6. return t0[3];
  7. }
  8. // CHECK: define void @main
  9. // CHECK: @dx.op.loadInput.f32
  10. // CHECK: @dx.op.loadInput.f32
  11. // CHECK: @dx.op.loadInput.f32
  12. bool main(float scalar : A, float4 vec : B, float4x4 mat : C, float4 arr[6] : D) : SV_Target {
  13. return subscript(vec) + subscript(mat) + subscript(arr);
  14. }