D3DXVec3 - Normalize, TransformCoord: Using same vector

Started by
0 comments, last by EvilDecl81 19 years, 3 months ago
How safe is it to pass in the same address to each parameter of such functions? Can it be assumed that they will work whether the out vector is the same as the in vector? Are certain optimizations made if they are different? Example:

D3DXVec3TransformCoord(&vRotateMe,&vRotateMe,&mRotation); //Safe?

D3DXVec3Normalize(&vNormal, &vNormal);  //Safe?  I think it is at least..
Thanks for your input!
Advertisement
Quote:Original post by n0ob
How safe is it to pass in the same address to each parameter of such functions? Can it be assumed that they will work whether the out vector is the same as the in vector? Are certain optimizations made if they are different? Example:

D3DXVec3TransformCoord(&vRotateMe,&vRotateMe,&mRotation); //Safe?D3DXVec3Normalize(&vNormal, &vNormal);  //Safe?  I think it is at least..


Thanks for your input!


They will work fine if the output is the same as the input. For some routines, e.g. matrix multiply, there will be a small perf hit since it will have to make an internal copy. This isn't true for D3DXVec3TransformCoord, however, since the internal copy can be staged in the FPU registers.

For best performance, use the array version of these functions if possible. They can be much faster (general call overhead as well as keeping parts of the matrix stored in registers).



EvilDecl81

This topic is closed to new replies.

Advertisement