[Mesa-dev] [PATCH] ir_to_mesa: Fix reallocating registers for shaders with loops

Ian Romanick idr at freedesktop.org
Sun Mar 27 16:23:13 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/27/2011 01:17 AM, Tom Stellard wrote:
> Registers that are used inside of loops need to be considered live
> starting with the very first instruction in the loop.
> 
> This fixes the following piglit tests on r300:
> - glsl-fs-loop-redundant-condition
> - glsl-vs-loop-redundant-condition
> - glsl-vs-vec4-indexing-temp-dst-in-loop
> 
> NOTE: This is a candidate for the 7.9 and 7.10 branches.

This is https://bugs.freedesktop.org/show_bug.cgi?id=34370.  There are a
couple patches already in the bug report.  The first one (by me) is a
hack.  The second one (by Fabian Bieler) seems better, but I haven't had
a chance to really review it yet.

We should resolve this and get one of the patches in soon.  I should be
able to review, test, and compare all three, but I won't get to it until
Tuesday.

> ---
>  src/mesa/program/prog_optimize.c |   17 ++++++++++++++---
>  1 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/program/prog_optimize.c b/src/mesa/program/prog_optimize.c
> index 96971f2..164297a 100644
> --- a/src/mesa/program/prog_optimize.c
> +++ b/src/mesa/program/prog_optimize.c
> @@ -937,24 +937,35 @@ update_interval(GLint intBegin[], GLint intEnd[],
>  		GLuint index, GLuint ic)
>  {
>     int i;
> +   GLuint begin = ic;
> +   GLuint end = ic;
>  
>     /* If the register is used in a loop, extend its lifetime through the end
>      * of the outermost loop that doesn't contain its definition.
>      */
>     for (i = 0; i < loopStackDepth; i++) {
>        if (intBegin[index] < loopStack[i].Start) {
> -	 ic = loopStack[i].End;
> +	 end = loopStack[i].End;
>  	 break;
>        }
>     }
>  
> +   /* Variables that are live at the end of a loop will also be live at the
> +    * beginning, so an instruction inside of a loop should have its live
> +    * interval begin at the start of the outermost loop.
> +    */
> +   if (loopStackDepth > 0 && ic > loopStack[0].Start && ic < loopStack[0].End) {
> +      begin = loopStack[0].Start;
> +   }
> +
>     ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
>     if (intBegin[index] == -1) {
>        ASSERT(intEnd[index] == -1);
> -      intBegin[index] = intEnd[index] = ic;
> +      intBegin[index] = begin;
> +      intEnd[index] = end;
>     }
>     else {
> -      intEnd[index] = ic;
> +      intEnd[index] = end;
>     }
>  }
>  
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk2PxuEACgkQX1gOwKyEAw+KqQCePDF9nV5ClztXFjokZhQSUCuP
QjsAoIceHefPsRVXylt5REoJMXQs9qRB
=UHfP
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list