diff --git a/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp b/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp index cb2beaa949..5aeecf1d3e 100644 --- a/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp +++ b/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp @@ -495,10 +495,9 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) { break; case k_dFdy_IntrinsicKind: // Flipping Y also negates the Y derivatives. - this->write("(" SKSL_RTFLIP_NAME ".y * dFdy("); - this->writeExpression(*arguments[0], Precedence::kSequence); - this->write("))"); - return; + this->write(SKSL_RTFLIP_NAME ".y * dFdy"); + nameWritten = true; + [[fallthrough]]; case k_dFdx_IntrinsicKind: case k_fwidth_IntrinsicKind: if (!fFoundDerivatives && diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp index fe21c1958d..67d789fc3a 100644 --- a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp +++ b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp @@ -717,9 +717,8 @@ bool MetalCodeGenerator::writeIntrinsicCall(const FunctionCall& c, IntrinsicKind return true; } case k_dFdy_IntrinsicKind: { - this->write("(" + fRTFlipName + ".y * dfdy"); + this->write(fRTFlipName + ".y*dfdy"); this->writeArgumentList(c.arguments()); - this->write(")"); return true; } case k_inverse_IntrinsicKind: { diff --git a/tests/sksl/intrinsics/DFdy.glsl b/tests/sksl/intrinsics/DFdy.glsl index 13f7fd2634..1ea763a838 100644 --- a/tests/sksl/intrinsics/DFdy.glsl +++ b/tests/sksl/intrinsics/DFdy.glsl @@ -6,5 +6,5 @@ uniform vec4 colorGreen; uniform vec4 colorRed; vec4 main() { vec4 expected = vec4(0.0); - return ((((((u_skRTFlip.y * dFdy(testInputs.x)) == expected.x && (u_skRTFlip.y * dFdy(testInputs.xy)) == expected.xy) && (u_skRTFlip.y * dFdy(testInputs.xyz)) == expected.xyz) && (u_skRTFlip.y * dFdy(testInputs)) == expected) && sign((u_skRTFlip.y * dFdy(coords.xx))) == vec2(0.0, 0.0)) && sign((u_skRTFlip.y * dFdy(coords.yy))) == vec2(1.0, 1.0)) && sign((u_skRTFlip.y * dFdy(coords))) == vec2(0.0, 1.0) ? colorGreen : colorRed; + return (((((u_skRTFlip.y * dFdy(testInputs.x) == expected.x && u_skRTFlip.y * dFdy(testInputs.xy) == expected.xy) && u_skRTFlip.y * dFdy(testInputs.xyz) == expected.xyz) && u_skRTFlip.y * dFdy(testInputs) == expected) && sign(u_skRTFlip.y * dFdy(coords.xx)) == vec2(0.0, 0.0)) && sign(u_skRTFlip.y * dFdy(coords.yy)) == vec2(1.0, 1.0)) && sign(u_skRTFlip.y * dFdy(coords)) == vec2(0.0, 1.0) ? colorGreen : colorRed; } diff --git a/tests/sksl/intrinsics/DFdy.metal b/tests/sksl/intrinsics/DFdy.metal index 8f4e8b8472..2d473c4d81 100644 --- a/tests/sksl/intrinsics/DFdy.metal +++ b/tests/sksl/intrinsics/DFdy.metal @@ -18,6 +18,6 @@ fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _unifo Outputs _out; (void)_out; float4 expected = float4(0.0); - _out.sk_FragColor = ((((((_anonInterface0.u_skRTFlip.y * dfdy(_uniforms.testInputs.x)) == expected.x && all((_anonInterface0.u_skRTFlip.y * dfdy(_uniforms.testInputs.xy)) == expected.xy)) && all((_anonInterface0.u_skRTFlip.y * dfdy(_uniforms.testInputs.xyz)) == expected.xyz)) && all((_anonInterface0.u_skRTFlip.y * dfdy(_uniforms.testInputs)) == expected)) && all(sign((_anonInterface0.u_skRTFlip.y * dfdy(coords.xx))) == float2(0.0, 0.0))) && all(sign((_anonInterface0.u_skRTFlip.y * dfdy(coords.yy))) == float2(1.0, 1.0))) && all(sign((_anonInterface0.u_skRTFlip.y * dfdy(coords))) == float2(0.0, 1.0)) ? _uniforms.colorGreen : _uniforms.colorRed; + _out.sk_FragColor = (((((_anonInterface0.u_skRTFlip.y*dfdy(_uniforms.testInputs.x) == expected.x && all(_anonInterface0.u_skRTFlip.y*dfdy(_uniforms.testInputs.xy) == expected.xy)) && all(_anonInterface0.u_skRTFlip.y*dfdy(_uniforms.testInputs.xyz) == expected.xyz)) && all(_anonInterface0.u_skRTFlip.y*dfdy(_uniforms.testInputs) == expected)) && all(sign(_anonInterface0.u_skRTFlip.y*dfdy(coords.xx)) == float2(0.0, 0.0))) && all(sign(_anonInterface0.u_skRTFlip.y*dfdy(coords.yy)) == float2(1.0, 1.0))) && all(sign(_anonInterface0.u_skRTFlip.y*dfdy(coords)) == float2(0.0, 1.0)) ? _uniforms.colorGreen : _uniforms.colorRed; return _out; }