diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index 8e8f1ede1c..fe10b2b930 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -959,6 +959,9 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out, if (type == sem::BuiltinType::kRadians) { return EmitRadiansCall(out, expr, builtin); } + if (type == sem::BuiltinType::kSign) { + return EmitSignCall(out, call, builtin); + } if (type == sem::BuiltinType::kQuantizeToF16) { return EmitQuantizeToF16Call(out, expr, builtin); } @@ -2065,6 +2068,22 @@ bool GeneratorImpl::EmitRadiansCall(std::ostream& out, }); } +// The HLSL `sign` method always returns an `int` result (scalar or vector). In WGSL the result is +// expected to be the same type as the argument. This injects a cast to the expected WGSL result +// type after the call to `sign`. +bool GeneratorImpl::EmitSignCall(std::ostream& out, const sem::Call* call, const sem::Builtin*) { + auto* arg = call->Arguments()[0]; + if (!EmitType(out, arg->Type(), ast::AddressSpace::kNone, ast::Access::kReadWrite, "")) { + return false; + } + out << "(sign("; + if (!EmitExpression(out, arg->Declaration())) { + return false; + } + out << "))"; + return true; +} + bool GeneratorImpl::EmitQuantizeToF16Call(std::ostream& out, const ast::CallExpression* expr, const sem::Builtin* builtin) { @@ -2662,7 +2681,6 @@ std::string GeneratorImpl::generate_builtin_name(const sem::Builtin* builtin) { case sem::BuiltinType::kRefract: case sem::BuiltinType::kRound: case sem::BuiltinType::kSaturate: - case sem::BuiltinType::kSign: case sem::BuiltinType::kSin: case sem::BuiltinType::kSinh: case sem::BuiltinType::kSqrt: diff --git a/src/tint/writer/hlsl/generator_impl.h b/src/tint/writer/hlsl/generator_impl.h index 1558fa5971..76b9042952 100644 --- a/src/tint/writer/hlsl/generator_impl.h +++ b/src/tint/writer/hlsl/generator_impl.h @@ -244,6 +244,12 @@ class GeneratorImpl : public TextGenerator { bool EmitRadiansCall(std::ostream& out, const ast::CallExpression* expr, const sem::Builtin* builtin); + /// Handles generating a call to the `sign()` builtin + /// @param out the output of the expression stream + /// @param call the call semantic node + /// @param builtin the semantic information for the builtin + /// @returns true if the call expression is emitted + bool EmitSignCall(std::ostream& out, const sem::Call* call, const sem::Builtin* builtin); /// Handles generating a call to data packing builtin /// @param out the output of the expression stream /// @param expr the call expression diff --git a/src/tint/writer/hlsl/generator_impl_builtin_test.cc b/src/tint/writer/hlsl/generator_impl_builtin_test.cc index 8b5fe0704b..785e1fd9a9 100644 --- a/src/tint/writer/hlsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/hlsl/generator_impl_builtin_test.cc @@ -98,7 +98,6 @@ const ast::CallExpression* GenerateCall(BuiltinType builtin, case BuiltinType::kTan: case BuiltinType::kTanh: case BuiltinType::kTrunc: - case BuiltinType::kSign: if (type == CallParamType::kF16) { return builder->Call(str.str(), "h2"); } else { @@ -294,8 +293,6 @@ INSTANTIATE_TEST_SUITE_P( BuiltinData{BuiltinType::kPow, CallParamType::kF16, "pow"}, BuiltinData{BuiltinType::kReflect, CallParamType::kF32, "reflect"}, BuiltinData{BuiltinType::kReflect, CallParamType::kF16, "reflect"}, - BuiltinData{BuiltinType::kSign, CallParamType::kF32, "sign"}, - BuiltinData{BuiltinType::kSign, CallParamType::kF16, "sign"}, BuiltinData{BuiltinType::kSin, CallParamType::kF32, "sin"}, BuiltinData{BuiltinType::kSin, CallParamType::kF16, "sin"}, BuiltinData{BuiltinType::kSinh, CallParamType::kF32, "sinh"}, @@ -1002,6 +999,112 @@ void test_function() { )"); } +TEST_F(HlslGeneratorImplTest_Builtin, Sign_Scalar_i32) { + auto* val = Var("val", ty.i32()); + auto* call = Call("sign", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)] +void test_function() { + int val = 0; + const int tint_symbol = int(sign(val)); + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Sign_Vector_i32) { + auto* val = Var("val", ty.vec3()); + auto* call = Call("sign", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)] +void test_function() { + int3 val = int3(0, 0, 0); + const int3 tint_symbol = int3(sign(val)); + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Sign_Scalar_f32) { + auto* val = Var("val", ty.f32()); + auto* call = Call("sign", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)] +void test_function() { + float val = 0.0f; + const float tint_symbol = float(sign(val)); + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Sign_Vector_f32) { + auto* val = Var("val", ty.vec3()); + auto* call = Call("sign", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)] +void test_function() { + float3 val = float3(0.0f, 0.0f, 0.0f); + const float3 tint_symbol = float3(sign(val)); + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Sign_Scalar_f16) { + Enable(ast::Extension::kF16); + + auto* val = Var("val", ty.f16()); + auto* call = Call("sign", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)] +void test_function() { + float16_t val = float16_t(0.0h); + const float16_t tint_symbol = float16_t(sign(val)); + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Sign_Vector_f16) { + Enable(ast::Extension::kF16); + + auto* val = Var("val", ty.vec3()); + auto* call = Call("sign", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"([numthreads(1, 1, 1)] +void test_function() { + vector val = vector(float16_t(0.0h), float16_t(0.0h), float16_t(0.0h)); + const vector tint_symbol = vector(sign(val)); + return; +} +)"); +} + TEST_F(HlslGeneratorImplTest_Builtin, Pack4x8Snorm) { auto* call = Call("pack4x8snorm", "p1"); GlobalVar("p1", ty.vec4(), ast::AddressSpace::kPrivate); diff --git a/src/tint/writer/hlsl/generator_impl_import_test.cc b/src/tint/writer/hlsl/generator_impl_import_test.cc index 96ed7ee052..3e9e5911ba 100644 --- a/src/tint/writer/hlsl/generator_impl_import_test.cc +++ b/src/tint/writer/hlsl/generator_impl_import_test.cc @@ -62,7 +62,6 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import, HlslImportData{"log", "log"}, HlslImportData{"log2", "log2"}, HlslImportData{"round", "round"}, - HlslImportData{"sign", "sign"}, HlslImportData{"sin", "sin"}, HlslImportData{"sinh", "sinh"}, HlslImportData{"sqrt", "sqrt"}, @@ -121,7 +120,6 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import, HlslImportData{"log2", "log2"}, HlslImportData{"normalize", "normalize"}, HlslImportData{"round", "round"}, - HlslImportData{"sign", "sign"}, HlslImportData{"sin", "sin"}, HlslImportData{"sinh", "sinh"}, HlslImportData{"sqrt", "sqrt"}, diff --git a/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl index 8f9f2ce525..d0f098eaa5 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl +++ b/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl @@ -31,8 +31,8 @@ RWTexture2D outImage : register(u1, space0); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t_1 = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t_1 = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t_1 : f); } diff --git a/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl b/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl index 8f9f2ce525..d0f098eaa5 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl +++ b/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl @@ -31,8 +31,8 @@ RWTexture2D outImage : register(u1, space0); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t_1 = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t_1 = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t_1 : f); } diff --git a/test/tint/bug/tint/977.spvasm.expected.dxc.hlsl b/test/tint/bug/tint/977.spvasm.expected.dxc.hlsl index edecf62d43..6fca35affc 100644 --- a/test/tint/bug/tint/977.spvasm.expected.dxc.hlsl +++ b/test/tint/bug/tint/977.spvasm.expected.dxc.hlsl @@ -21,7 +21,7 @@ float binaryOperation_f1_f1_(inout float a, inout float b) { const float x_34 = a; const float x_36 = a; const float x_38 = b; - x_26 = (sign(x_34) * pow(abs(x_36), x_38)); + x_26 = (float(sign(x_34)) * pow(abs(x_36), x_38)); } const float x_41 = x_26; return x_41; diff --git a/test/tint/bug/tint/977.spvasm.expected.fxc.hlsl b/test/tint/bug/tint/977.spvasm.expected.fxc.hlsl index edecf62d43..6fca35affc 100644 --- a/test/tint/bug/tint/977.spvasm.expected.fxc.hlsl +++ b/test/tint/bug/tint/977.spvasm.expected.fxc.hlsl @@ -21,7 +21,7 @@ float binaryOperation_f1_f1_(inout float a, inout float b) { const float x_34 = a; const float x_36 = a; const float x_38 = b; - x_26 = (sign(x_34) * pow(abs(x_36), x_38)); + x_26 = (float(sign(x_34)) * pow(abs(x_36), x_38)); } const float x_41 = x_26; return x_41; diff --git a/test/tint/bug/tint/980.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/980.wgsl.expected.dxc.hlsl index bcec5f7aaa..9401dcb838 100644 --- a/test/tint/bug/tint/980.wgsl.expected.dxc.hlsl +++ b/test/tint/bug/tint/980.wgsl.expected.dxc.hlsl @@ -4,7 +4,7 @@ void set_float3(inout float3 vec, int idx, float val) { float3 Bad(uint index, float3 rd) { float3 normal = (0.0f).xxx; - set_float3(normal, index, -(sign(rd[index]))); + set_float3(normal, index, -(float(sign(rd[index])))); return normalize(normal); } diff --git a/test/tint/bug/tint/980.wgsl.expected.fxc.hlsl b/test/tint/bug/tint/980.wgsl.expected.fxc.hlsl index bcec5f7aaa..9401dcb838 100644 --- a/test/tint/bug/tint/980.wgsl.expected.fxc.hlsl +++ b/test/tint/bug/tint/980.wgsl.expected.fxc.hlsl @@ -4,7 +4,7 @@ void set_float3(inout float3 vec, int idx, float val) { float3 Bad(uint index, float3 rd) { float3 normal = (0.0f).xxx; - set_float3(normal, index, -(sign(rd[index]))); + set_float3(normal, index, -(float(sign(rd[index])))); return normalize(normal); } diff --git a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl index 17bf1dd4dc..efe4f1a72f 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl index 17bf1dd4dc..efe4f1a72f 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.dxc.hlsl index fd0e466b1e..8c1ebf33df 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.dxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.fxc.hlsl index fd0e466b1e..8c1ebf33df 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.fxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl index b6bbc70b37..6a15bfbcf1 100644 --- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl @@ -27,8 +27,8 @@ SamplerState arg_1 : register(s1, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl index b6bbc70b37..6a15bfbcf1 100644 --- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl @@ -27,8 +27,8 @@ SamplerState arg_1 : register(s1, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/var/sign/159665.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/159665.wgsl.expected.dxc.hlsl index 0f5abe888e..66f2d8c573 100644 --- a/test/tint/builtins/gen/var/sign/159665.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/159665.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_159665() { float3 arg_0 = (1.0f).xxx; - float3 res = sign(arg_0); + float3 res = float3(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/159665.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sign/159665.wgsl.expected.fxc.hlsl index 0f5abe888e..66f2d8c573 100644 --- a/test/tint/builtins/gen/var/sign/159665.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/sign/159665.wgsl.expected.fxc.hlsl @@ -1,6 +1,6 @@ void sign_159665() { float3 arg_0 = (1.0f).xxx; - float3 res = sign(arg_0); + float3 res = float3(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/160933.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/160933.wgsl.expected.dxc.hlsl index a7f7d6a4a0..0f56714e7b 100644 --- a/test/tint/builtins/gen/var/sign/160933.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/160933.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_160933() { vector arg_0 = (float16_t(1.0h)).xxxx; - vector res = sign(arg_0); + vector res = vector(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/3233fa.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/3233fa.wgsl.expected.dxc.hlsl index edc661b9fd..0cc495e075 100644 --- a/test/tint/builtins/gen/var/sign/3233fa.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/3233fa.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_3233fa() { int arg_0 = 1; - int res = sign(arg_0); + int res = int(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/3233fa.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sign/3233fa.wgsl.expected.fxc.hlsl index edc661b9fd..0cc495e075 100644 --- a/test/tint/builtins/gen/var/sign/3233fa.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/sign/3233fa.wgsl.expected.fxc.hlsl @@ -1,6 +1,6 @@ void sign_3233fa() { int arg_0 = 1; - int res = sign(arg_0); + int res = int(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/58d779.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/58d779.wgsl.expected.dxc.hlsl index f9df2fbd96..6e66a1bcae 100644 --- a/test/tint/builtins/gen/var/sign/58d779.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/58d779.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_58d779() { int4 arg_0 = (1).xxxx; - int4 res = sign(arg_0); + int4 res = int4(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/58d779.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sign/58d779.wgsl.expected.fxc.hlsl index f9df2fbd96..6e66a1bcae 100644 --- a/test/tint/builtins/gen/var/sign/58d779.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/sign/58d779.wgsl.expected.fxc.hlsl @@ -1,6 +1,6 @@ void sign_58d779() { int4 arg_0 = (1).xxxx; - int4 res = sign(arg_0); + int4 res = int4(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/5d283a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/5d283a.wgsl.expected.dxc.hlsl index ba4ea8efd8..1b7200df02 100644 --- a/test/tint/builtins/gen/var/sign/5d283a.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/5d283a.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_5d283a() { vector arg_0 = (float16_t(1.0h)).xxx; - vector res = sign(arg_0); + vector res = vector(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/7c85ea.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/7c85ea.wgsl.expected.dxc.hlsl index 2a3c869578..17807f9dea 100644 --- a/test/tint/builtins/gen/var/sign/7c85ea.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/7c85ea.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_7c85ea() { float16_t arg_0 = float16_t(1.0h); - float16_t res = sign(arg_0); + float16_t res = float16_t(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/926015.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/926015.wgsl.expected.dxc.hlsl index 48233dcae8..5421ab23df 100644 --- a/test/tint/builtins/gen/var/sign/926015.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/926015.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_926015() { int2 arg_0 = (1).xx; - int2 res = sign(arg_0); + int2 res = int2(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/926015.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sign/926015.wgsl.expected.fxc.hlsl index 48233dcae8..5421ab23df 100644 --- a/test/tint/builtins/gen/var/sign/926015.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/sign/926015.wgsl.expected.fxc.hlsl @@ -1,6 +1,6 @@ void sign_926015() { int2 arg_0 = (1).xx; - int2 res = sign(arg_0); + int2 res = int2(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/9603b1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/9603b1.wgsl.expected.dxc.hlsl index e3bd74cb9b..1a54c841b3 100644 --- a/test/tint/builtins/gen/var/sign/9603b1.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/9603b1.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_9603b1() { int3 arg_0 = (1).xxx; - int3 res = sign(arg_0); + int3 res = int3(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/9603b1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sign/9603b1.wgsl.expected.fxc.hlsl index e3bd74cb9b..1a54c841b3 100644 --- a/test/tint/builtins/gen/var/sign/9603b1.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/sign/9603b1.wgsl.expected.fxc.hlsl @@ -1,6 +1,6 @@ void sign_9603b1() { int3 arg_0 = (1).xxx; - int3 res = sign(arg_0); + int3 res = int3(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/b8f634.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/b8f634.wgsl.expected.dxc.hlsl index dd79825e0c..61cd17f401 100644 --- a/test/tint/builtins/gen/var/sign/b8f634.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/b8f634.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_b8f634() { float4 arg_0 = (1.0f).xxxx; - float4 res = sign(arg_0); + float4 res = float4(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/b8f634.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sign/b8f634.wgsl.expected.fxc.hlsl index dd79825e0c..61cd17f401 100644 --- a/test/tint/builtins/gen/var/sign/b8f634.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/sign/b8f634.wgsl.expected.fxc.hlsl @@ -1,6 +1,6 @@ void sign_b8f634() { float4 arg_0 = (1.0f).xxxx; - float4 res = sign(arg_0); + float4 res = float4(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/ccdb3c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/ccdb3c.wgsl.expected.dxc.hlsl index 8ec5c58856..cf827fd066 100644 --- a/test/tint/builtins/gen/var/sign/ccdb3c.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/ccdb3c.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_ccdb3c() { vector arg_0 = (float16_t(1.0h)).xx; - vector res = sign(arg_0); + vector res = vector(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/d065d8.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/d065d8.wgsl.expected.dxc.hlsl index 1c42f9a7d6..514562e5b0 100644 --- a/test/tint/builtins/gen/var/sign/d065d8.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/d065d8.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_d065d8() { float2 arg_0 = (1.0f).xx; - float2 res = sign(arg_0); + float2 res = float2(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/d065d8.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sign/d065d8.wgsl.expected.fxc.hlsl index 1c42f9a7d6..514562e5b0 100644 --- a/test/tint/builtins/gen/var/sign/d065d8.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/sign/d065d8.wgsl.expected.fxc.hlsl @@ -1,6 +1,6 @@ void sign_d065d8() { float2 arg_0 = (1.0f).xx; - float2 res = sign(arg_0); + float2 res = float2(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/dd790e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sign/dd790e.wgsl.expected.dxc.hlsl index d0ef005da9..7a84431e30 100644 --- a/test/tint/builtins/gen/var/sign/dd790e.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/sign/dd790e.wgsl.expected.dxc.hlsl @@ -1,6 +1,6 @@ void sign_dd790e() { float arg_0 = 1.0f; - float res = sign(arg_0); + float res = float(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/sign/dd790e.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sign/dd790e.wgsl.expected.fxc.hlsl index d0ef005da9..7a84431e30 100644 --- a/test/tint/builtins/gen/var/sign/dd790e.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/sign/dd790e.wgsl.expected.fxc.hlsl @@ -1,6 +1,6 @@ void sign_dd790e() { float arg_0 = 1.0f; - float res = sign(arg_0); + float res = float(sign(arg_0)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl index a90f55cb12..93cec7b899 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl index a90f55cb12..93cec7b899 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.dxc.hlsl index 55e0aa30b9..062af5567d 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.dxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.fxc.hlsl index 55e0aa30b9..062af5567d 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.fxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl index 9322a94fc4..678344ff29 100644 --- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl @@ -27,8 +27,8 @@ SamplerState arg_1 : register(s1, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl index 9322a94fc4..678344ff29 100644 --- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl @@ -27,8 +27,8 @@ SamplerState arg_1 : register(s1, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.dxc.hlsl b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.dxc.hlsl index ca1acb36b7..c61c15ddc0 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.dxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl index ca1acb36b7..c61c15ddc0 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl @@ -26,8 +26,8 @@ Texture2D arg_0 : register(t0, space1); float3 gammaCorrection(float3 v, GammaTransferParams params) { const bool3 cond = (abs(v) < float3((params.D).xxx)); - const float3 t = (sign(v) * ((params.C * abs(v)) + params.F)); - const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); + const float3 t = (float3(sign(v)) * ((params.C * abs(v)) + params.F)); + const float3 f = (float3(sign(v)) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E)); return (cond ? t : f); } diff --git a/webgpu-cts/expectations.txt b/webgpu-cts/expectations.txt index 3dfe1470f7..71919a86b9 100644 --- a/webgpu-cts/expectations.txt +++ b/webgpu-cts/expectations.txt @@ -250,18 +250,6 @@ crbug.com/tint/1794 [ intel-gen-9 ubuntu ] webgpu:shader,execution,expression,ca crbug.com/tint/1794 [ intel-gen-9 ubuntu ] webgpu:shader,execution,expression,call,builtin,firstTrailingBit:u32:inputSource="uniform";vectorize=2 [ Failure ] crbug.com/tint/1794 [ intel-gen-9 ubuntu ] webgpu:shader,execution,expression,call,builtin,firstTrailingBit:u32:inputSource="uniform";vectorize=3 [ Failure ] crbug.com/tint/1794 [ intel-gen-9 ubuntu ] webgpu:shader,execution,expression,call,builtin,firstTrailingBit:u32:inputSource="uniform";vectorize=4 [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_r";vectorize="_undef_" [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_r";vectorize=2 [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_r";vectorize=3 [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_r";vectorize=4 [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_rw";vectorize="_undef_" [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_rw";vectorize=2 [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_rw";vectorize=3 [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="storage_rw";vectorize=4 [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="uniform";vectorize="_undef_" [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="uniform";vectorize=2 [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="uniform";vectorize=3 [ Failure ] -crbug.com/tint/1795 [ win10 ] webgpu:shader,execution,expression,call,builtin,sign:f32:inputSource="uniform";vectorize=4 [ Failure ] ################################################################################ # webgpu:shader,execution,memory_model