Skip to main content
gamedev.net
🔒 Locked

XNA Math

Started by Quat 2 replies 1.7k views
Original Post
Quat
Quat
The documentation for XMVECTORF32 says:

Quote:

An opaque, portable type to support the use of C/C++ initializer syntax to load floating-point values into an instance of XMVECTOR type.


However, I do not see the difference between these two lines of code:

XMVECTOR  g = {1.0f, 2.0f, 3.0f};00221B1B  movss       xmm0,dword ptr [__real@3f800000 (22976Ch)] 00221B23  movss       dword ptr [ebp-20h],xmm0 00221B28  movss       xmm0,dword ptr [__real@40000000 (229768h)] 00221B30  movss       dword ptr [ebp-1Ch],xmm0 00221B35  movss       xmm0,dword ptr [__real@40400000 (229764h)] 00221B3D  movss       dword ptr [ebp-18h],xmm0 00221B42  xor         eax,eax 00221B44  mov         dword ptr [ebp-14h],eax XMVECTORF32  g2 = {-1.0f, -2.0f, -3.0f};00221B47  movss       xmm0,dword ptr [__real@bf800000 (229760h)] 00221B4F  movss       dword ptr [ebp-40h],xmm0 00221B54  movss       xmm0,dword ptr [__real@c0000000 (22974Ch)] 00221B5C  movss       dword ptr [ebp-3Ch],xmm0 00221B61  movss       xmm0,dword ptr [__real@c0400000 (22A868h)] 00221B69  movss       dword ptr [ebp-38h],xmm0 00221B6E  xor         eax,eax 00221B70  mov         dword ptr [ebp-34h],eax 
-----Quat
Evil Steve
Evil Steve
Why would you expect to see any difference? The two lines are syntactically the same.
jpetrie
jpetrie
The XMVECTORF32 documentation also states: "[XMVECTORF32] is necessary to support XMVECTOR, as it does not itself support initializers, for portability and optimization reasons." Is that why you expect there to be some difference in that code, other than the actual values loaded?

Despite the claims of the documentation, the actual definition of XMVECTOR is gated by several preprocessor definitions, some combination of which do cause it to be resolved to something that does happen to support initializers in some form. That's probably what you're seeing here, unless you're expecting something completely different.
Quat
Quat
Quote:

The XMVECTORF32 documentation also states: "[XMVECTORF32] is necessary to support XMVECTOR, as it does not itself support initializers, for portability and optimization reasons." Is that why you expect there to be some difference in that code, other than the actual values loaded?


Yes, I was expecting to either get a compiler error because initialization would not be supported, or I was expecting the initialization to not work as expected (some garbage values get put in for the vector components), or the way the vector would be loaded would generate different assembly (one using SSE2 and the other not).


On my system, Vista-32, but 64-bit CPU, typedef __m128 XMVECTOR;

So __m128 supports initialization syntax on this platform, but might not on other platforms like XBox 360?

Basically, the documentation said to use XMVECTORF32 to initialize constants. So i did the test above and didn't see any difference, so I am trying to understand why we should use XMVECTORF32 instead of XMVECTOR for constants when it appears to make no difference.



-----Quat

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.