vector-matrix-binops.hlsl 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
  2. // CHECK: vector-matrix-binops.hlsl:29:26: warning: implicit truncation of vector type
  3. // CHECK: vector-matrix-binops.hlsl:30:21: warning: implicit truncation of vector type
  4. // CHECK: vector-matrix-binops.hlsl:30:14: warning: implicit truncation of vector type
  5. // CHECK: vector-matrix-binops.hlsl:35:23: warning: implicit truncation of vector type
  6. // CHECK: vector-matrix-binops.hlsl:36:29: warning: implicit truncation of vector type
  7. // CHECK: vector-matrix-binops.hlsl:37:23: warning: implicit truncation of vector type
  8. // CHECK: vector-matrix-binops.hlsl:37:16: warning: implicit truncation of vector type
  9. // CHECK: vector-matrix-binops.hlsl:42:26: error: cannot convert from 'float4x4' to 'float4'
  10. // CHECK: vector-matrix-binops.hlsl:43:29: error: cannot convert from 'float4' to 'float4x4'
  11. // CHECK: vector-matrix-binops.hlsl:44:26: warning: implicit truncation of vector type
  12. // CHECK: vector-matrix-binops.hlsl:45:21: warning: implicit truncation of vector type
  13. // CHECK: vector-matrix-binops.hlsl:58:29: error: cannot convert from 'float3x2' to 'float2x3'
  14. // CHECK: vector-matrix-binops.hlsl:59:29: error: cannot convert from 'float2x3' to 'float1x4'
  15. void main() {
  16. float4 v4 = float4(0.1f, 0.2f, 0.3f, 0.4f);
  17. float3 v3 = float3(0.1f, 0.2f, 0.3f);
  18. float2 v2 = float2(0.5f, 0.6f);
  19. float4x4 m44 = float4x4(v4, v4, v4, v4);
  20. float2x2 m22 = float2x2(0.1f, 0.2f, 0.3f, 0.4f);
  21. float1x4 m14 = float1x4(v4);
  22. float3x2 m32 = float3x2(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f);
  23. // vector truncation
  24. {
  25. float2 res1 = v2 * v4; // expected-warning {{implicit truncation of vector type}}
  26. float2 res2 = v4 - v3; // expected-warning {{implicit truncation of vector type}}
  27. }
  28. // matrix truncation
  29. {
  30. float1x4 res1 = m44 / m14; // expected-warning {{implicit truncation of vector type}}
  31. float1x4 res2 = m14 - m44; // expected-warning {{implicit truncation of vector type}}
  32. float2x2 res3 = m44 + m32; // expected-warning {{implicit truncation of vector type}}
  33. }
  34. // matrix and vector binary operation - mismatched dimensions
  35. {
  36. float4 res1 = v4 * m44; // expected-error {{cannot convert from 'float4x4' to 'float4'}}
  37. float4x4 res2 = m44 + v4; // expected-error {{cannot convert from 'float4' to 'float4x4'}}
  38. float3 res3 = v3 * m14; // expected-warning {{implicit truncation of vector type}}
  39. float2 res4 = m14 / v2; // expected-warning {{implicit truncation of vector type}}
  40. }
  41. // matrix and vector binary operation - matching dimensions - no warnings expected
  42. {
  43. float4 res1 = v4 / m22;
  44. float2x2 res2 = m22 - v4;
  45. float4 res3 = v4 + m14;
  46. }
  47. // matrix mismatched dimensions
  48. {
  49. float2x3 m23 = float2x3(1, 2, 3, 4, 5, 6);
  50. float3x2 res1 = m23 - m32; // expected-error {{error: cannot convert from 'float3x2' to 'float2x3'}}
  51. float1x4 res2 = m14 / m23; // expected-error {{cannot convert from 'float2x3' to 'float1x4'}}
  52. }
  53. }