Optimization question

Optimization question

I have a few question to know "how" I should write my methods. Can you tell me which one is the fast one ?By example to pass values to a method :1 - Passing float3 by pointer void mymethod(float3* a, float3* b, float3* result)....
2 - Passing float3 directly
void mymethod(float3 a, float3 b, float3* result)....3 - using "const" allowing the compiler to keep "a" and avoir a copy when entering into the method void mymethod(const float3 a, const float3 b, float3* result)....And to return values1 - By pointer void mymethod(float3* a, float3* b, float3* result).... float3 a; mymethod(&a);2 - By value float3 mymethod(float3* a, float3* b).... float3 a = mythod(...);

http://spectralbattle.wordpress.com/
3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Good questions. I'm also interestered in this!

In most of the cases the compiler will perform in-lining, hence there is no much differences.

If for some reason the compiler can't perform in-lining the following method is preferred.

float3 mymethod(float3,float3);

In any case, I advise you to use the "Offline compiler" tool and look for thex86 assembly.

Login to leave a comment.