[Mesa-dev] RFC: r300 compiler loop emulation

Brian Paul brianp at vmware.com
Mon Jun 7 07:38:15 PDT 2010


Tom Stellard wrote:
> Hi,
> 
> I have just published a branch with loop emulation for the r300
> compiler here: http://cgit.freedesktop.org/~tstellar/mesa/ 
> 
> This adds support for unrolling of loops that have a constant number of
> iterations (e.g. for(i=0; i<10; i++) or for(i=10; i>0; i--)
> It only handles cases where the counter is either added to or subtracted
> from, like the examples above, but I think this covers a majority
> of loops.
> 
> Loops that have an unknown number of iterations are unrolled as many
> times as possible without going over the instruction limit for the
> shader program.
> 
> Right now, this is only enabled for fragment shaders, but I am working on
> enabling it for vertex shaders.
> 
> Any comments/suggestions would be appreciated.  Thanks.

Is there any advantage to doing this in the r300 compiler instead of 
the GLSL compiler?  The GLSL compiler already does loop unrolling in 
some cases.  If we do it in the GLSL compiler, all the drivers can 
benefit.

-Brian



More information about the mesa-dev mailing list