# D3DXVec3 - Normalize, TransformCoord: Using same vector

This topic is 4796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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..


##### Share on other sites
Quote:
 Original post by n0obHow 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).