Jump to content
  • Advertisement
Sign in to follow this  
Dirk Gregorius

Calling Convention (XNA Math)

This topic is 2704 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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!