cast.flat-conversion.implicit.hlsl 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Run: %dxc -T ps_6_0 -E main
  2. struct VSOutput {
  3. float4 sv_pos : SV_POSITION;
  4. uint3 normal : NORMAL;
  5. int2 tex_coord : TEXCOORD;
  6. bool mybool[2] : MYBOOL;
  7. int arr[5] : MYARRAY;
  8. float2x3 mat2x3 : MYMATRIX;
  9. int2x3 intmat : MYINTMATRIX;
  10. bool2x3 boolmat : MYBOOLMATRIX;
  11. };
  12. // CHECK: [[nullVSOutput:%\d+]] = OpConstantNull %VSOutput
  13. void main() {
  14. int x = 3;
  15. // CHECK: OpStore %output1 [[nullVSOutput]]
  16. VSOutput output1 = (VSOutput)0;
  17. // CHECK: OpStore %output2 [[nullVSOutput]]
  18. VSOutput output2 = (VSOutput)0.0;
  19. // CHECK: OpStore %output3 [[nullVSOutput]]
  20. VSOutput output3 = (VSOutput)false;
  21. // CHECK: [[f1:%\d+]] = OpConvertSToF %float %int_1
  22. // CHECK-NEXT: [[v4f1:%\d+]] = OpCompositeConstruct %v4float [[f1]] [[f1]] [[f1]] [[f1]]
  23. // CHECK-NEXT: [[u1:%\d+]] = OpBitcast %uint %int_1
  24. // CHECK-NEXT: [[v3u1:%\d+]] = OpCompositeConstruct %v3uint [[u1]] [[u1]] [[u1]]
  25. // CHECK-NEXT: [[v2i1:%\d+]] = OpCompositeConstruct %v2int %int_1 %int_1
  26. // CHECK-NEXT: [[bool1:%\d+]] = OpINotEqual %bool %int_1 %int_0
  27. // CHECK-NEXT: [[arr2bool1:%\d+]] = OpCompositeConstruct %_arr_bool_uint_2 [[bool1]] [[bool1]]
  28. // CHECK-NEXT: [[arr5i1:%\d+]] = OpCompositeConstruct %_arr_int_uint_5 %int_1 %int_1 %int_1 %int_1 %int_1
  29. // CHECK-NEXT: [[f1_1:%\d+]] = OpConvertSToF %float %int_1
  30. // CHECK-NEXT: [[col3:%\d+]] = OpCompositeConstruct %v3float [[f1_1]] [[f1_1]] [[f1_1]]
  31. // CHECK-NEXT: [[matFloat1:%\d+]] = OpCompositeConstruct %mat2v3float [[col3]] [[col3]]
  32. // CHECK-NEXT: [[v3i1:%\d+]] = OpCompositeConstruct %v3int %int_1 %int_1 %int_1
  33. // CHECK-NEXT: [[intmat:%\d+]] = OpCompositeConstruct %_arr_v3int_uint_2 [[v3i1]] [[v3i1]]
  34. // CHECK-NEXT: [[true:%\d+]] = OpINotEqual %bool %int_1 %int_0
  35. // CHECK-NEXT: [[boolvec:%\d+]] = OpCompositeConstruct %v3bool [[true]] [[true]] [[true]]
  36. // CHECK-NEXT: [[boolmat:%\d+]] = OpCompositeConstruct %_arr_v3bool_uint_2 [[boolvec]] [[boolvec]]
  37. // CHECK-NEXT: [[flatConvert1:%\d+]] = OpCompositeConstruct %VSOutput [[v4f1]] [[v3u1]] [[v2i1]] [[arr2bool1]] [[arr5i1]] [[matFloat1]] [[intmat]] [[boolmat]]
  38. // CHECK-NEXT: OpStore %output4 [[flatConvert1]]
  39. VSOutput output4 = (VSOutput)1;
  40. // CHECK: [[x:%\d+]] = OpLoad %int %x
  41. // CHECK-NEXT: [[floatX:%\d+]] = OpConvertSToF %float [[x]]
  42. // CHECK-NEXT: [[v4fX:%\d+]] = OpCompositeConstruct %v4float [[floatX]] [[floatX]] [[floatX]] [[floatX]]
  43. // CHECK-NEXT: [[uintX:%\d+]] = OpBitcast %uint [[x]]
  44. // CHECK-NEXT: [[v3uX:%\d+]] = OpCompositeConstruct %v3uint [[uintX]] [[uintX]] [[uintX]]
  45. // CHECK-NEXT: [[v2iX:%\d+]] = OpCompositeConstruct %v2int [[x]] [[x]]
  46. // CHECK-NEXT: [[boolX:%\d+]] = OpINotEqual %bool [[x]] %int_0
  47. // CHECK-NEXT: [[arr2boolX:%\d+]] = OpCompositeConstruct %_arr_bool_uint_2 [[boolX]] [[boolX]]
  48. // CHECK-NEXT: [[arr5iX:%\d+]] = OpCompositeConstruct %_arr_int_uint_5 [[x]] [[x]] [[x]] [[x]] [[x]]
  49. // CHECK-NEXT: [[floatX2:%\d+]] = OpConvertSToF %float [[x]]
  50. // CHECK-NEXT: [[v3fX:%\d+]] = OpCompositeConstruct %v3float [[floatX2]] [[floatX2]] [[floatX2]]
  51. // CHECK-NEXT: [[matFloatX:%\d+]] = OpCompositeConstruct %mat2v3float [[v3fX]] [[v3fX]]
  52. // CHECK-NEXT: [[intvec:%\d+]] = OpCompositeConstruct %v3int [[x]] [[x]] [[x]]
  53. // CHECK-NEXT: [[intmat:%\d+]] = OpCompositeConstruct %_arr_v3int_uint_2 [[intvec]] [[intvec]]
  54. // CHECK-NEXT: [[boolx:%\d+]] = OpINotEqual %bool [[x]] %int_0
  55. // CHECK-NEXT: [[boolvec:%\d+]] = OpCompositeConstruct %v3bool [[boolx]] [[boolx]] [[boolx]]
  56. // CHECK-NEXT: [[boolmat:%\d+]] = OpCompositeConstruct %_arr_v3bool_uint_2 [[boolvec]] [[boolvec]]
  57. // CHECK-NEXT: [[flatConvert2:%\d+]] = OpCompositeConstruct %VSOutput [[v4fX]] [[v3uX]] [[v2iX]] [[arr2boolX]] [[arr5iX]] [[matFloatX]] [[intmat]] [[boolmat]]
  58. // CHECK-NEXT: OpStore %output5 [[flatConvert2]]
  59. VSOutput output5 = (VSOutput)x;
  60. // CHECK: [[v4f1_5:%\d+]] = OpCompositeConstruct %v4float %float_1_5 %float_1_5 %float_1_5 %float_1_5
  61. // CHECK-NEXT: [[u1_5:%\d+]] = OpConvertFToU %uint %float_1_5
  62. // CHECK-NEXT: [[v3u1_5:%\d+]] = OpCompositeConstruct %v3uint [[u1_5]] [[u1_5]] [[u1_5]]
  63. // CHECK-NEXT: [[i1_5:%\d+]] = OpConvertFToS %int %float_1_5
  64. // CHECK-NEXT: [[v2i1_5:%\d+]] = OpCompositeConstruct %v2int [[i1_5]] [[i1_5]]
  65. // CHECK-NEXT: [[bool1_5:%\d+]] = OpFOrdNotEqual %bool %float_1_5 %float_0
  66. // CHECK-NEXT: [[arr2bool_1_5:%\d+]] = OpCompositeConstruct %_arr_bool_uint_2 [[bool1_5]] [[bool1_5]]
  67. // CHECK-NEXT: [[i1_5:%\d+]] = OpConvertFToS %int %float_1_5
  68. // CHECK-NEXT: [[arr5i1_5:%\d+]] = OpCompositeConstruct %_arr_int_uint_5 [[i1_5]] [[i1_5]] [[i1_5]] [[i1_5]] [[i1_5]]
  69. // CHECK-NEXT: [[v3f_1_5:%\d+]] = OpCompositeConstruct %v3float %float_1_5 %float_1_5 %float_1_5
  70. // CHECK-NEXT: [[matFloat_1_5:%\d+]] = OpCompositeConstruct %mat2v3float [[v3f_1_5]] [[v3f_1_5]]
  71. // CHECK-NEXT: [[int_1_5:%\d+]] = OpConvertFToS %int %float_1_5
  72. // CHECK-NEXT: [[intvec:%\d+]] = OpCompositeConstruct %v3int [[int_1_5]] [[int_1_5]] [[int_1_5]]
  73. // CHECK-NEXT: [[intmat:%\d+]] = OpCompositeConstruct %_arr_v3int_uint_2 [[intvec]] [[intvec]]
  74. // CHECK-NEXT: [[bool_1_5:%\d+]] = OpFOrdNotEqual %bool %float_1_5 %float_0
  75. // CHECK-NEXT: [[boolvec:%\d+]] = OpCompositeConstruct %v3bool [[bool_1_5]] [[bool_1_5]] [[bool_1_5]]
  76. // CHECK-NEXT: [[boolmat:%\d+]] = OpCompositeConstruct %_arr_v3bool_uint_2 [[boolvec]] [[boolvec]]
  77. // CHECK-NEXT: {{%\d+}} = OpCompositeConstruct %VSOutput [[v4f1_5]] [[v3u1_5]] [[v2i1_5]] [[arr2bool_1_5]] [[arr5i1_5]] [[matFloat_1_5]] [[intmat]] [[boolmat]]
  78. VSOutput output6 = (VSOutput)1.5;
  79. // CHECK: [[float_true:%\d+]] = OpSelect %float %true %float_1 %float_0
  80. // CHECK-NEXT: [[v4f_true:%\d+]] = OpCompositeConstruct %v4float [[float_true]] [[float_true]] [[float_true]] [[float_true]]
  81. // CHECK-NEXT: [[uint_true:%\d+]] = OpSelect %uint %true %uint_1 %uint_0
  82. // CHECK-NEXT: [[v3u_true:%\d+]] = OpCompositeConstruct %v3uint [[uint_true]] [[uint_true]] [[uint_true]]
  83. // CHECK-NEXT: [[int_true:%\d+]] = OpSelect %int %true %int_1 %int_0
  84. // CHECK-NEXT: [[v2i_true:%\d+]] = OpCompositeConstruct %v2int [[int_true]] [[int_true]]
  85. // CHECK-NEXT: [[arr2_true:%\d+]] = OpCompositeConstruct %_arr_bool_uint_2 %true %true
  86. // CHECK-NEXT: [[int_true:%\d+]] = OpSelect %int %true %int_1 %int_0
  87. // CHECK-NEXT: [[arr5i_true:%\d+]] = OpCompositeConstruct %_arr_int_uint_5 [[int_true]] [[int_true]] [[int_true]] [[int_true]] [[int_true]]
  88. // CHECK-NEXT: [[float_true:%\d+]] = OpSelect %float %true %float_1 %float_0
  89. // CHECK-NEXT: [[v3f_true:%\d+]] = OpCompositeConstruct %v3float [[float_true]] [[float_true]] [[float_true]]
  90. // CHECK-NEXT:[[mat2v3_true:%\d+]] = OpCompositeConstruct %mat2v3float [[v3f_true]] [[v3f_true]]
  91. // CHECK-NEXT: [[true_int:%\d+]] = OpSelect %int %true %int_1 %int_0
  92. // CHECK-NEXT: [[intvec:%\d+]] = OpCompositeConstruct %v3int [[true_int]] [[true_int]] [[true_int]]
  93. // CHECK-NEXT: [[intmat:%\d+]] = OpCompositeConstruct %_arr_v3int_uint_2 [[intvec]] [[intvec]]
  94. // CHECK-NEXT: [[boolvec:%\d+]] = OpCompositeConstruct %v3bool %true %true %true
  95. // CHECK-NEXT: [[boolmat:%\d+]] = OpCompositeConstruct %_arr_v3bool_uint_2 [[boolvec]] [[boolvec]]
  96. // CHECK-NEXT: {{%\d+}} = OpCompositeConstruct %VSOutput [[v4f_true]] [[v3u_true]] [[v2i_true]] [[arr2_true]] [[arr5i_true]] [[mat2v3_true]] [[intmat]] [[boolmat]]
  97. VSOutput output7 = (VSOutput)true;
  98. }