Skip to content

nir/inline_uniforms: support loop

Qiang Yu requested to merge yuq825/mesa:topic/inline-uniform-loop into main

Be able to inline uniforms in loop for unrolling it. Nested loop/if is also supported.

Some example:

    for (i = 0; i < count; i++)
        ...

uniform "count" will be inlined. But note this does not make sure the loop will be unrolled (ie. count = 1000).

    for (i = 0; i < count; i++)
        for (j = init; j < 10; j++)
            if (type == 2)
                ...

uniform "count", "init" and "type" will be inlined.

It is intentional to not be too aggressive to add uniforms to avoid false positive case while be able to support most common usage.

Similar MR: !8687 (closed)

CC: @mareko

v2: support vector uniform

v3: filter out some cases which loop unroll pass does not support, like:

  • for (i = 0; i + 1 < count; i++)
  • for (i = 1; i < count; i *= 2)
Edited by Qiang Yu

Merge request reports

Loading