Sign in to follow this  
Dirk Gregorius

Calling Convention (XNA Math)

Recommended Posts

The XNA Math library reads in its documentation:

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

[list][*] Use the [url=""]__fastcall[/url] calling conventions to pass the first three [b]__m128[/b] values ([url=""]XMVECTOR[/url] instances) as arguments to a function in a [b]SSE/SSE2[/b] register.[*] Pass on the stack any remaining [b]__m128[/b] values passed as arguments to a function.[/list]
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 [b]FXMVECTOR[/b] and [b]CXMVECTOR[/b] aliases are defined as follows:
For 32-bit Windows[/b]
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this