1

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?

Olhovsky
  • 5,466
  • 3
  • 36
  • 47
  • Are you actually pixel-shader limited anyway? Removing individual instructions is very much a micro-optimisation. Even if you are pixel-shader limited you can probably find better place to improve performance. – Andrew Russell Apr 28 '11 at 05:03
  • I'm trying to fit another point light or two into the scene, yes. – Olhovsky Apr 28 '11 at 11:13

1 Answers1

3

Use the pow instruction (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 pow instruction like that itself.)

The reason that it used to be common to use a texture is that the pow instruction 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).

Andrew Russell
  • 26,924
  • 7
  • 58
  • 104
  • I don't know anything about the 360's GPU, but lookup textures are [still relevant](http://www.google.com/url?sa=t&rct=j&q=2001+all+voer+again+aras&source=web&cd=1&ved=0CCYQFjAA&url=http%3A%2F%2Faras-p.info%2Fblog%2F2011%2F02%2F01%2Fios-shader-tricks-or-its-2001-all-over-). –  Feb 01 '12 at 21:28