Sign in to follow this  
Dirk Gregorius

Calling Convention (XNA Math)

Recommended Posts

The XNA Math library reads in its documentation:

[quote][b]
For 32-bit Windows[/b]To make full use of available [b]SSE/SSE2[/b] functionality, passing [url="http://msdn.microsoft.com/en-us/library/ayeb3ayc.aspx"]__m128[/url] values (which implements [url="http://msdn.microsoft.com/en-us/library/ee420742%28v=VS.85%29.aspx"]XMVECTOR[/url] on that platform) to an inline routine, you need to do the following:

[list][*] Use the [url="http://msdn.microsoft.com/en-us/library/6xa169sk%28VS.71%29.aspx"]__fastcall[/url] calling conventions to pass the first three [b]__m128[/b] values ([url="http://msdn.microsoft.com/en-us/library/ee420742%28v=VS.85%29.aspx"]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:
[b]
For 32-bit Windows[/b]
typedef const XMVECTOR FXMVECTOR;
typedef const XMVECTOR& CXMVECTOR;


[/quote]

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?

Thanks,
-Dirk

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