Sign in to follow this  
Lee_Hillvith

Get error when I try to use XMMATRIX type as an function variable

Recommended Posts

Lee_Hillvith    143
Hi gentlemen,

There is a function in my class for some rendering job, and I would like to pass two matrix , view and projection from my Camera class to this external function.

its prototype is like

[source lang="cpp"]Draw(ID3D11Device* device, XMMATRIX view, XMMATRIX projection)

{

//......

......//

}[/source]

I get error messages like

[source lang="cpp"]Error 10 error C2719: 'view': formal parameter with __declspec(align('16')) won't be aligned[/source]

I 've googled and some say it's a known vector and Align data issue and MS will fix this in VC11.

Any idea How I can fix this?

Thank you and have a nice day!

Share this post


Link to post
Share on other sites
Necrolis    1464
Trying passing by reference or a pointer, the error occurs because the compiler cannot guarantee the alignment of function parameters passed on the stack (technically it can, but VS2010 and lower have horrible stack alignment handling). the alternative is to covert to a XMFLOAT4X4 which has no alignment requirement, but this adds extra overhead and painful conversion code.

Share this post


Link to post
Share on other sites
kubera    1587
[source lang="cpp"]Draw(ID3D11Device* device, XMMATRIX & view, XMMATRIX & projection)
Draw(ID3D11Device* device, XMMATRIX * view, XMMATRIX * projection)
[/source]
Will work also.

Please, consider reading that thread.
[url="http://xboxforums.create.msdn.com/forums/t/84299.aspx"]http://xboxforums.cr...ms/t/84299.aspx[/url]

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