From: Brian P. <br...@vm...> - 2010-04-05 15:27:49
|
Nicolai Haehnle wrote: > Hi, > > On Mon, Apr 5, 2010 at 1:58 AM, Tom Stellard <tst...@gm...> wrote: >> 1. Improve branch emulation in the r300 compiler: >> The goal of this task will be to improve upon the work done by >> Nicolai Häehnle in this branch: >> http://cgit.freedesktop.org/~nh/mesa/log/?h=r300g-glsl and fully support >> branch emulation in the r300 compiler. This first part of this task >> will involve testing the current branch emulation code to determine what >> works and what does not. After this has been completed work can begin >> on any part of the branch emulation that does not work correctly. > > You misspelled my name :P > >> 2. Unroll loops in the r300 compiler: >> The goal of this task will be to unroll loops so that they can be executed >> by hardware that does not support them. The loop unrolling in this task >> is not meant as a code optimization. It is only being done to eliminate >> branch instructions. Loops where the number of iterations are known >> at compile time will be unrolled and may have additional optimizations >> applied. Loops that have an unknown number of iterations, will have to >> be studied to see if there is a way to replace the loop with a set of >> instructions that produces the same output as the loop. For example, >> one solution might be to replace an ADD(src0, src0) instruction that >> is supposed to execute n times with a MUL(src0, n). It is possible that >> not all loops will be able to be unrolled successfully. > > It is certain that not all loops will be able to be unrolled > successfully, if only due to limits on the number of instruction in a > shader ;) > > For loops with number of iterations determined at runtime, you should > check (ask around) for real-life shaders where this is the case. The > example you mention sounds unrealistic to me, but I could imagine that > there are shaders with an *upper-bound* on the number of iterations > known at compile time. Then loops can be unrolled to that upper-bound, > and later iterations could be masked off somehow based on the actual > desired number of iterations at runtime. See progs/glsl/CH18-mandel.frag for an example: for (iter = 0.0; iter < 12.0 && r2 < 4.0; ++iter) I believe the Phoronix Lightsmark demo also uses some loops in its shaders. It's not feasible to unroll all loops but some common cases are doable. -Brian |