2
0

vector-conditional.hlsl 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. // RUN: %clang_cc1 -fsyntax-only -ffreestanding -verify %s
  2. // Disable validation on fxc (/Vd) because
  3. // non-literal ternary with objects results in bad code.
  4. // :FXC_VERIFY_ARGUMENTS: /E main /T ps_5_1 /Vd
  5. /****************************************************************************
  6. Notes:
  7. - try various object types:
  8. Basic Numerics: scalar, vector, matrix
  9. Arrays
  10. User Defined Types
  11. Objects: Textures/Samplers/Streams/Patches?
  12. Inner Objects: intermediate mips object?
  13. - try various dimensions, testing truncation/replication, etc...
  14. - try various numeric component types, testing promotion, etc...
  15. - try l-value vs. r-value cases: like out params, etc...
  16. ****************************************************************************/
  17. bool4 b4;
  18. bool4x4 b4x4;
  19. bool3x3 b3x3;
  20. Texture2D T1;
  21. Texture2D T2;
  22. SamplerState S;
  23. float4x4 m1, m2;
  24. // UDT1, UDT2, and UDT3 have the same number of components:
  25. struct UDT1 {
  26. float4 a;
  27. float4 b;
  28. };
  29. struct UDT2 {
  30. row_major float4x2 m;
  31. };
  32. struct UDT3 {
  33. float a;
  34. float b;
  35. float3 c;
  36. float3 d;
  37. };
  38. UDT1 u1, u1b;
  39. UDT2 u2;
  40. UDT3 u3;
  41. float4 a1[2];
  42. float4 a2[2];
  43. float4 a3[8];
  44. float a4[8];
  45. void Select(out Texture2D TOut) { /* expected-note {{candidate function}} fxc-pass {{}} */
  46. TOut = b4.x ? T1 : T2;
  47. }
  48. float4 main(float4 v0 : TEXCOORD) : SV_Target
  49. {
  50. float4 acc = 0.0F;
  51. acc += b4.x ?: v0; /* expected-error {{use of GNU ?: conditional expression extension, omitting middle operand is unsupported in HLSL}} fxc-error {{X3000: syntax error: unexpected token ':'}} */
  52. acc += b4.x ? v0 : (v0 + 1.0F);
  53. /*verify-ast
  54. CompoundAssignOperator <col:3, col:32> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
  55. |-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  56. `-ConditionalOperator <col:10, col:32> 'vector<float, 4>'
  57. |-ImplicitCastExpr <col:10, col:13> 'const bool' <LValueToRValue>
  58. | `-HLSLVectorElementExpr <col:10, col:13> 'const bool' lvalue vectorcomponent x
  59. | `-DeclRefExpr <col:10> 'const bool4':'const vector<bool, 4>' lvalue Var 'b4' 'const bool4':'const vector<bool, 4>'
  60. |-ImplicitCastExpr <col:17> 'float4':'vector<float, 4>' <LValueToRValue>
  61. | `-DeclRefExpr <col:17> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  62. `-ParenExpr <col:22, col:32> 'float4':'vector<float, 4>'
  63. `-BinaryOperator <col:23, col:28> 'float4':'vector<float, 4>' '+'
  64. |-ImplicitCastExpr <col:23> 'float4':'vector<float, 4>' <LValueToRValue>
  65. | `-DeclRefExpr <col:23> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  66. `-ImplicitCastExpr <col:28> 'vector<float, 4>':'vector<float, 4>' <HLSLVectorSplat>
  67. `-FloatingLiteral <col:28> 'float' 1.000000e+00
  68. */
  69. acc += b4.x ? v0 : 1.0F;
  70. /*verify-ast
  71. CompoundAssignOperator <col:3, col:22> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
  72. |-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  73. `-ConditionalOperator <col:10, col:22> 'vector<float, 4>'
  74. |-ImplicitCastExpr <col:10, col:13> 'const bool' <LValueToRValue>
  75. | `-HLSLVectorElementExpr <col:10, col:13> 'const bool' lvalue vectorcomponent x
  76. | `-DeclRefExpr <col:10> 'const bool4':'const vector<bool, 4>' lvalue Var 'b4' 'const bool4':'const vector<bool, 4>'
  77. |-ImplicitCastExpr <col:17> 'float4':'vector<float, 4>' <LValueToRValue>
  78. | `-DeclRefExpr <col:17> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  79. `-ImplicitCastExpr <col:22> 'vector<float, 4>':'vector<float, 4>' <HLSLVectorSplat>
  80. `-FloatingLiteral <col:22> 'float' 1.000000e+00
  81. */
  82. acc += b4 ? v0 : (v0 + 1.0F);
  83. /*verify-ast
  84. CompoundAssignOperator <col:3, col:30> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
  85. |-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  86. `-ConditionalOperator <col:10, col:30> 'vector<float, 4>'
  87. |-ImplicitCastExpr <col:10> 'const bool4':'const vector<bool, 4>' <LValueToRValue>
  88. | `-DeclRefExpr <col:10> 'const bool4':'const vector<bool, 4>' lvalue Var 'b4' 'const bool4':'const vector<bool, 4>'
  89. |-ImplicitCastExpr <col:15> 'float4':'vector<float, 4>' <LValueToRValue>
  90. | `-DeclRefExpr <col:15> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  91. `-ParenExpr <col:20, col:30> 'float4':'vector<float, 4>'
  92. `-BinaryOperator <col:21, col:26> 'float4':'vector<float, 4>' '+'
  93. |-ImplicitCastExpr <col:21> 'float4':'vector<float, 4>' <LValueToRValue>
  94. | `-DeclRefExpr <col:21> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  95. `-ImplicitCastExpr <col:26> 'vector<float, 4>':'vector<float, 4>' <HLSLVectorSplat>
  96. `-FloatingLiteral <col:26> 'float' 1.000000e+00
  97. */
  98. acc += b4 ? v0 : 1.0F;
  99. /*verify-ast
  100. CompoundAssignOperator <col:3, col:20> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
  101. |-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  102. `-ConditionalOperator <col:10, col:20> 'vector<float, 4>'
  103. |-ImplicitCastExpr <col:10> 'const bool4':'const vector<bool, 4>' <LValueToRValue>
  104. | `-DeclRefExpr <col:10> 'const bool4':'const vector<bool, 4>' lvalue Var 'b4' 'const bool4':'const vector<bool, 4>'
  105. |-ImplicitCastExpr <col:15> 'float4':'vector<float, 4>' <LValueToRValue>
  106. | `-DeclRefExpr <col:15> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  107. `-ImplicitCastExpr <col:20> 'vector<float, 4>':'vector<float, 4>' <HLSLVectorSplat>
  108. `-FloatingLiteral <col:20> 'float' 1.000000e+00
  109. */
  110. acc.xy += b4.xy ? v0.xy : (v0 + 1.0F); /* expected-warning {{implicit truncation of vector type}} fxc-warning {{X3206: implicit truncation of vector type}} */
  111. /*verify-ast
  112. CompoundAssignOperator <col:3, col:39> 'vector<float, 2>':'vector<float, 2>' lvalue vectorcomponent '+=' ComputeLHSTy='vector<float, 2>':'vector<float, 2>' ComputeResultTy='vector<float, 2>':'vector<float, 2>'
  113. |-HLSLVectorElementExpr <col:3, col:7> 'vector<float, 2>':'vector<float, 2>' lvalue vectorcomponent xy
  114. | `-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  115. `-ConditionalOperator <col:13, col:39> 'vector<float, 2>'
  116. |-ImplicitCastExpr <col:13, col:16> 'const vector<bool, 2>':'const vector<bool, 2>' <LValueToRValue>
  117. | `-HLSLVectorElementExpr <col:13, col:16> 'const vector<bool, 2>':'const vector<bool, 2>' lvalue vectorcomponent xy
  118. | `-DeclRefExpr <col:13> 'const bool4':'const vector<bool, 4>' lvalue Var 'b4' 'const bool4':'const vector<bool, 4>'
  119. |-ImplicitCastExpr <col:21, col:24> 'vector<float, 2>':'vector<float, 2>' <LValueToRValue>
  120. | `-HLSLVectorElementExpr <col:21, col:24> 'vector<float, 2>':'vector<float, 2>' lvalue vectorcomponent xy
  121. | `-DeclRefExpr <col:21> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  122. `-ImplicitCastExpr <col:29, col:39> 'vector<float, 2>':'vector<float, 2>' <HLSLVectorTruncationCast>
  123. `-ParenExpr <col:29, col:39> 'float4':'vector<float, 4>'
  124. `-BinaryOperator <col:30, col:35> 'float4':'vector<float, 4>' '+'
  125. |-ImplicitCastExpr <col:30> 'float4':'vector<float, 4>' <LValueToRValue>
  126. | `-DeclRefExpr <col:30> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  127. `-ImplicitCastExpr <col:35> 'vector<float, 4>':'vector<float, 4>' <HLSLVectorSplat>
  128. `-FloatingLiteral <col:35> 'float' 1.000000e+00
  129. */
  130. acc += b4 ? v0.xy : 1.0F; /* expected-error {{conditional operator condition and result dimensions mismatch.}} fxc-error {{X3017: cannot implicitly convert from 'float2' to 'float4'}} */
  131. acc += b4 ? v0.xy : (v0 + 1.0F); /* expected-error {{conditional operator condition and result dimensions mismatch.}} fxc-error {{X3017: cannot implicitly convert from 'float2' to 'const float4'}} */
  132. acc += b4.xy ? v0 : (v0 + 1.0F); /* expected-error {{conditional operator condition and result dimensions mismatch.}} fxc-error {{X3020: dimension of conditional does not match value}} */
  133. acc += b4.xy ? v0 : (v0.xy + 1.0F); /* expected-error {{cannot convert from 'vector<float, 2>' to 'float4'}} expected-warning {{implicit truncation of vector type}} fxc-error {{X3017: cannot implicitly convert from 'const float2' to 'float4'}} fxc-warning {{X3206: implicit truncation of vector type}} */
  134. // lit float/int
  135. acc += b4 ? v0 : 1.1;
  136. /*verify-ast
  137. CompoundAssignOperator <col:3, col:20> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
  138. |-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  139. `-ConditionalOperator <col:10, col:20> 'vector<float, 4>'
  140. |-ImplicitCastExpr <col:10> 'const bool4':'const vector<bool, 4>' <LValueToRValue>
  141. | `-DeclRefExpr <col:10> 'const bool4':'const vector<bool, 4>' lvalue Var 'b4' 'const bool4':'const vector<bool, 4>'
  142. |-ImplicitCastExpr <col:15> 'float4':'vector<float, 4>' <LValueToRValue>
  143. | `-DeclRefExpr <col:15> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  144. `-ImplicitCastExpr <col:20> 'vector<float, 4>':'vector<float, 4>' <HLSLVectorSplat>
  145. `-ImplicitCastExpr <col:20> 'float' <FloatingCast>
  146. `-FloatingLiteral <col:20> 'literal float' 1.100000e+00
  147. */
  148. acc += b4 ? v0 : -2;
  149. /*verify-ast
  150. CompoundAssignOperator <col:3, col:21> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
  151. |-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  152. `-ConditionalOperator <col:10, col:21> 'vector<float, 4>'
  153. |-ImplicitCastExpr <col:10> 'const bool4':'const vector<bool, 4>' <LValueToRValue>
  154. | `-DeclRefExpr <col:10> 'const bool4':'const vector<bool, 4>' lvalue Var 'b4' 'const bool4':'const vector<bool, 4>'
  155. |-ImplicitCastExpr <col:15> 'float4':'vector<float, 4>' <LValueToRValue>
  156. | `-DeclRefExpr <col:15> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  157. `-ImplicitCastExpr <col:20, col:21> 'vector<float, 4>':'vector<float, 4>' <HLSLVectorSplat>
  158. `-ImplicitCastExpr <col:20, col:21> 'float' <IntegralToFloating>
  159. `-UnaryOperator <col:20, col:21> 'literal int' prefix '-'
  160. `-IntegerLiteral <col:21> 'literal int' 2
  161. */
  162. min16float4 mf4 = (min16float4)acc * (min16float4)v0;
  163. mf4 += b4 ? v0 : mf4; /* expected-warning {{conversion from larger type 'vector<float, 4>' to smaller type 'min16float4', possible loss of data}} fxc-warning {{X3205: conversion from larger type to smaller, possible loss of data}} */
  164. /*verify-ast
  165. CompoundAssignOperator <col:3, col:20> 'min16float4':'vector<min16float, 4>' lvalue '+=' ComputeLHSTy='vector<float, 4>':'vector<float, 4>' ComputeResultTy='vector<float, 4>':'vector<float, 4>'
  166. |-DeclRefExpr <col:3> 'min16float4':'vector<min16float, 4>' lvalue Var 'mf4' 'min16float4':'vector<min16float, 4>'
  167. `-ConditionalOperator <col:10, col:20> 'vector<float, 4>'
  168. |-ImplicitCastExpr <col:10> 'const bool4':'const vector<bool, 4>' <LValueToRValue>
  169. | `-DeclRefExpr <col:10> 'const bool4':'const vector<bool, 4>' lvalue Var 'b4' 'const bool4':'const vector<bool, 4>'
  170. |-ImplicitCastExpr <col:15> 'float4':'vector<float, 4>' <LValueToRValue>
  171. | `-DeclRefExpr <col:15> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  172. `-ImplicitCastExpr <col:20> 'vector<float, 4>' <HLSLCC_FloatingCast>
  173. `-ImplicitCastExpr <col:20> 'min16float4':'vector<min16float, 4>' <LValueToRValue>
  174. `-DeclRefExpr <col:20> 'min16float4':'vector<min16float, 4>' lvalue Var 'mf4' 'min16float4':'vector<min16float, 4>'
  175. */
  176. acc += b4 ? v0 : mf4;
  177. /*verify-ast
  178. CompoundAssignOperator <col:3, col:20> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
  179. |-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  180. `-ConditionalOperator <col:10, col:20> 'vector<float, 4>'
  181. |-ImplicitCastExpr <col:10> 'const bool4':'const vector<bool, 4>' <LValueToRValue>
  182. | `-DeclRefExpr <col:10> 'const bool4':'const vector<bool, 4>' lvalue Var 'b4' 'const bool4':'const vector<bool, 4>'
  183. |-ImplicitCastExpr <col:15> 'float4':'vector<float, 4>' <LValueToRValue>
  184. | `-DeclRefExpr <col:15> 'float4':'vector<float, 4>' lvalue ParmVar 'v0' 'float4':'vector<float, 4>'
  185. `-ImplicitCastExpr <col:20> 'vector<float, 4>' <HLSLCC_FloatingCast>
  186. `-ImplicitCastExpr <col:20> 'min16float4':'vector<min16float, 4>' <LValueToRValue>
  187. `-DeclRefExpr <col:20> 'min16float4':'vector<min16float, 4>' lvalue Var 'mf4' 'min16float4':'vector<min16float, 4>'
  188. */
  189. Texture2D T;
  190. Select(T);
  191. acc += T.Sample(S, v0.xy);
  192. // Texture object as condition
  193. acc += T ? v0 : (v0 + 1.0F); /* expected-error {{conditional operator only supports condition with scalar, vector, or matrix types convertable to bool.}} fxc-error {{X3020: conditional must be numeric}} */
  194. Texture2D TOut1 = T1;
  195. Texture2D TOut2 = T2;
  196. // fxc doesn't like this because ?: results in RValue:
  197. Select(b4.y ? TOut1 : TOut2); /* expected-error {{no matching function for call to 'Select'}} fxc-error {{X3025: out parameters require l-value arguments}} */
  198. acc += TOut1.Sample(S, v0.xy);
  199. acc += TOut2.Sample(S, v0.xy);
  200. // Matrix ternary support:
  201. acc += mul(acc, b4x4 ? m1 : m2);
  202. /*verify-ast
  203. CompoundAssignOperator <col:3, col:33> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='float4':'vector<float, 4>' ComputeResultTy='float4':'vector<float, 4>'
  204. |-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  205. `-CallExpr <col:10, col:33> 'vector<float, 4>':'vector<float, 4>'
  206. |-ImplicitCastExpr <col:10> 'vector<float, 4> (*)(vector<float, 4>, matrix<float, 4, 4>)' <FunctionToPointerDecay>
  207. | `-DeclRefExpr <col:10> 'vector<float, 4> (vector<float, 4>, matrix<float, 4, 4>)' lvalue Function 'mul' 'vector<float, 4> (vector<float, 4>, matrix<float, 4, 4>)'
  208. |-ImplicitCastExpr <col:14> 'float4':'vector<float, 4>' <LValueToRValue>
  209. | `-DeclRefExpr <col:14> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  210. `-ConditionalOperator <col:19, col:31> 'matrix<float, 4, 4>'
  211. |-ImplicitCastExpr <col:19> 'const bool4x4':'const matrix<bool, 4, 4>' <LValueToRValue>
  212. | `-DeclRefExpr <col:19> 'const bool4x4':'const matrix<bool, 4, 4>' lvalue Var 'b4x4' 'const bool4x4':'const matrix<bool, 4, 4>'
  213. |-ImplicitCastExpr <col:26> 'const float4x4':'const matrix<float, 4, 4>' <LValueToRValue>
  214. | `-DeclRefExpr <col:26> 'const float4x4':'const matrix<float, 4, 4>' lvalue Var 'm1' 'const float4x4':'const matrix<float, 4, 4>'
  215. `-ImplicitCastExpr <col:31> 'const float4x4':'const matrix<float, 4, 4>' <LValueToRValue>
  216. `-DeclRefExpr <col:31> 'const float4x4':'const matrix<float, 4, 4>' lvalue Var 'm2' 'const float4x4':'const matrix<float, 4, 4>'
  217. */
  218. // float : double and matrix : scalar
  219. acc += mul(acc, b4x4 ? m1 : (double)1.0); /* expected-warning {{conversion from larger type 'vector<double, 4>' to smaller type 'float4', possible loss of data}} fxc-warning {{X3205: conversion from larger type to smaller, possible loss of data}} */
  220. /*verify-ast
  221. CompoundAssignOperator <col:3, col:42> 'float4':'vector<float, 4>' lvalue '+=' ComputeLHSTy='vector<double, 4>':'vector<double, 4>' ComputeResultTy='vector<double, 4>':'vector<double, 4>'
  222. |-DeclRefExpr <col:3> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  223. `-CallExpr <col:10, col:42> 'vector<double, 4>':'vector<double, 4>'
  224. |-ImplicitCastExpr <col:10> 'vector<double, 4> (*)(vector<double, 4>, matrix<double, 4, 4>)' <FunctionToPointerDecay>
  225. | `-DeclRefExpr <col:10> 'vector<double, 4> (vector<double, 4>, matrix<double, 4, 4>)' lvalue Function 'mul' 'vector<double, 4> (vector<double, 4>, matrix<double, 4, 4>)'
  226. |-ImplicitCastExpr <col:14> 'vector<double, 4>' <HLSLCC_FloatingCast>
  227. | `-ImplicitCastExpr <col:14> 'float4':'vector<float, 4>' <LValueToRValue>
  228. | `-DeclRefExpr <col:14> 'float4':'vector<float, 4>' lvalue Var 'acc' 'float4':'vector<float, 4>'
  229. `-ConditionalOperator <col:19, col:39> 'matrix<double, 4, 4>'
  230. |-ImplicitCastExpr <col:19> 'const bool4x4':'const matrix<bool, 4, 4>' <LValueToRValue>
  231. | `-DeclRefExpr <col:19> 'const bool4x4':'const matrix<bool, 4, 4>' lvalue Var 'b4x4' 'const bool4x4':'const matrix<bool, 4, 4>'
  232. |-ImplicitCastExpr <col:26> 'matrix<double, 4, 4>' <HLSLCC_FloatingCast>
  233. | `-ImplicitCastExpr <col:26> 'const float4x4':'const matrix<float, 4, 4>' <LValueToRValue>
  234. | `-DeclRefExpr <col:26> 'const float4x4':'const matrix<float, 4, 4>' lvalue Var 'm1' 'const float4x4':'const matrix<float, 4, 4>'
  235. `-ImplicitCastExpr <col:31, col:39> 'matrix<double, 4, 4>':'matrix<double, 4, 4>' <HLSLMatrixSplat>
  236. `-CStyleCastExpr <col:31, col:39> 'double' <NoOp>
  237. `-ImplicitCastExpr <col:39> 'double' <FloatingCast>
  238. `-FloatingLiteral <col:39> 'literal float' 1.000000e+00
  239. */
  240. // Truncation to condition size not supported:
  241. acc.xyz += (b3x3 ? m1 : m2)[1]; /* expected-error {{conditional operator condition and result dimensions mismatch.}} fxc-error {{X3020: dimension of conditional does not match value}} */
  242. // fxc doesn't like UDT's in a ternary operator. It results in:
  243. // internal error: assertion failed! onecoreuap\windows\directx\dxg\d3d12\compiler\tok\types.cpp(1460): pLeft->CollectInfo(AR_TINFO_SIMPLE_OBJECTS, &LeftInfo) && pRight->CollectInfo(AR_TINFO_SIMPLE_OBJECTS, &RightInfo)
  244. // error X3020: type mismatch between conditional values
  245. UDT3 lu3 = (UDT3)0;
  246. lu3 = b4.x ? u3 : u3; /* expected-error {{conditional operator only supports results with numeric scalar, vector, or matrix types.}} fxc-error {{X3020: type mismatch between conditional values}} */
  247. lu3 += b4.x ? u1 : u1b; /* expected-error {{conditional operator only supports results with numeric scalar, vector, or matrix types.}} fxc-error {{X3020: type mismatch between conditional values}} */
  248. lu3 += b4.x ? u1 : u2; /* expected-error {{conditional operator only supports results with numeric scalar, vector, or matrix types.}} fxc-error {{X3020: type mismatch between conditional values}} */
  249. lu3 += ((bool4x2)b4x4) ? u1 : u2; /* expected-error {{conditional operator only supports results with numeric scalar, vector, or matrix types.}} fxc-error {{X3020: type mismatch between conditional values}} */
  250. acc += float4(lu3.a, lu3.b, lu3.c.xy);
  251. acc += float4(lu3.c.z, lu3.d.xyz);
  252. // Same problem with arrays:
  253. acc += (b4.x ? a1 : a2)[0]; /* expected-error {{conditional operator only supports results with numeric scalar, vector, or matrix types.}} fxc-error {{X3020: type mismatch between conditional values}} */
  254. acc += (b4.x ? a1 : a3)[0]; /* expected-error {{conditional operator only supports results with numeric scalar, vector, or matrix types.}} fxc-error {{X3020: type mismatch between conditional values}} */
  255. acc += (b4.x ? a1 : a4)[0]; /* expected-error {{conditional operator only supports results with numeric scalar, vector, or matrix types.}} fxc-error {{X3020: type mismatch between conditional values}} */
  256. return acc;
  257. }