Jump to content
  • Advertisement

DX12 Returning XMMATRIX & XMVECTOR from a function

Recommended Posts

As far as I know, the size of XMMATRIX must be 64 bytes, which is way too big to be returned by a function. However, DirectXMath functions do return this struct. I suppose this has something to do with the SIMD optimization. Should I return this huge struct from my own functions or should I pass it by a reference or pointer?

This question will look silly to you if you know how SIMD works, but I don't.

Share this post

Link to post
Share on other sites

DirectXMath uses the vectorcall calling convention that's available in VC++, which allows returning values in XMM0 through XMM3. This is enough to fit a 4x4 matrix, so even if the functions aren't inlined the return value doesn't have to go on the stack.

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

  • 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!