diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index 4910f812af..2c4279cfd2 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -997,6 +997,9 @@ bool GeneratorImpl::EmitBuiltinCall(utils::StringStream& out, if (type == builtin::Function::kQuantizeToF16) { return EmitQuantizeToF16Call(out, expr, builtin); } + if (type == builtin::Function::kTrunc) { + return EmitTruncCall(out, expr, builtin); + } if (builtin->IsDataPacking()) { return EmitDataPackingCall(out, expr, builtin); } @@ -2116,6 +2119,20 @@ bool GeneratorImpl::EmitQuantizeToF16Call(utils::StringStream& out, return true; } +bool GeneratorImpl::EmitTruncCall(utils::StringStream& out, + const ast::CallExpression* expr, + const sem::Builtin* builtin) { + // HLSL's trunc is broken for very large/small float values. + // See crbug.com/tint/1883 + return CallBuiltinHelper( // + out, expr, builtin, [&](TextBuffer* b, const std::vector& params) { + // value < 0 ? ceil(value) : floor(value) + line(b) << "return " << params[0] << " < 0 ? ceil(" << params[0] << ") : floor(" + << params[0] << ");"; + return true; + }); +} + bool GeneratorImpl::EmitDataPackingCall(utils::StringStream& out, const ast::CallExpression* expr, const sem::Builtin* builtin) { @@ -2704,7 +2721,6 @@ std::string GeneratorImpl::generate_builtin_name(const sem::Builtin* builtin) { case builtin::Function::kTan: case builtin::Function::kTanh: case builtin::Function::kTranspose: - case builtin::Function::kTrunc: return builtin->str(); case builtin::Function::kCountOneBits: // uint return "countbits"; diff --git a/src/tint/writer/hlsl/generator_impl.h b/src/tint/writer/hlsl/generator_impl.h index f7adc9f9bc..103e355d9e 100644 --- a/src/tint/writer/hlsl/generator_impl.h +++ b/src/tint/writer/hlsl/generator_impl.h @@ -281,6 +281,14 @@ class GeneratorImpl : public TextGenerator { bool EmitQuantizeToF16Call(utils::StringStream& out, const ast::CallExpression* expr, const sem::Builtin* builtin); + /// Handles generating a call to the `trunc()` intrinsic + /// @param out the output of the expression stream + /// @param expr the call expression + /// @param builtin the semantic information for the builtin + /// @returns true if the call expression is emitted + bool EmitTruncCall(utils::StringStream& out, + const ast::CallExpression* expr, + const sem::Builtin* builtin); /// Handles generating a call to DP4a builtins (dot4I8Packed and dot4U8Packed) /// @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 d552671910..75fd4638ce 100644 --- a/src/tint/writer/hlsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/hlsl/generator_impl_builtin_test.cc @@ -97,7 +97,6 @@ const ast::CallExpression* GenerateCall(builtin::Function builtin, case builtin::Function::kSqrt: case builtin::Function::kTan: case builtin::Function::kTanh: - case builtin::Function::kTrunc: if (type == CallParamType::kF16) { return builder->Call(str.str(), "h2"); } else { @@ -309,8 +308,6 @@ INSTANTIATE_TEST_SUITE_P( BuiltinData{builtin::Function::kTan, CallParamType::kF16, "tan"}, BuiltinData{builtin::Function::kTanh, CallParamType::kF32, "tanh"}, BuiltinData{builtin::Function::kTanh, CallParamType::kF16, "tanh"}, - BuiltinData{builtin::Function::kTrunc, CallParamType::kF32, "trunc"}, - BuiltinData{builtin::Function::kTrunc, CallParamType::kF16, "trunc"}, /* Integer built-in */ BuiltinData{builtin::Function::kAbs, CallParamType::kU32, "abs"}, BuiltinData{builtin::Function::kClamp, CallParamType::kU32, "clamp"}, @@ -1089,6 +1086,94 @@ void test_function() { )"); } +TEST_F(HlslGeneratorImplTest_Builtin, Trunc_Scalar_f32) { + auto* val = Var("val", ty.f32()); + auto* call = Call("trunc", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + +[numthreads(1, 1, 1)] +void test_function() { + float val = 0.0f; + const float tint_symbol = tint_trunc(val); + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Trunc_Vector_f32) { + auto* val = Var("val", ty.vec3()); + auto* call = Call("trunc", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + +[numthreads(1, 1, 1)] +void test_function() { + float3 val = float3(0.0f, 0.0f, 0.0f); + const float3 tint_symbol = tint_trunc(val); + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Trunc_Scalar_f16) { + Enable(builtin::Extension::kF16); + + auto* val = Var("val", ty.f16()); + auto* call = Call("trunc", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(float16_t tint_trunc(float16_t param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + +[numthreads(1, 1, 1)] +void test_function() { + float16_t val = float16_t(0.0h); + const float16_t tint_symbol = tint_trunc(val); + return; +} +)"); +} + +TEST_F(HlslGeneratorImplTest_Builtin, Trunc_Vector_f16) { + Enable(builtin::Extension::kF16); + + auto* val = Var("val", ty.vec3()); + auto* call = Call("trunc", val); + WrapInFunction(val, call); + + GeneratorImpl& gen = SanitizeAndBuild(); + + ASSERT_TRUE(gen.Generate()) << gen.error(); + EXPECT_EQ(gen.result(), R"(vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + +[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 = tint_trunc(val); + return; +} +)"); +} + TEST_F(HlslGeneratorImplTest_Builtin, Pack4x8Snorm) { auto* call = Call("pack4x8snorm", "p1"); GlobalVar("p1", ty.vec4(), builtin::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 133774a5fc..3fbad507ea 100644 --- a/src/tint/writer/hlsl/generator_impl_import_test.cc +++ b/src/tint/writer/hlsl/generator_impl_import_test.cc @@ -66,8 +66,7 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import, HlslImportData{"sinh", "sinh"}, HlslImportData{"sqrt", "sqrt"}, HlslImportData{"tan", "tan"}, - HlslImportData{"tanh", "tanh"}, - HlslImportData{"trunc", "trunc"})); + HlslImportData{"tanh", "tanh"})); using HlslImportData_SingleIntParamTest = TestParamHelper; TEST_P(HlslImportData_SingleIntParamTest, IntScalar) { @@ -125,8 +124,7 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import, HlslImportData{"sinh", "sinh"}, HlslImportData{"sqrt", "sqrt"}, HlslImportData{"tan", "tan"}, - HlslImportData{"tanh", "tanh"}, - HlslImportData{"trunc", "trunc"})); + HlslImportData{"tanh", "tanh"})); using HlslImportData_DualParam_ScalarTest = TestParamHelper; TEST_P(HlslImportData_DualParam_ScalarTest, Float) { diff --git a/test/tint/bug/tint/948.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/948.wgsl.expected.dxc.hlsl index 22b7bcf46d..7d2dc12aeb 100644 --- a/test/tint/bug/tint/948.wgsl.expected.dxc.hlsl +++ b/test/tint/bug/tint/948.wgsl.expected.dxc.hlsl @@ -1,3 +1,7 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + cbuffer cbuffer_x_20 : register(b9, space2) { uint4 x_20[8]; }; @@ -34,7 +38,7 @@ float4x4 getFrameData_f1_(inout float frameID) { } float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } void main_1() { diff --git a/test/tint/bug/tint/948.wgsl.expected.fxc.hlsl b/test/tint/bug/tint/948.wgsl.expected.fxc.hlsl index 22b7bcf46d..7d2dc12aeb 100644 --- a/test/tint/bug/tint/948.wgsl.expected.fxc.hlsl +++ b/test/tint/bug/tint/948.wgsl.expected.fxc.hlsl @@ -1,3 +1,7 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + cbuffer cbuffer_x_20 : register(b9, space2) { uint4 x_20[8]; }; @@ -34,7 +38,7 @@ float4x4 getFrameData_f1_(inout float frameID) { } float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } void main_1() { diff --git a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.dxc.hlsl index 7325653db3..297fe1eb22 100644 --- a/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/103ab8.wgsl.expected.dxc.hlsl @@ -1,8 +1,12 @@ +vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_103ab8() { vector arg_0 = (float16_t(1.5h)).xxx; - vector res = trunc(arg_0); + vector res = tint_trunc(arg_0); prevent_dce.Store >(0u, res); } diff --git a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.dxc.hlsl index 45ad5a7877..6da994980d 100644 --- a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.dxc.hlsl @@ -1,8 +1,12 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_562d05() { float3 arg_0 = (1.5f).xxx; - float3 res = trunc(arg_0); + float3 res = tint_trunc(arg_0); prevent_dce.Store3(0u, asuint(res)); } diff --git a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.fxc.hlsl index 45ad5a7877..6da994980d 100644 --- a/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/562d05.wgsl.expected.fxc.hlsl @@ -1,8 +1,12 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_562d05() { float3 arg_0 = (1.5f).xxx; - float3 res = trunc(arg_0); + float3 res = tint_trunc(arg_0); prevent_dce.Store3(0u, asuint(res)); } diff --git a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.dxc.hlsl index 82724f55f3..cf4c0d9f8d 100644 --- a/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/a56109.wgsl.expected.dxc.hlsl @@ -1,8 +1,12 @@ +vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_a56109() { vector arg_0 = (float16_t(1.5h)).xx; - vector res = trunc(arg_0); + vector res = tint_trunc(arg_0); prevent_dce.Store >(0u, res); } diff --git a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.dxc.hlsl index 9b264827f3..8731bf2ae4 100644 --- a/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/cc2b0d.wgsl.expected.dxc.hlsl @@ -1,8 +1,12 @@ +float16_t tint_trunc(float16_t param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_cc2b0d() { float16_t arg_0 = float16_t(1.5h); - float16_t res = trunc(arg_0); + float16_t res = tint_trunc(arg_0); prevent_dce.Store(0u, res); } diff --git a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.dxc.hlsl index 9cda36fad2..4e8cb2b80c 100644 --- a/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/ce7c17.wgsl.expected.dxc.hlsl @@ -1,8 +1,12 @@ +vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_ce7c17() { vector arg_0 = (float16_t(1.5h)).xxxx; - vector res = trunc(arg_0); + vector res = tint_trunc(arg_0); prevent_dce.Store >(0u, res); } diff --git a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.dxc.hlsl index 4049c45a68..5d762df644 100644 --- a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.dxc.hlsl @@ -1,8 +1,12 @@ +float4 tint_trunc(float4 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_e183aa() { float4 arg_0 = (1.5f).xxxx; - float4 res = trunc(arg_0); + float4 res = tint_trunc(arg_0); prevent_dce.Store4(0u, asuint(res)); } diff --git a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.fxc.hlsl index 4049c45a68..5d762df644 100644 --- a/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/e183aa.wgsl.expected.fxc.hlsl @@ -1,8 +1,12 @@ +float4 tint_trunc(float4 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_e183aa() { float4 arg_0 = (1.5f).xxxx; - float4 res = trunc(arg_0); + float4 res = tint_trunc(arg_0); prevent_dce.Store4(0u, asuint(res)); } diff --git a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.dxc.hlsl index 39e592a7e8..7cf7811c9b 100644 --- a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.dxc.hlsl @@ -1,8 +1,12 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_eb83df() { float arg_0 = 1.5f; - float res = trunc(arg_0); + float res = tint_trunc(arg_0); prevent_dce.Store(0u, asuint(res)); } diff --git a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.fxc.hlsl index 39e592a7e8..7cf7811c9b 100644 --- a/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/eb83df.wgsl.expected.fxc.hlsl @@ -1,8 +1,12 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_eb83df() { float arg_0 = 1.5f; - float res = trunc(arg_0); + float res = tint_trunc(arg_0); prevent_dce.Store(0u, asuint(res)); } diff --git a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.dxc.hlsl index 6077e4d951..715c2d69a5 100644 --- a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.dxc.hlsl @@ -1,8 +1,12 @@ +float2 tint_trunc(float2 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_f370d3() { float2 arg_0 = (1.5f).xx; - float2 res = trunc(arg_0); + float2 res = tint_trunc(arg_0); prevent_dce.Store2(0u, asuint(res)); } diff --git a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.fxc.hlsl index 6077e4d951..715c2d69a5 100644 --- a/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/trunc/f370d3.wgsl.expected.fxc.hlsl @@ -1,8 +1,12 @@ +float2 tint_trunc(float2 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + RWByteAddressBuffer prevent_dce : register(u0, space2); void trunc_f370d3() { float2 arg_0 = (1.5f).xx; - float2 res = trunc(arg_0); + float2 res = tint_trunc(arg_0); prevent_dce.Store2(0u, asuint(res)); } diff --git a/test/tint/expressions/binary/mod/scalar-scalar/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod/scalar-scalar/f16.wgsl.expected.dxc.hlsl index ad0a42199e..ca63e8305d 100644 --- a/test/tint/expressions/binary/mod/scalar-scalar/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod/scalar-scalar/f16.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float16_t tint_trunc(float16_t param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float16_t tint_float_mod(float16_t lhs, float16_t rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/scalar-scalar/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod/scalar-scalar/f32.wgsl.expected.dxc.hlsl index 0c9eb2e075..d877f6258c 100644 --- a/test/tint/expressions/binary/mod/scalar-scalar/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod/scalar-scalar/f32.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/scalar-scalar/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod/scalar-scalar/f32.wgsl.expected.fxc.hlsl index 0c9eb2e075..d877f6258c 100644 --- a/test/tint/expressions/binary/mod/scalar-scalar/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod/scalar-scalar/f32.wgsl.expected.fxc.hlsl @@ -1,5 +1,9 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/scalar-vec3/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod/scalar-vec3/f16.wgsl.expected.dxc.hlsl index 99ffb584bb..ac7ecfa5da 100644 --- a/test/tint/expressions/binary/mod/scalar-vec3/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod/scalar-vec3/f16.wgsl.expected.dxc.hlsl @@ -1,6 +1,10 @@ +vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + vector tint_float_mod(float16_t lhs, vector rhs) { const vector l = vector((lhs).xxx); - return (l - (trunc((l / rhs)) * rhs)); + return (l - (tint_trunc((l / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/scalar-vec3/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod/scalar-vec3/f32.wgsl.expected.dxc.hlsl index c864275a6a..e157fd9cf2 100644 --- a/test/tint/expressions/binary/mod/scalar-vec3/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod/scalar-vec3/f32.wgsl.expected.dxc.hlsl @@ -1,6 +1,10 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float lhs, float3 rhs) { const float3 l = float3((lhs).xxx); - return (l - (trunc((l / rhs)) * rhs)); + return (l - (tint_trunc((l / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/scalar-vec3/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod/scalar-vec3/f32.wgsl.expected.fxc.hlsl index c864275a6a..e157fd9cf2 100644 --- a/test/tint/expressions/binary/mod/scalar-vec3/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod/scalar-vec3/f32.wgsl.expected.fxc.hlsl @@ -1,6 +1,10 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float lhs, float3 rhs) { const float3 l = float3((lhs).xxx); - return (l - (trunc((l / rhs)) * rhs)); + return (l - (tint_trunc((l / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/vec3-scalar/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod/vec3-scalar/f16.wgsl.expected.dxc.hlsl index a8976e907f..674f37a05b 100644 --- a/test/tint/expressions/binary/mod/vec3-scalar/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod/vec3-scalar/f16.wgsl.expected.dxc.hlsl @@ -1,6 +1,10 @@ +vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + vector tint_float_mod(vector lhs, float16_t rhs) { const vector r = vector((rhs).xxx); - return (lhs - (trunc((lhs / r)) * r)); + return (lhs - (tint_trunc((lhs / r)) * r)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/vec3-scalar/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod/vec3-scalar/f32.wgsl.expected.dxc.hlsl index c61e266e8d..9b1c9e826a 100644 --- a/test/tint/expressions/binary/mod/vec3-scalar/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod/vec3-scalar/f32.wgsl.expected.dxc.hlsl @@ -1,6 +1,10 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float rhs) { const float3 r = float3((rhs).xxx); - return (lhs - (trunc((lhs / r)) * r)); + return (lhs - (tint_trunc((lhs / r)) * r)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/vec3-scalar/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod/vec3-scalar/f32.wgsl.expected.fxc.hlsl index c61e266e8d..9b1c9e826a 100644 --- a/test/tint/expressions/binary/mod/vec3-scalar/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod/vec3-scalar/f32.wgsl.expected.fxc.hlsl @@ -1,6 +1,10 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float rhs) { const float3 r = float3((rhs).xxx); - return (lhs - (trunc((lhs / r)) * r)); + return (lhs - (tint_trunc((lhs / r)) * r)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/vec3-vec3/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod/vec3-vec3/f16.wgsl.expected.dxc.hlsl index 69ff97a56e..f155a84a21 100644 --- a/test/tint/expressions/binary/mod/vec3-vec3/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod/vec3-vec3/f16.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + vector tint_float_mod(vector lhs, vector rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/vec3-vec3/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod/vec3-vec3/f32.wgsl.expected.dxc.hlsl index b03e6c8bb7..494f4ce1d4 100644 --- a/test/tint/expressions/binary/mod/vec3-vec3/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod/vec3-vec3/f32.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float3 rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod/vec3-vec3/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod/vec3-vec3/f32.wgsl.expected.fxc.hlsl index b03e6c8bb7..494f4ce1d4 100644 --- a/test/tint/expressions/binary/mod/vec3-vec3/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod/vec3-vec3/f32.wgsl.expected.fxc.hlsl @@ -1,5 +1,9 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float3 rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f16.wgsl.expected.dxc.hlsl index 45c8ee1ef6..97fecd142e 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f16.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float16_t tint_trunc(float16_t param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float16_t tint_float_mod(float16_t lhs, float16_t rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f32.wgsl.expected.dxc.hlsl index 515bcfb4cf..ae4c47153f 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f32.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f32.wgsl.expected.fxc.hlsl index 515bcfb4cf..ae4c47153f 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/f32.wgsl.expected.fxc.hlsl @@ -1,5 +1,9 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f16.wgsl.expected.dxc.hlsl index 8e4d644520..b0c681a80e 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f16.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + vector tint_float_mod(vector lhs, vector rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f32.wgsl.expected.dxc.hlsl index 0cd0191b63..286cf50588 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f32.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float3 rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f32.wgsl.expected.fxc.hlsl index 0cd0191b63..286cf50588 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/f32.wgsl.expected.fxc.hlsl @@ -1,5 +1,9 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float3 rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f16.wgsl.expected.dxc.hlsl index 649bbd27ca..375c800bd2 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f16.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float16_t tint_trunc(float16_t param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float16_t tint_float_mod(float16_t lhs, float16_t rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f32.wgsl.expected.dxc.hlsl index 6af8624597..acdbe86c8a 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f32.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f32.wgsl.expected.fxc.hlsl index 6af8624597..acdbe86c8a 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/f32.wgsl.expected.fxc.hlsl @@ -1,5 +1,9 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f16.wgsl.expected.dxc.hlsl index dfe3a63dc3..eeaad40856 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f16.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + vector tint_float_mod(vector lhs, vector rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f32.wgsl.expected.dxc.hlsl index ff6fdd424b..c02066067c 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f32.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float3 rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f32.wgsl.expected.fxc.hlsl index ff6fdd424b..c02066067c 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/f32.wgsl.expected.fxc.hlsl @@ -1,5 +1,9 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float3 rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f16.wgsl.expected.dxc.hlsl index 7ee2e0b994..00842cae0d 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f16.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float16_t tint_trunc(float16_t param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float16_t tint_float_mod(float16_t lhs, float16_t rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f32.wgsl.expected.dxc.hlsl index 0fc0aef110..022984ca76 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f32.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f32.wgsl.expected.fxc.hlsl index 0fc0aef110..022984ca76 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/f32.wgsl.expected.fxc.hlsl @@ -1,5 +1,9 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f16.wgsl.expected.dxc.hlsl index 4c47f3bd27..51ad062076 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f16.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +vector tint_trunc(vector param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + vector tint_float_mod(vector lhs, vector rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f32.wgsl.expected.dxc.hlsl index f6fdd4c136..65bfe56957 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f32.wgsl.expected.dxc.hlsl @@ -1,5 +1,9 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float3 rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f32.wgsl.expected.fxc.hlsl index f6fdd4c136..65bfe56957 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/f32.wgsl.expected.fxc.hlsl @@ -1,5 +1,9 @@ +float3 tint_trunc(float3 param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + float3 tint_float_mod(float3 lhs, float3 rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } [numthreads(1, 1, 1)] diff --git a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.dxc.hlsl b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.dxc.hlsl index 314a630db0..cd21f9455f 100644 --- a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.dxc.hlsl +++ b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.dxc.hlsl @@ -1,3 +1,7 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + [numthreads(1, 1, 1)] void unused_entry_point() { return; @@ -20,7 +24,7 @@ int tint_mod(int lhs, int rhs) { } float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } void foo(int maybe_zero) { diff --git a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.fxc.hlsl b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.fxc.hlsl index 314a630db0..cd21f9455f 100644 --- a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.fxc.hlsl +++ b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.fxc.hlsl @@ -1,3 +1,7 @@ +float tint_trunc(float param_0) { + return param_0 < 0 ? ceil(param_0) : floor(param_0); +} + [numthreads(1, 1, 1)] void unused_entry_point() { return; @@ -20,7 +24,7 @@ int tint_mod(int lhs, int rhs) { } float tint_float_mod(float lhs, float rhs) { - return (lhs - (trunc((lhs / rhs)) * rhs)); + return (lhs - (tint_trunc((lhs / rhs)) * rhs)); } void foo(int maybe_zero) { diff --git a/webgpu-cts/expectations.txt b/webgpu-cts/expectations.txt index 16acd40858..c8ff226c97 100644 --- a/webgpu-cts/expectations.txt +++ b/webgpu-cts/expectations.txt @@ -718,19 +718,6 @@ crbug.com/dawn/0000 [ amd-0x67ef dawn-no-backend-validation ventura ] webgpu:sha crbug.com/dawn/0000 [ amd-0x67ef dawn-backend-validation ventura ] webgpu:shader,execution,expression,binary,f32_arithmetic:addition:inputSource="uniform";vectorize="_undef_" [ Failure ] crbug.com/dawn/0000 [ dawn-no-backend-validation intel-0x9bc5 ubuntu ] webgpu:shader,execution,expression,binary,f32_arithmetic:addition_compound:inputSource="const";vectorize=3 [ Slow ] crbug.com/dawn/0000 [ dawn-backend-validation intel-0x3e9b monterey ] webgpu:shader,execution,expression,binary,f32_arithmetic:addition_scalar_vector:inputSource="storage_rw";dim=2 [ Failure ] -crbug.com/dawn/0000 [ dawn-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize="_undef_" [ Failure ] -crbug.com/dawn/0000 [ dawn-no-backend-validation intel-0x9bc5 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize="_undef_" [ Failure ] -crbug.com/dawn/0000 [ dawn-no-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize="_undef_" [ Failure ] -crbug.com/dawn/0000 [ dawn-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=2 [ Failure ] -crbug.com/dawn/0000 [ dawn-no-backend-validation intel-0x9bc5 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=2 [ Failure ] -crbug.com/dawn/0000 [ dawn-no-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=2 [ Failure ] -crbug.com/dawn/0000 [ dawn-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=3 [ Failure ] -crbug.com/dawn/0000 [ dawn-no-backend-validation intel-0x9bc5 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=3 [ Failure ] -crbug.com/dawn/0000 [ dawn-no-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=3 [ Failure ] -crbug.com/dawn/0000 [ dawn-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=4 [ Failure ] -crbug.com/dawn/0000 [ dawn-no-backend-validation intel-0x9bc5 ubuntu ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=4 [ Slow ] -crbug.com/dawn/0000 [ dawn-no-backend-validation intel-0x9bc5 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=4 [ Failure ] -crbug.com/dawn/0000 [ dawn-no-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_compound:inputSource="const";vectorize=4 [ Failure ] crbug.com/dawn/0000 [ dawn-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_vector_scalar_compound:inputSource="const";dim=2 [ Failure ] crbug.com/dawn/0000 [ dawn-no-backend-validation intel-0x9bc5 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_vector_scalar_compound:inputSource="const";dim=2 [ Failure ] crbug.com/dawn/0000 [ dawn-no-backend-validation nvidia-0x2184 win10 ] webgpu:shader,execution,expression,binary,f32_arithmetic:remainder_vector_scalar_compound:inputSource="const";dim=2 [ Failure ]