有人能帮我把这段代码翻译成人类可读的吗?
|704| assert(((uintptr_t)pSource & 0xF) == 0);
基本上这个断言在我的程序中失败了,但不是 100% 的时间(没有我重新编译任何东西),这很奇怪。
完整的XMLoadFloat4A
函数是(第 697 行 - DirectXMathConvert.inl):
|697| _Use_decl_annotations_
|698| inline XMVECTOR XM_CALLCONV XMLoadFloat4A
|699| (
|700| const XMFLOAT4A* pSource
|701| )
|702| {
|703| assert(pSource);
|704| assert(((uintptr_t)pSource & 0xF) == 0);
|705| #if defined(_XM_NO_INTRINSICS_)
|706| XMVECTOR V;
|707| V.vector4_f32[0] = pSource->x;
|708| V.vector4_f32[1] = pSource->y;
|709| V.vector4_f32[2] = pSource->z;
|710| V.vector4_f32[3] = pSource->w;
|711| return V;
|712| #elif defined(_XM_ARM_NEON_INTRINSICS_)
|713| return vld1q_f32_ex( reinterpret_cast<const float*>(pSource), 128 );
|714| #elif defined(_XM_SSE_INTRINSICS_)
|715| return _mm_load_ps( &pSource->x );
|716| #endif
|717| }
用例 :
// Convert an XMFLOAT4A to XMVECTOR
XMVECTOR getXMVECTORfromXMFLOAT4A(const XMFLOAT4A& v) {
return XMLoadFloat4A(&v);
}
XMVECTOR foo = getXMVECTORfromXMFLOAT4A(XMFLOAT4A(1.0, 2.0, 3.0, 1.0));
// Transform XMFLOAT4A with XMMATRIX
XMFLOAT4A XMFloat4Transform(const XMFLOAT4A& v, const XMMATRIX& m) {
XMVECTOR vec = XMLoadFloat4A(&v);
XMVECTOR rot = XMVector4Transform(vec, m);
XMFLOAT4A result;
XMStoreFloat4A(&result, rot);
return result;
}
XMMATRIX m = XMMatrixLookAtLH(...);
XMFLOAT4A foo (1.0, 2.0, 3.0, 1.0);
XMFLOAT4A bar = XMFloat4Transform(foo, m);
为什么这个断言失败了?为什么不是 100% 的时间?