|
@@ -1905,23 +1905,6 @@ Value *TranslateFWidth(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
|
|
return Builder.CreateFAdd(absDdx, absDdy);
|
|
return Builder.CreateFAdd(absDdx, absDdy);
|
|
}
|
|
}
|
|
|
|
|
|
-Value *TranslateNormalize(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
|
|
|
|
- HLOperationLowerHelper &helper, HLObjectOperationLowerHelper *pObjHelper, bool &Translated) {
|
|
|
|
- hlsl::OP *hlslOP = &helper.hlslOP;
|
|
|
|
- Type *Ty = CI->getType();
|
|
|
|
- Value *op = CI->getArgOperand(HLOperandIndex::kUnaryOpSrc0Idx);
|
|
|
|
- IRBuilder<> Builder(CI);
|
|
|
|
- Value *length = TranslateLength(CI, op, hlslOP);
|
|
|
|
- if (Ty != length->getType()) {
|
|
|
|
- VectorType *VT = cast<VectorType>(Ty);
|
|
|
|
- Value *vecLength = UndefValue::get(VT);
|
|
|
|
- for (unsigned i = 0; i < VT->getNumElements(); i++)
|
|
|
|
- vecLength = Builder.CreateInsertElement(vecLength, length, i);
|
|
|
|
- length = vecLength;
|
|
|
|
- }
|
|
|
|
- return Builder.CreateFDiv(op, length);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
Value *TranslateLerp(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
|
|
Value *TranslateLerp(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
|
|
HLOperationLowerHelper &helper, HLObjectOperationLowerHelper *pObjHelper, bool &Translated) {
|
|
HLOperationLowerHelper &helper, HLObjectOperationLowerHelper *pObjHelper, bool &Translated) {
|
|
// x + s(y-x)
|
|
// x + s(y-x)
|
|
@@ -2019,6 +2002,30 @@ Value *TranslateDot(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Value *TranslateNormalize(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
|
|
|
|
+ HLOperationLowerHelper &helper,
|
|
|
|
+ HLObjectOperationLowerHelper *pObjHelper,
|
|
|
|
+ bool &Translated) {
|
|
|
|
+ hlsl::OP *hlslOP = &helper.hlslOP;
|
|
|
|
+ Type *Ty = CI->getType();
|
|
|
|
+ Value *op = CI->getArgOperand(HLOperandIndex::kUnaryOpSrc0Idx);
|
|
|
|
+ VectorType *VT = cast<VectorType>(Ty);
|
|
|
|
+ unsigned vecSize = VT->getNumElements();
|
|
|
|
+
|
|
|
|
+ IRBuilder<> Builder(CI);
|
|
|
|
+ Value *dot = TranslateFDot(op, op, vecSize, hlslOP, Builder);
|
|
|
|
+ DXIL::OpCode rsqrtOp = DXIL::OpCode::Rsqrt;
|
|
|
|
+ Function *dxilRsqrt = hlslOP->GetOpFunc(rsqrtOp, VT->getElementType());
|
|
|
|
+ Value *rsqrt = Builder.CreateCall(
|
|
|
|
+ dxilRsqrt, {hlslOP->GetI32Const((unsigned)rsqrtOp), dot},
|
|
|
|
+ hlslOP->GetOpCodeName(rsqrtOp));
|
|
|
|
+ Value *vecRsqrt = UndefValue::get(VT);
|
|
|
|
+ for (unsigned i = 0; i < VT->getNumElements(); i++)
|
|
|
|
+ vecRsqrt = Builder.CreateInsertElement(vecRsqrt, rsqrt, i);
|
|
|
|
+
|
|
|
|
+ return Builder.CreateFMul(op, vecRsqrt);
|
|
|
|
+}
|
|
|
|
+
|
|
Value *TranslateReflect(CallInst *CI, IntrinsicOp IOP, OP::OpCode op,
|
|
Value *TranslateReflect(CallInst *CI, IntrinsicOp IOP, OP::OpCode op,
|
|
HLOperationLowerHelper &helper, HLObjectOperationLowerHelper *pObjHelper, bool &Translated) {
|
|
HLOperationLowerHelper &helper, HLObjectOperationLowerHelper *pObjHelper, bool &Translated) {
|
|
hlsl::OP *hlslOP = &helper.hlslOP;
|
|
hlsl::OP *hlslOP = &helper.hlslOP;
|