Workaround MSVC 2019 code-gen bug in lighting image filter

Change-Id: Ia189fa2bec80093ddd6e2db35054db31c56106d8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261676
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2019-12-27 13:50:31 -05:00 committed by Skia Commit-Bot
parent 81158535ed
commit 5e976be7f0

View File

@ -72,7 +72,15 @@ static inline void shiftMatrixLeft(int m[9]) {
static inline void fast_normalize(SkPoint3* vector) {
// add a tiny bit so we don't have to worry about divide-by-zero
SkScalar magSq = vector->dot(*vector) + SK_ScalarNearlyZero;
#if defined(_MSC_VER) && _MSC_VER >= 1920
// Visual Studio 2019 has some kind of code-generation bug in release builds involving the
// lighting math in this file. Using the portable rsqrt avoids the issue. This issue appears
// to be specific to the collection of (inline) functions in this file that call into this
// function, not with sk_float_rsqrt itself.
SkScalar scale = sk_float_rsqrt_portable(magSq);
#else
SkScalar scale = sk_float_rsqrt(magSq);
#endif
vector->fX *= scale;
vector->fY *= scale;
vector->fZ *= scale;