Support for WebAssembly SIMD Intrinsics (v128) and Rust Integration
DirectXMath supports SIMD on architectures such as SSE2 but does not support WebAssembly SIMD intrinsics using the v128 type. As a header-only library that compiles with any standard C++20 compiler, I successfully compiled it with Clang targeting WebAssembly but found no intrinsic support for WebAssembly SIMD.
I prefer DirectXMath over other libraries (such as GLM) because it is released under the MIT License, supports major SIMD instruction sets, and offers useful functions for software rendering.
My main use case for DirectXMath is software-based rendering (rasterization and ray tracing) targeting outputs such as:
Win32 (GDI)
Direct2D
HTML Canvas via WebAssembly
BMP files
Could you consider adding support for WebAssembly SIMD intrinsics using the v128 type? Also, with Microsoft’s recent focus on Rust, are there any plans for official Rust support or bindings in DirectXMath?
Thank you for your consideration.
I actually did port this to WebAssembly in my repository and this is pretty simple to do
Can you provide a PR as to what you had to change for reference?
Hi, I’m interested in working on WebAssembly SIMD support and/or Rust bindings for DirectXMath. Is anyone else working on this? Any tips before I dive in?
Can you provide a PR as to what you had to change for reference?
Sure, I'd do that as soon as I can.
It took me longer than expected to create this minimally working demo project for anyone it may help.
I built a C++ source file using DirectXMath into a WASM binary and integrated it with JavaScript. The extra time went into providing clear explanations, thorough documentation, and assembling the minimally needed components (e.g., additional dummy headers).
I hope it is at least somewhat useful.
P.S. It may be possible to use XMFLOAT3 directly; I'm not sure about XMVECTOR.
It may also be possible to use the LLVM (Clang/LLVM) toolchain integrated with Microsoft Visual Studio 2022.
The Visual Studio compiler team may consider adding support for WebAssembly as a compilation target, similar to how LLVM does.