microsoft / DirectXMath

DirectXMath is an all inline SIMD C++ linear algebra library for use in games and graphics apps
https://walbourn.github.io/introducing-directxmath/
MIT License
1.54k stars 238 forks source link

Re-optimized unswizzle #126

Closed shinjich closed 3 years ago

shinjich commented 3 years ago

modified code that optimized for Xenon architecture, and vectorized unity table generators.

walbourn commented 3 years ago

Make sure this still runs with the associated xdsp test here.

The CMakeLists.txt in that project should also allow you to verify it builds without warnings with clang/LLVM.

shinjich commented 3 years ago

The updated XDSP adopted XMVectorSinCos for vectorization. I noticed that compiling with clang LLVM would cause an accuracy error of about 1 bit and it would fail compareson on XDSPTest.

define TESTEPSILON 0.00001f -> 0.0000124f can absorb accuracy errors, but if we need to resolve the accuracy error itself, we will need to use standard library's sinf/cosf instead of XMVectorSinCos.

Note that this issue does not occurs with VC compiler.

walbourn commented 3 years ago

The updated XDSP adopted XMVectorSinCos for vectorization. I noticed that compiling with clang LLVM would cause an accuracy error of about 1 bit and it would fail compareson on XDSPTest.

define TESTEPSILON 0.00001f -> 0.0000124f can absorb accuracy errors, but if we need to resolve the accuracy error itself, we will need to use standard library's sinf/cosf instead of XMVectorSinCos.

Note that this issue does not occurs with VC compiler.

Feel free to submit a PR for the test as well. It's pretty common to need to adjust epsilon between implementations. You should see what I hit originally moving from Intel to ARM :)

shinjich commented 3 years ago

Thanks Chuck, I'll submit a PR for the test later. As you pointed out, precision will be different between NEON and SSE.