Преглед изворни кода

Fix crash in refract intrinsic lowering (#3498)

Vishal Sharma пре 4 година
родитељ
комит
6fd578cff4

+ 1 - 1
tools/clang/lib/Sema/gen_intrin_main_tables_15.h

@@ -1380,7 +1380,7 @@ static const HLSL_INTRINSIC_ARGUMENT g_Intrinsics_Args204[] =
     {"refract", AR_QUAL_OUT, 1, LITEMPLATE_VECTOR, 1, LICOMPTYPE_FLOAT_LIKE, 1, IA_C},
     {"i", AR_QUAL_IN, 1, LITEMPLATE_VECTOR, 1, LICOMPTYPE_FLOAT_LIKE, 1, IA_C},
     {"n", AR_QUAL_IN, 1, LITEMPLATE_VECTOR, 1, LICOMPTYPE_FLOAT_LIKE, 1, IA_C},
-    {"ri", AR_QUAL_IN, 3, LITEMPLATE_SCALAR, 3, LICOMPTYPE_FLOAT_LIKE, 1, 1},
+    {"ri", AR_QUAL_IN, 3, LITEMPLATE_SCALAR, 1, LICOMPTYPE_FLOAT_LIKE, 1, 1},
 };
 
 static const HLSL_INTRINSIC_ARGUMENT g_Intrinsics_Args205[] =

+ 26 - 0
tools/clang/test/HLSLFileCheck/hlsl/intrinsics/compound/refract.hlsl

@@ -0,0 +1,26 @@
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float -DTY2=float -enable-16bit-types %s | FileCheck %s
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float2 -DTY2=float -enable-16bit-types %s | FileCheck %s
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float3 -DTY2=float -enable-16bit-types %s | FileCheck %s
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=float -enable-16bit-types %s | FileCheck %s
+
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float16_t -DTY2=uint -enable-16bit-types %s | FileCheck %s
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float16_t2 -DTY2=float16_t -enable-16bit-types %s | FileCheck %s
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float16_t3 -DTY2=bool -enable-16bit-types %s | FileCheck %s
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float16_t4 -DTY2=min16float -enable-16bit-types %s | FileCheck %s
+
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float -DTY2=float16_t -enable-16bit-types %s | FileCheck %s
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float2 -DTY2=int16_t -enable-16bit-types %s | FileCheck %s
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float3 -DTY2=bool -enable-16bit-types %s | FileCheck %s
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=uint16_t -enable-16bit-types %s | FileCheck %s
+
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=uint16_t4x4 -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK_ERROR
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=uint16_t4 -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK_ERROR
+// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=float16_t2 -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK_ERROR
+// RUN: %dxc -E main -T vs_6_2 -DTY1=uint16_t4x4 -DTY2=float16_t -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK_ERROR
+
+// CHECK: define void @main()
+// CHECK_ERROR: note: candidate function not viable: no known conversion from
+
+TY1 main (TY1 a: IN0, TY1 b : IN1, TY2 c : IN2) : OUT {
+   return refract(a, b, c);
+}

+ 1 - 1
utils/hct/gen_intrin_main.txt

@@ -223,7 +223,7 @@ void [[]] ProcessTriTessFactorsMin(in float<3> RawEdgeFactors, in float<1> Insid
 $type1 [[rn]] radians(in float_like<> x);
 $type1 [[rn]] rcp(in any_float<> x) : rcp_approx;
 $type1 [[rn]] reflect(in float_like<c> i, in $type1 n);
-$type1 [[rn]] refract(in float_like<c> i, in $type1 n, in float_like ri);
+$type1 [[rn]] refract(in float_like<c> i, in $type1 n, in $match<3, 1> float_like ri);
 $type1 [[rn]] reversebits(in any_int<> x);
 $type1 [[rn]] round(in float_like<> x);
 $type1 [[rn]] rsqrt(in float_like<> x);