• Advertisement
Sign in to follow this  

Calling Convention (XNA Math)

This topic is 2590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The XNA Math library reads in its documentation:

For 32-bit Windows
To make full use of available SSE/SSE2 functionality, passing __m128 values (which implements XMVECTOR on that platform) to an inline routine, you need to do the following:

  • Use the __fastcall calling conventions to pass the first three __m128 values (XMVECTOR instances) as arguments to a function in a SSE/SSE2 register.
  • Pass on the stack any remaining __m128 values passed as arguments to a function.
    The following are example declarations that illustrate this convention:

    XMMATRIX XMMatrixLookAtLH(FXMVECTOR EyePosition, FXMVECTOR FocusPosition, FXMVECTOR UpDirection);
    XMMATRIX XMMatrixTransformation2D(FXMVECTOR ScalingOrigin, FLOAT ScalingOrientation, FXMVECTOR Scaling, FXMVECTOR RotationOrigin, FLOAT Rotation, CXMVECTOR Translation);

    To support these calling conventions, the FXMVECTOR and CXMVECTOR aliases are defined as follows:

    For 32-bit Windows

    typedef const XMVECTOR FXMVECTOR;
    typedef const XMVECTOR& CXMVECTOR;


    Question: Why aren't the functions declared using the __fastcall convention? E.g. XMMATRIX __fastcall XMMatrixLookAtLH(...). Is this not necessary and happens automatically or do they assume the global compiler settings to use __fastcall as default? How do I make sure that the first three arguments are passed in registers if I would write my own function similar to one found in the XNA math library?


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement