HLSL writer: Translate the built-in function "mix" into "lerp"

The built-in function "mix" in WGSL should be translated into the
intrinsic function "lerp" in HLSL according to the HLSL document.

With this patch the dawn sample CubeReflection will be able to run
correctly with tint generator on D3D12 backend.

Bug: tint:758
Change-Id: I7e84987c02fd2090d5e7af8f4aba995fc95a6fdb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49601
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Zhaoming Jiang 2021-04-30 08:47:06 +00:00 committed by Commit Bot service account
parent e08cc15dd9
commit 30c03a5d50
2 changed files with 4 additions and 1 deletions

View File

@ -1179,7 +1179,6 @@ std::string GeneratorImpl::generate_builtin_name(
case sem::IntrinsicType::kTan:
case sem::IntrinsicType::kTanh:
case sem::IntrinsicType::kTrunc:
case sem::IntrinsicType::kMix:
case sem::IntrinsicType::kSign:
case sem::IntrinsicType::kAbs:
case sem::IntrinsicType::kMax:
@ -1231,6 +1230,9 @@ std::string GeneratorImpl::generate_builtin_name(
case sem::IntrinsicType::kIsNan:
out = "isnan";
break;
case sem::IntrinsicType::kMix:
out = "lerp";
break;
case sem::IntrinsicType::kReverseBits:
out = "reversebits";
break;

View File

@ -230,6 +230,7 @@ INSTANTIATE_TEST_SUITE_P(
IntrinsicData{IntrinsicType::kMax, ParamType::kU32, "max"},
IntrinsicData{IntrinsicType::kMin, ParamType::kF32, "min"},
IntrinsicData{IntrinsicType::kMin, ParamType::kU32, "min"},
IntrinsicData{IntrinsicType::kMix, ParamType::kF32, "lerp"},
IntrinsicData{IntrinsicType::kNormalize, ParamType::kF32, "normalize"},
IntrinsicData{IntrinsicType::kPow, ParamType::kF32, "pow"},
IntrinsicData{IntrinsicType::kReflect, ParamType::kF32, "reflect"},