Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
fast_exp2
with MSVC and sse4.2 (AcademySoftwareFoundation#3804)
I ran into the problem described in AcademySoftwareFoundation#2929 and did a little digging to see if I could find the source of the bad color conversions. I tracked it down to `fast_exp2()` https://github.com/OpenImageIO/oiio/blob/a77e36250fadfb4c391688eb1df4b3dd88d5e367/src/include/OpenImageIO/fmath.h#L2050-L2080 and in particular the return statement on L2071. In the process of trying to figure out what part of that return statement was going awry, I found that separating the bitcasts to separate variables as in this PR, the problem went away. All testing was done with the `color_test` added in AcademySoftwareFoundation#3023. It also succeeded when adding various `std::cout` lines to check what the values of each computation were, so it does sound like a compiler optimization that does or does not get triggered is the problem. Unfortunately I don't know why it's not failing on the CI builds, I double checked to make sure I'm using the same settings and flags. I also tested on two different machines and get the same failures, and success with this patch, on both. One strange wrinkle is that even without this patch, color conversions worked fine when using AVX2 for the SIMD mode. Summary : Previous results (without this patch) - USE_SIMD=0 - PASS - USE_SIMD=SSE4.2 - FAIL - USE_SIMD=AVX - FAIL - USE_SIMD=AVX2 - PASS With this patch - USE_SIMD=0 - PASS - USE_SIMD=SSE4.2 - PASS - USE_SIMD=AVX - PASS - USE_SIMD=AVX2 - PASS Visual Studio 2019 versions 16.11.32228.343, 16.11.33328.57 and 16.11.33423.256(same as current Github build runners) in RelWithDebInfo mode.
- Loading branch information