I’m developing for the XBOX 360, and I use the pow() intrinsic in some lighting calculations.
6-8 years ago it used to be common to use a 1D lookup texture to approximate pow(). Does anyone still do that?
Is it worth trying this for the 6 year old XBOX 360, or is it unlikely to improve performance?
Use the
powinstruction (or the equivalent intrinsic function in HLSL). It takes 3 instruction slots, which indicates that it is reasonably quick.I haven’t sat down and figured out the exact cost of doing a lookup table. But you would struggle to find a useful implementation in fewer instruction slots. And obviously it requires a texture read (which is itself not free, and there’s a good chance it will be a dependent texture read and so quite slow).
(Additionally: if a lookup texture were a better choice, then the GPU could just implement the
powinstruction like that itself.)The reason that it used to be common to use a texture is that the
powinstruction did not exist for either vertex or pixel shaders in shader model 1.x. In 2.x and everything newer it is available (more instruction sets).