Jump to content
  • Advertisement
Sign in to follow this  
Mezz

D3DXMATRIXA16 and std::vector

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

I have a problem that basically I am stumped on. It goes a little something like this.
#include <vector>
#include <Windows.h>
#include <d3dx9.h>

class Bullshit
{
public:
    D3DXMATRIXA16 m_mat;
};

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    std::vector <Bullshit> vec;
    return(0);
}

That's the little test program I made to ensure I wasn't insane. When I compile it, I get this error:
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\vector(507) : error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned
        d:\Mezz\Poo\App.cpp(14) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
        with
        [
            _Ty=Bullshit
        ]
If I take out the matrix member, it's fine. If I make it a vector of pointers to the class, it's fine. But why doesn't it work like that? I would prefer to use a 16-byte aligned matrix if possible... -Mezz

Share this post


Link to post
Share on other sites
Advertisement
I was just struggling a bit with a similar issue - then it occurred to me that, yeah, how could a function (or template) parameter be 16-byte aligned? Sure it could be, but it's not guarenteed, thus attempts to do SSE/SSE2 ops on the incoming argument could fault.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!