HLSL d3dcompiler_47 problems

Started by
1 comment, last by ericrrichards22 9 years, 2 months ago

Just wana say that I just discovered that using length(), distance() and "/" division operator is a bad idea, using dot() and pow() is faster and more accurate. Why is the compiler not optimizing that?

to get the length of a vector "v"


l = pow(dot(v,v),0.5f);

if you need to divide a position by the length of "v"


p*pow(dot(v,v),-0.5f) 
Advertisement

How do you know it's not optimizing it?

Did you actually benchmark the different methods, and if so what GPU and driver were you using?

Any output from the HLSL compiler is some form of cross-platform ASM and I'm pretty sure the driver will re-arrange it in all kinds of ways depending on the underlying architecture.

Curious what kind of hardware this is running on. If there is really any difference, I would suspect that is comes down to particular optimizations in the hardware or possibly the drivers.

Assuming that you can naively expand things out algebraically, these should be the same, barring any specific hardware optimized to compute vector dot-products or exponentiation.

I will admit I am not overly familiar with specialized silicon-level components, beyond the simple adder and multiplier circuits I had to learn in my computer architecture courses.

Eric Richards

SlimDX tutorials - http://www.richardssoftware.net/

Twitter - @EricRichards22

This topic is closed to new replies.

Advertisement