Updated type conversion rules for HLSL frontend

This commit is contained in:
t.jung 2018-11-13 17:11:03 +01:00
parent 7274bbc27c
commit 8279f0728a
6 changed files with 3443 additions and 7 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,190 @@
#define zeros 0
#define zeros1 0
#define zeros2 0, 0
#define zeros3 0, 0, 0
#define zeros4 0, 0, 0, 0
#define zeros5 0, 0, 0, 0, 0
#define zeros6 0, 0, 0, 0, 0, 0
#define zeros7 0, 0, 0, 0, 0, 0, 0
#define zeros8 0, 0, 0, 0, 0, 0, 0, 0
#define zeros9 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros10 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros11 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros12 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros13 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros14 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros15 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros16 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
float4 main() : SV_Target {
float var0 = float(zeros1);
float2 var13 = float(zeros1);
float2 var14 = float2(zeros2);
float3 var26 = float(zeros1);
float3 var28 = float3(zeros3);
float4 var39 = float(zeros1);
float4 var42 = float4(zeros4);
float4 var43 = float2x2(zeros4);
float2x2 var52 = float(zeros1);
float2x2 var55 = float4(zeros4);
float2x2 var56 = float2x2(zeros4);
float2x3 var65 = float(zeros1);
float2x3 var70 = float2x3(zeros6);
float2x4 var78 = float(zeros1);
float2x4 var84 = float2x4(zeros8);
float3x2 var91 = float(zeros1);
float3x2 var98 = float3x2(zeros6);
float3x3 var104 = float(zeros1);
float3x3 var112 = float3x3(zeros9);
float3x4 var117 = float(zeros1);
float3x4 var126 = float3x4(zeros12);
float4x2 var130 = float(zeros1);
float4x2 var140 = float4x2(zeros8);
float4x3 var143 = float(zeros1);
float4x3 var154 = float4x3(zeros12);
float4x4 var156 = float(zeros1);
float4x4 var168 = float4x4(zeros16);
float var1 = float2(zeros2);// warning X3206: implicit truncation of vector type
float var2 = float3(zeros3);// warning X3206: implicit truncation of vector type
float var3 = float4(zeros4);// warning X3206: implicit truncation of vector type
float var4 = float2x2(zeros4);// warning X3206: implicit truncation of vector type
float var5 = float2x3(zeros6);// warning X3206: implicit truncation of vector type
float var6 = float2x4(zeros8);// warning X3206: implicit truncation of vector type
float var7 = float3x2(zeros6);// warning X3206: implicit truncation of vector type
float var8 = float3x3(zeros9);// warning X3206: implicit truncation of vector type
float var9 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float var10 = float4x2(zeros8);// warning X3206: implicit truncation of vector type
float var11 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float var12 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float2 var15 = float3(zeros3);// warning X3206: implicit truncation of vector type
float2 var16 = float4(zeros4);// warning X3206: implicit truncation of vector type
float3 var29 = float4(zeros4);// warning X3206: implicit truncation of vector type
float2x2 var57 = float2x3(zeros6);// warning X3206: implicit truncation of vector type
float2x2 var58 = float2x4(zeros8);// warning X3206: implicit truncation of vector type
float2x2 var59 = float3x2(zeros6);// warning X3206: implicit truncation of vector type
float2x2 var60 = float3x3(zeros9);// warning X3206: implicit truncation of vector type
float2x2 var61 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float2x2 var62 = float4x2(zeros8);// warning X3206: implicit truncation of vector type
float2x2 var63 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float2x2 var64 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float2x3 var71 = float2x4(zeros8);// warning X3206: implicit truncation of vector type
float2x3 var73 = float3x3(zeros9);// warning X3206: implicit truncation of vector type
float2x3 var74 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float2x3 var76 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float2x3 var77 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float2x4 var87 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float2x4 var90 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float3x2 var99 = float3x3(zeros9);// warning X3206: implicit truncation of vector type
float3x2 var100 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float3x2 var101 = float4x2(zeros8);// warning X3206: implicit truncation of vector type
float3x2 var102 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float3x2 var103 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float3x3 var113 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float3x3 var115 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float3x3 var116 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float3x4 var129 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float4x2 var141 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float4x2 var142 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float4x3 var155 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float2 var17 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float2'
float2 var18 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float2'
float2 var19 = float2x4(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x4' to 'float2'
float2 var20 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float2'
float2 var21 = float3x3(zeros9);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x3' to 'float2'
float2 var22 = float3x4(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x4' to 'float2'
float2 var23 = float4x2(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x2' to 'float2'
float2 var24 = float4x3(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x3' to 'float2'
float2 var25 = float4x4(zeros16);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x4' to 'float2'
float3 var27 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float3'
float3 var30 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float3'
float3 var31 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float3'
float3 var32 = float2x4(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x4' to 'float3'
float3 var33 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float3'
float3 var34 = float3x3(zeros9);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x3' to 'float3'
float3 var35 = float3x4(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x4' to 'float3'
float3 var36 = float4x2(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x2' to 'float3'
float3 var37 = float4x3(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x3' to 'float3'
float3 var38 = float4x4(zeros16);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x4' to 'float3'
float4 var40 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float4'
float4 var41 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float4'
float4 var44 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float4'
float4 var45 = float2x4(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x4' to 'float4'
float4 var46 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float4'
float4 var47 = float3x3(zeros9);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x3' to 'float4'
float4 var48 = float3x4(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x4' to 'float4'
float4 var49 = float4x2(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x2' to 'float4'
float4 var50 = float4x3(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x3' to 'float4'
float4 var51 = float4x4(zeros16);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x4' to 'float4'
float2x2 var53 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float2x2'
float2x2 var54 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float2x2'
float2x3 var66 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float2x3'
float2x3 var67 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float2x3'
float2x3 var68 = float4(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4' to 'float2x3'
float2x3 var69 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float2x3'
float2x3 var72 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float2x3'
float2x3 var75 = float4x2(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x2' to 'float2x3'
float2x4 var79 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float2x4'
float2x4 var80 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float2x4'
float2x4 var81 = float4(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4' to 'float2x4'
float2x4 var82 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float2x4'
float2x4 var83 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float2x4'
float2x4 var85 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float2x4'
float2x4 var86 = float3x3(zeros9);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x3' to 'float2x4'
float2x4 var88 = float4x2(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x2' to 'float2x4'
float2x4 var89 = float4x3(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x3' to 'float2x4'
float3x2 var92 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float3x2'
float3x2 var93 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float3x2'
float3x2 var94 = float4(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4' to 'float3x2'
float3x2 var95 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float3x2'
float3x2 var96 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float3x2'
float3x2 var97 = float2x4(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x4' to 'float3x2'
float3x3 var105 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float3x3'
float3x3 var106 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float3x3'
float3x3 var107 = float4(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4' to 'float3x3'
float3x3 var108 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float3x3'
float3x3 var109 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float3x3'
float3x3 var110 = float2x4(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x4' to 'float3x3'
float3x3 var111 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float3x3'
float3x3 var114 = float4x2(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x2' to 'float3x3'
float3x4 var118 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float3x4'
float3x4 var119 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float3x4'
float3x4 var120 = float4(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4' to 'float3x4'
float3x4 var121 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float3x4'
float3x4 var122 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float3x4'
float3x4 var123 = float2x4(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x4' to 'float3x4'
float3x4 var124 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float3x4'
float3x4 var125 = float3x3(zeros9);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x3' to 'float3x4'
float3x4 var127 = float4x2(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x2' to 'float3x4'
float3x4 var128 = float4x3(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x3' to 'float3x4'
float4x2 var131 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float4x2'
float4x2 var132 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float4x2'
float4x2 var133 = float4(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4' to 'float4x2'
float4x2 var134 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float4x2'
float4x2 var135 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float4x2'
float4x2 var136 = float2x4(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x4' to 'float4x2'
float4x2 var137 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float4x2'
float4x2 var138 = float3x3(zeros9);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x3' to 'float4x2'
float4x2 var139 = float3x4(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x4' to 'float4x2'
float4x3 var144 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float4x3'
float4x3 var145 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float4x3'
float4x3 var146 = float4(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4' to 'float4x3'
float4x3 var147 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float4x3'
float4x3 var148 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float4x3'
float4x3 var149 = float2x4(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x4' to 'float4x3'
float4x3 var150 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float4x3'
float4x3 var151 = float3x3(zeros9);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x3' to 'float4x3'
float4x3 var152 = float3x4(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x4' to 'float4x3'
float4x3 var153 = float4x2(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x2' to 'float4x3'
float4x4 var157 = float2(zeros2);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2' to 'float4x4'
float4x4 var158 = float3(zeros3);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3' to 'float4x4'
float4x4 var159 = float4(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4' to 'float4x4'
float4x4 var160 = float2x2(zeros4);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x2' to 'float4x4'
float4x4 var161 = float2x3(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x3' to 'float4x4'
float4x4 var162 = float2x4(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float2x4' to 'float4x4'
float4x4 var163 = float3x2(zeros6);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x2' to 'float4x4'
float4x4 var164 = float3x3(zeros9);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x3' to 'float4x4'
float4x4 var165 = float3x4(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float3x4' to 'float4x4'
float4x4 var166 = float4x2(zeros8);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x2' to 'float4x4'
float4x4 var167 = float4x3(zeros12);// Compilation failed because: error X3017: cannot implicitly convert from 'const float4x3' to 'float4x4'
return 0;
}

View File

@ -0,0 +1,90 @@
#define zeros 0
#define zeros1 0
#define zeros2 0, 0
#define zeros3 0, 0, 0
#define zeros4 0, 0, 0, 0
#define zeros5 0, 0, 0, 0, 0
#define zeros6 0, 0, 0, 0, 0, 0
#define zeros7 0, 0, 0, 0, 0, 0, 0
#define zeros8 0, 0, 0, 0, 0, 0, 0, 0
#define zeros9 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros10 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros11 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros12 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros13 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros14 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros15 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define zeros16 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
float4 main() : SV_Target {
float var0 = float(zeros1);
float2 var13 = float(zeros1);
float2 var14 = float2(zeros2);
float3 var26 = float(zeros1);
float3 var28 = float3(zeros3);
float4 var39 = float(zeros1);
float4 var42 = float4(zeros4);
float4 var43 = float2x2(zeros4);
float2x2 var52 = float(zeros1);
float2x2 var55 = float4(zeros4);
float2x2 var56 = float2x2(zeros4);
float2x3 var65 = float(zeros1);
float2x3 var70 = float2x3(zeros6);
float2x4 var78 = float(zeros1);
float2x4 var84 = float2x4(zeros8);
float3x2 var91 = float(zeros1);
float3x2 var98 = float3x2(zeros6);
float3x3 var104 = float(zeros1);
float3x3 var112 = float3x3(zeros9);
float3x4 var117 = float(zeros1);
float3x4 var126 = float3x4(zeros12);
float4x2 var130 = float(zeros1);
float4x2 var140 = float4x2(zeros8);
float4x3 var143 = float(zeros1);
float4x3 var154 = float4x3(zeros12);
float4x4 var156 = float(zeros1);
float4x4 var168 = float4x4(zeros16);
float var1 = float2(zeros2);// warning X3206: implicit truncation of vector type
float var2 = float3(zeros3);// warning X3206: implicit truncation of vector type
float var3 = float4(zeros4);// warning X3206: implicit truncation of vector type
float var4 = float2x2(zeros4);// warning X3206: implicit truncation of vector type
float var5 = float2x3(zeros6);// warning X3206: implicit truncation of vector type
float var6 = float2x4(zeros8);// warning X3206: implicit truncation of vector type
float var7 = float3x2(zeros6);// warning X3206: implicit truncation of vector type
float var8 = float3x3(zeros9);// warning X3206: implicit truncation of vector type
float var9 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float var10 = float4x2(zeros8);// warning X3206: implicit truncation of vector type
float var11 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float var12 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float2 var15 = float3(zeros3);// warning X3206: implicit truncation of vector type
float2 var16 = float4(zeros4);// warning X3206: implicit truncation of vector type
float3 var29 = float4(zeros4);// warning X3206: implicit truncation of vector type
float2x2 var57 = float2x3(zeros6);// warning X3206: implicit truncation of vector type
float2x2 var58 = float2x4(zeros8);// warning X3206: implicit truncation of vector type
float2x2 var59 = float3x2(zeros6);// warning X3206: implicit truncation of vector type
float2x2 var60 = float3x3(zeros9);// warning X3206: implicit truncation of vector type
float2x2 var61 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float2x2 var62 = float4x2(zeros8);// warning X3206: implicit truncation of vector type
float2x2 var63 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float2x2 var64 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float2x3 var71 = float2x4(zeros8);// warning X3206: implicit truncation of vector type
float2x3 var73 = float3x3(zeros9);// warning X3206: implicit truncation of vector type
float2x3 var74 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float2x3 var76 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float2x3 var77 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float2x4 var87 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float2x4 var90 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float3x2 var99 = float3x3(zeros9);// warning X3206: implicit truncation of vector type
float3x2 var100 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float3x2 var101 = float4x2(zeros8);// warning X3206: implicit truncation of vector type
float3x2 var102 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float3x2 var103 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float3x3 var113 = float3x4(zeros12);// warning X3206: implicit truncation of vector type
float3x3 var115 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float3x3 var116 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float3x4 var129 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float4x2 var141 = float4x3(zeros12);// warning X3206: implicit truncation of vector type
float4x2 var142 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
float4x3 var155 = float4x4(zeros16);// warning X3206: implicit truncation of vector type
return 0;
}

View File

@ -1119,9 +1119,12 @@ void TIntermediate::addBiShapeConversion(TOperator op, TIntermTyped*& lhsNode, T
rhsNode = addUniShapeConversion(op, lhsNode->getType(), rhsNode);
return;
case EOpMul:
// matrix multiply does not change shapes
if (lhsNode->isMatrix() && rhsNode->isMatrix())
return;
case EOpAdd:
case EOpSub:
case EOpMul:
case EOpDiv:
// want to support vector * scalar native ops in AST and lower, not smear, similarly for
// matrix * vector, etc.
@ -1194,9 +1197,19 @@ TIntermTyped* TIntermediate::addShapeConversion(const TType& type, TIntermTyped*
// The new node that handles the conversion
TOperator constructorOp = mapTypeToConstructorOp(type);
// HLSL has custom semantics for scalar->mat shape conversions.
if (source == EShSourceHlsl) {
if (node->getType().isScalarOrVec1() && type.isMatrix()) {
// HLSL rules for scalar, vector and matrix conversions:
// 1) scalar can become anything, initializing every component with its value
// 2) vector and matrix can become scalar, first element is used (warning: truncation)
// 3) matrix can become matrix with less rows and/or columns (warning: truncation)
// 4) vector can become vector with less rows size (warning: truncation)
// 5a) vector 4 can become 2x2 matrix (special case) (same packing layout, its a reinterpret)
// 5b) 2x2 matrix can become vector 4 (special case) (same packing layout, its a reinterpret)
const TType &sourceType = node->getType();
// rule 1 for scalar to matrix is special
if (sourceType.isScalarOrVec1() && type.isMatrix()) {
// HLSL semantics: the scalar (or vec1) is replicated to every component of the matrix. Left to its
// own devices, the constructor from a scalar would populate the diagonal. This forces replication
@ -1204,7 +1217,7 @@ TIntermTyped* TIntermediate::addShapeConversion(const TType& type, TIntermTyped*
// Note that if the node is complex (e.g, a function call), we don't want to duplicate it here
// repeatedly, so we copy it to a temp, then use the temp.
const int matSize = type.getMatrixRows() * type.getMatrixCols();
const int matSize = type.computeNumComponents();
TIntermAggregate* rhsAggregate = new TIntermAggregate();
const bool isSimple = (node->getAsSymbolNode() != nullptr) || (node->getAsConstantUnion() != nullptr);
@ -1212,12 +1225,44 @@ TIntermTyped* TIntermediate::addShapeConversion(const TType& type, TIntermTyped*
if (!isSimple) {
assert(0); // TODO: use node replicator service when available.
}
for (int x=0; x<matSize; ++x)
for (int x = 0; x < matSize; ++x)
rhsAggregate->getSequence().push_back(node);
return setAggregateOperator(rhsAggregate, constructorOp, type, node->getLoc());
}
// rule 1 and 2
if ((sourceType.isScalar() && !type.isScalar()) || (!sourceType.isScalar() && type.isScalar()))
return setAggregateOperator(makeAggregate(node), constructorOp, type, node->getLoc());
// rule 3 and 5b
if (sourceType.isMatrix()) {
// rule 3
if (type.isMatrix()) {
if ((sourceType.getMatrixCols() != type.getMatrixCols() || sourceType.getMatrixRows() != type.getMatrixRows()) &&
sourceType.getMatrixCols() >= type.getMatrixCols() && sourceType.getMatrixRows() >= type.getMatrixRows())
return setAggregateOperator(makeAggregate(node), constructorOp, type, node->getLoc());
// rule 5b
} else if (type.isVector()) {
if (type.getVectorSize() == 4 && sourceType.getMatrixCols() == 2 && sourceType.getMatrixRows() == 2)
return setAggregateOperator(makeAggregate(node), constructorOp, type, node->getLoc());
}
}
// rule 4 and 5a
if (sourceType.isVector()) {
// rule 4
if (type.isVector())
{
if (sourceType.getVectorSize() > type.getVectorSize())
return setAggregateOperator(makeAggregate(node), constructorOp, type, node->getLoc());
// rule 5a
} else if (type.isMatrix()) {
if (sourceType.getVectorSize() == 4 && type.getMatrixCols() == 2 && type.getMatrixRows() == 2)
return setAggregateOperator(makeAggregate(node), constructorOp, type, node->getLoc());
}
}
}
// scalar -> vector or vec1 -> vector or

View File

@ -382,7 +382,8 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.typeGraphCopy.vert", "main"},
{"hlsl.typedef.frag", "PixelShaderFunction"},
{"hlsl.whileLoop.frag", "PixelShaderFunction"},
{"hlsl.void.frag", "PixelShaderFunction"}
{"hlsl.void.frag", "PixelShaderFunction"},
{"hlsl.type.type.conversion.all.frag", "main"}
}),
FileNameAsCustomTestSuffix
);
@ -399,6 +400,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.wavequery.frag", "PixelShaderFunction"},
{"hlsl.wavereduction.comp", "CSMain"},
{"hlsl.wavevote.comp", "CSMain"},
{ "hlsl.type.type.conversion.valid.frag", "main" }
}),
FileNameAsCustomTestSuffix
);