Jump to content
  • Advertisement
Sign in to follow this  
G-Man9566

Using VXA/SSE in game programming

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

Hi,

1. I want to know if someone can tell me if it is common to use SSE or the newer VXA to do matrix and vector calculations for games?

2. Does D3DX make use of SSE/VXA when calling functions like D3DXMatrixMultiply or when doing any arithmetic on D3DXMATRIX or D3DXVECTOR? If not, I'm assuming one has to explicitely implement SSE on your matrix and vector arithmetic.

3. If D3DX does not implement SSE/VXA implecitely, where can I start to look into SSE? Apparently Intel has an SSE/VXA lib?

Im currently using D3DXMATRIX and D3DVECTOR to store and manipulate my matrices and vertices and Im just contemplating if it is the fastest structure to use.

Share this post


Link to post
Share on other sites
Advertisement
1) YES VERY! But there are a LOT of caveats. See, it isn't so quick to actually be shuffling things back and forth from vector registers to cpu registers. So if you don't have enough work to do, it costs more time to setup the vector operations than to just work in the fpu.
There is a LOT of gameplay code where you end up doing things like:
AddVec( a, b );
if( a.y <= groundHeight ) do splat!

and so any gains you'd get from using SSE/VMX in the Add are instantly lost when you try to retrieve a.y.

So, you'll see the vectorized code in places where it counts: Particle Systems, Skeletal Animation systems, Physics Systems. All of those systems can manage to really stream though a lot of data in the vector unit without ever having to pull it back into the fpu.

2) iirc, yes it can and does.

3) Sony's Math Lib was released through the Bullet Physics SDK. It is a very well done and complete library if you wanted to look into it.

Share this post


Link to post
Share on other sites
KulSeran, so if I understand you correctly, D3DXMATRIX and D3DXVECTOR uses/implements SSE? So then I dont need to go and explicitely implement it if I use those 2 data structures.

Share this post


Link to post
Share on other sites
Those structs are defined in the header files, so you can see most of the code there if you want. There are also aligned variants (eg D3DXMATRIXA16) Some of the big operations like matrix multiply and inverse use SIMD instructions, but most of the simple vector ops are simple inline C code, because vectorized code doesn't help there.

Share this post


Link to post
Share on other sites
Quote:
Original post by G-Man9566
1. I want to know if someone can tell me if it is common to use SSE or the newer VXA to do matrix and vector calculations for games?


SSE is extremely common. AVX (not VXA) is brand new, and is likely to gain some ground given time, but for the time being I doubt many people have done a huge amount with the instruction set. SSE4.1 Still has it's place though, and for most people would be where the dev effort still goes (since pretty much every PC will support SSE, not so many support AVX as yet).

Quote:
Original post by G-Man9566
2. Does D3DX make use of SSE/VXA when calling functions like D3DXMatrixMultiply or when doing any arithmetic on D3DXMATRIX or D3DXVECTOR? If not, I'm assuming one has to explicitely implement SSE on your matrix and vector arithmetic.


It certainly used to (postfixed with 'A'), but not sure of the current version. I imagine you should be able to beat the performance in most cases with your own SSE code though (since it doesn't seem to care about alignment, so I'm guessing it loads/stores using the un-aligned versions? It's been a while since I used D3DX)

Quote:
Original post by G-Man9566
3. If D3DX does not implement SSE/VXA implecitely, where can I start to look into SSE? Apparently Intel has an SSE/VXA lib?


As does AMD.... (lacking quats IIRC)

As for looking into SSE
Agner's blog
msdn
Intel optimization manual

Share this post


Link to post
Share on other sites
Quote:
Original post by RobTheBloke
It certainly used to (postfixed with 'A'), but not sure of the current version. I imagine you should be able to beat the performance in most cases with your own SSE code though (since it doesn't seem to care about alignment, so I'm guessing it loads/stores using the un-aligned versions? It's been a while since I used D3DX)


The newer XNA Math library for DX has 'aligned' versions of the various structs etc which I would guess get dumped via the aligned instructions, however if using those as members of your own classes you have to be careful as you need to make sure the aligned versions ARE aligned or you'll get weird and wonderfull crashes and access errors.

(This is something I ran into recently as you might have guessed, took a few minutes to figure out why a simple vector assignment was blowing up in my face then I realised wtf was going on [grin])

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!