Skip to main content
gamedev.net
🔒 Locked

D3DXVec3 - Normalize, TransformCoord: Using same vector

Started by n0ob 0 replies 2.9k views
Original Post
n0ob
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!
EvilDecl81
EvilDecl81
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.