Преглед на файлове

Fix crash for vector smoothstep.

Xiang Li преди 7 години
родител
ревизия
3bfa9960a8
променени са 2 файла, в които са добавени 10 реда и са изтрити 5 реда
  1. 1 5
      lib/HLSL/HLOperationLower.cpp
  2. 9 0
      tools/clang/test/CodeGenHLSL/quick-test/vec_smooth_step.hlsl

+ 1 - 5
lib/HLSL/HLOperationLower.cpp

@@ -1939,11 +1939,7 @@ Value *TranslateSmoothStep(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
   // return s * s *(3-2*s).
   Constant *c2 = ConstantFP::get(CI->getType(),2);
   Constant *c3 = ConstantFP::get(CI->getType(),3);
-  if (s->getType()->isVectorTy()) {
-    unsigned vecSize = s->getType()->getVectorNumElements();
-    c2 = ConstantVector::getSplat(vecSize, c2);
-    c3 = ConstantVector::getSplat(vecSize, c3);
-  }
+
   Value *sMul2 = Builder.CreateFMul(s, c2);
   Value *result = Builder.CreateFSub(c3, sMul2);
   result = Builder.CreateFMul(s, result);

+ 9 - 0
tools/clang/test/CodeGenHLSL/quick-test/vec_smooth_step.hlsl

@@ -0,0 +1,9 @@
+// RUN: %dxc -T ps_6_0 -E main %s | FileCheck %s
+
+// Make sure use vector smoothstep works.
+// CHECK: Saturate
+
+float2 main(float2 a : A) : SV_TARGET
+{
+  return smoothstep(a, 1.2,1.6);
+}