Jump to content
  • Advertisement
Sign in to follow this  
zqueezy

sse another problem

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

hey folks, this is more like a quick question. I know that my sse matrix has to be 16-byte-aligned. and I put the __declspec(align(16)) before my class. I works well with matrices on the stack! I know when I want to get them dynamically I have to use _aligned_malloc. The question now: I have a class (an enemy) which has a matrix as a member variable which will not be aligned automatically. I create this enemy with a new-statement. when I change to "_aligned_malloc" for the enemy-class it works alright but it's pretty ugly cause I have to call the constructor again explicitly. Is there a way to automatically align a member variable? some #pragma pack?? (I don't really get the pragma pack) any ideas? thx in advance <code> class Enemy { ... matrix4x4 m_MtxOrientation; // <-- not aligned! }; </code>

Share this post


Link to post
Share on other sites
Advertisement
Option 1: define an operator new for your Enemy class which internally calls _aligned_malloc. Option 2: provide a MemberMatrix object which is in fact a reference to a correctly aligned matrix on the heap, with a COW implementation.

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!