![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
Go to the source code of this file.
Namespaces | |
| namespace | Chaos |
| namespace | Chaos::Private |
This file contains a set of classes to help with SIMD data storage and operations on that data. E.g., sets of N 3-vectors are stored as 3 arrays of N floats (one for the X elements, one for Y, one for Z).
Arranging data this way allows us to process N datasets for the cost of 1, and eliminates the need to call any horizontal vector operations (such as is required for the summation in a dot product of two vectors).
Examples:
For a real-world example see methods in FPBDCollisionSolverSimd like SolvePositionNoFriction, SolvePositionWithFriction, and SolveVelocity.
// Hopefully your data is already stored in SIMD lanes, but if not you // can load it into SIMD registers with the factory functions and SetValue // methods. This should be avoided if possible.
FSimd4Realf R0; SimdR0.SetValue(0, -1); SimdR0.SetValue(1, 0); SimdR0.SetValue(2, 1); SimdR0.SetValue(3, 2); FSimd4Realf R1; SimdR1.SetValue(0, 3); SimdR1.SetValue(1, 4); SimdR1.SetValue(2, 5); SimdR1.SetValue(3, 6);
FSim4Selector IsR0GreaterThanZero = SimdGreater(R0, FSimd4Realf::Zero());
// If it's likely that all lanes will agree on IsGreaterZero, it may be worth // skipping the code block when possible. This will depend how expensive the // branch is vs the code we skip and the probability of doing so. FSimd4Realf R2 = FSimd4Realf::Zero(); if (SimdAnyTrue(IsR0GreaterThanZero)) { R2 = SimdSelect(IsR0GreaterThanZero, R0, R1); // -> (3,4,1,2) }