Skip to content

r300: tweak constant vectorization (final fix for glamor on R400)

Pavel Ondračka requested to merge ondracka/mesa:R400_glamor into main

Vectorization can make the constant layout worse and increase the constant register usage. The worst scenario is vectorization of lowered indirect register access, where we access i-th element and later we access i-1 or i+1 (most notably used in glamor and gsk shaders). In this case we already added constants 1..n where n is the array size, however we can reuse them unless the lowered ladder gets vectorized later (and the vectors are not similar, e.g., (1,2,3,4) and (2,3,4,5) for example).

Thus prevent vectorization of the specific patterns from lowered indirect access.

This is quite a heavy hammer right now, with handtuned values. We could in theory estimate how many slots will the current ubos and constants need and only disable vectorization when we are close to the limit. However, this would likely need a global shader analysis each time r300_should_vectorize_inst is called, which we want to avoid.

So for now just don't vectorize anything that loads constants if we already have lot of uniforms (more than the 32 HW slots).

This is the final missing piece to make glamor work on R400.

shader-db R420:
total instructions in shared programs: 107288 -> 107290 (<.01%)
instructions in affected programs: 236 -> 238 (0.85%)
helped: 2
HURT: 3
total temps in shared programs: 17730 -> 17726 (-0.02%)
temps in affected programs: 41 -> 37 (-9.76%)
helped: 4
HURT: 0
total cycles in shared programs: 163251 -> 163251 (0.00%)
cycles in affected programs: 478 -> 478 (0.00%)
helped: 2
HURT: 3
GAINED: 7 (2 glamor and 5 GSK shaders)

RV370 is quite similar instruction/temp-wise, but we don't gain any shader there, because they are all over the 64 instructions limit...

Merge request reports