Sunday, June 6, 2010

r300 Loop Emulation

I have been making good progress on implementing loop emulation for the r300 compiler. I just published a branch containing loop emulation code here: http://cgit.freedesktop.org/~tstellar/mesa/

Loops like for(i=0; i<10; i++), the compiler is able to figure out how many iterations the loop will have and then unroll it that many times. It can't handle every possible loop, but I think I have the most common ones covered. For the rest of the loops that don't have a known number of iterations at compile time, the compiler will just unroll the loop until it hits the maximum instruction limit.

4 comments:

  1. I hear the i945 series also lacks loops. Could this be applied in the i915 or i915g driver?

    Maybe you could make arbitrary looping work by returning the loop counter state to the CPU and running the shader multiple times?

    ReplyDelete
  2. What performance increase do you get with the loop emulation patches?

    ReplyDelete
  3. As a r300 owner(igp xpress 1150), i`d like to thank you by doing such a job!

    ReplyDelete
  4. I might be adding some loop unrolling code to the GLSL frontend which would help the other drivers, but I am not sure yet. If I do this, it will come at the end of the summer. The loop emulation code will not really increase performance, it just allows the GPU to execute shaders that it couldn't before.

    ReplyDelete