Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualRobTheBloke

Posted 23 October 2013 - 06:37 PM

Don't profile code, profile apps. Pass vectors by value, not reference (although that only works for the first 3 or so args, the rest will need to be by reference). Forceinline is just stupid. Stop using it. Stop constantly assigning things to V & T - It just introduces dependency chains for no good reason. Don't fear the use of multiple variables - they'll just end up as registers instead... 

 

const float x = (a.y*b.z) - (b.y*a.z);
const float y = (a.z*b.x) - (b.z*a.x);
const float z = (a.x*b.y) - (b.x*a.y);
const float w = (0 * 0) - (0 * 0);
 
4 shuffles, 2 mults, 1 sub = obvious, and better! ;)

#2RobTheBloke

Posted 23 October 2013 - 06:37 PM

Don't profile code, profile apps. Pass vectors by value, not reference (although that only works for the first 3 or so args, the rest will need to be by reference). Forceinline is just stupid. Stop using it. Stop constantly assigning things to V & T - It just introduces dependency chains for no good reason. Don't fear the use of multiple variables - they'll just end up as registers instead... 

 

<span  style="color:rgb(0,0,136)">const</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(0,0,136)">float</span><span  style="color:rgb(0,0,0)"> x </span><span  style="color:rgb(102,102,0)">=</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">(</span><span  style="color:rgb(0,0,0)">a</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">y</span><span  style="color:rgb(102,102,0)">*</span><span  style="color:rgb(0,0,0)">b</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">z</span><span  style="color:rgb(102,102,0)">)</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">-</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">(</span><span  style="color:rgb(0,0,0)">b</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">y</span><span  style="color:rgb(102,102,0)">*</span><span  style="color:rgb(0,0,0)">a</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">z</span><span  style="color:rgb(102,102,0)">);</span>
<span  style="color:rgb(0,0,136)">const</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(0,0,136)">float</span><span  style="color:rgb(0,0,0)"> y </span><span  style="color:rgb(102,102,0)">=</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">(</span><span  style="color:rgb(0,0,0)">a</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">z</span><span  style="color:rgb(102,102,0)">*</span><span  style="color:rgb(0,0,0)">b</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">x</span><span  style="color:rgb(102,102,0)">)</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">-</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">(</span><span  style="color:rgb(0,0,0)">b</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">z</span><span  style="color:rgb(102,102,0)">*</span><span  style="color:rgb(0,0,0)">a</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">x</span><span  style="color:rgb(102,102,0)">);</span>
<span  style="color:rgb(0,0,136)">const</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(0,0,136)">float</span><span  style="color:rgb(0,0,0)"> z </span><span  style="color:rgb(102,102,0)">=</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">(</span><span  style="color:rgb(0,0,0)">a</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">x</span><span  style="color:rgb(102,102,0)">*</span><span  style="color:rgb(0,0,0)">b</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">y</span><span  style="color:rgb(102,102,0)">)</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">-</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">(</span><span  style="color:rgb(0,0,0)">b</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">x</span><span  style="color:rgb(102,102,0)">*</span><span  style="color:rgb(0,0,0)">a</span><span  style="color:rgb(102,102,0)">.</span><span  style="color:rgb(0,0,0)">y</span><span  style="color:rgb(102,102,0)">);</span>
<span  style="color:rgb(0,0,136)">const</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(0,0,136)">float</span><span  style="color:rgb(0,0,0)"> w </span><span  style="color:rgb(102,102,0)">=</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">(</span><span>0 </span><span  style="color:rgb(102,102,0)">* </span><span>0</span><span  style="color:rgb(102,102,0)">)</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">-</span><span  style="color:rgb(0,0,0)"> </span><span  style="color:rgb(102,102,0)">(</span><span>0 * 0</span><span  style="color:rgb(102,102,0)">);</span>
 
4 shuffles, 2 mults, 1 sub = obvious, and better! ;)

#1RobTheBloke

Posted 23 October 2013 - 06:32 PM

Don't profile code, profile apps. Pass vectors by value, not reference (although that only works for the first 3 or so args, the rest will need to be by reference). Forceinline is just stupid. Stop using it. Stop constantly assigning things to V & T - It just introduces dependency chains for no good reason. Don't fear the use of multiple variables - they'll just end up as registers instead... 


PARTNERS