Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b395b05e authored by Ivan Yossi's avatar Ivan Yossi 👌

FIX: Float precision bug masking issues for

    vectorized GaussMask generator

ref T8734
parent 0e0e4f9a
......@@ -219,22 +219,20 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i
Vc::float_v fullFade = vAlphafactor * ( d->vErf(valDist + vCenter) - d->vErf(valDist - vCenter));
Vc::float_m mask;
// Mask undefined values, out of range are out of mask
mask = Vc::isfinite(fullFade);
fullFade.setZero(!mask);
// Mask in the inner circe of the mask
mask = fullFade < vZero;
fullFade.setZero(mask);
// Mask the outter circle
mask = fullFade > 254.974f;
fullFade(mask) = vValMax;
// Mask (value - value), presicion errors.
mask = fullFade >= vValMax;
Vc::float_v vFade = (vValMax - fullFade) / vValMax;
vFade(mask) = vZero;
// filter nan and inf. Vc uses float, imprecission errors are frequent
mask = Vc::isfinite(vFade);
vFade(!mask) = vOne;
// Mask the inner circe of the mask
mask = vFade < vZero;
vFade(mask) = vZero;
// return original dist values before vFade transform
vFade(excludeMask) = dist;
......
......@@ -53,6 +53,8 @@ struct Q_DECL_HIDDEN KisGaussCircleMaskGenerator::Private
// vectorized erf function, precision 1e-5
Vc::float_v vErf(Vc::float_v x) {
Vc::float_v xa = abs(x);
Vc::float_m precisionLimit(xa >= 9.3f); // wrong result for any number beyond this
xa(precisionLimit) = 0;
Vc::float_v sign(Vc::One);
Vc::float_m invertMask = x < 0.f;
sign(invertMask) = -1.f;
......@@ -67,6 +69,7 @@ struct Q_DECL_HIDDEN KisGaussCircleMaskGenerator::Private
Vc::float_v t = 1.0f / (1.0f + p * xa);
Vc::float_v y = 1.0f - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * exp(-xa * xa);
y(precisionLimit) = 1.0f;
return sign * y;
}
#endif /* defined HAVE_VC */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment