brw: Track the largest VGRF size in liveness analysis

We're already looking at this data to calculate the per-component
vars_from_vgrf[] and vgrf_from_vars[] mappings, so just record the
largest VGRF size while we're here.  This will allow passes to size
arrays based on the actual size needed, rather than hardcoding some
fixed size.  In many cases, MAX_VGRF_SIZE(devinfo) is larger than
necessary, because e.g. vec5 sparse sampling results aren't used.
Not hardcoding this means we can also temporarily handle very large
VGRFs which we know will be split eventually, without having to
increase the maximum which is ultimately used for RA classes.

Cc: mesa-stable
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34461>
(cherry picked from commit ea468412f6)
This commit is contained in:
Kenneth Graunke 2025-04-09 16:02:25 -07:00 committed by Eric Engestrom
parent 6c6c6873c4
commit c906f565b6
3 changed files with 6 additions and 1 deletions

View file

@ -1404,7 +1404,7 @@
"description": "brw: Track the largest VGRF size in liveness analysis",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -254,10 +254,13 @@ fs_live_variables::fs_live_variables(const fs_visitor *s)
num_vgrfs = s->alloc.count;
num_vars = 0;
max_vgrf_size = 0;
var_from_vgrf = linear_alloc_array(lin_ctx, int, num_vgrfs);
for (int i = 0; i < num_vgrfs; i++) {
var_from_vgrf[i] = num_vars;
num_vars += s->alloc.sizes[i];
max_vgrf_size = MAX2(max_vgrf_size, s->alloc.sizes[i]);
}
vgrf_from_var = linear_alloc_array(lin_ctx, int, num_vars);

View file

@ -111,6 +111,8 @@ public:
int num_vgrfs;
int bitset_words;
unsigned max_vgrf_size;
/** @{
* Final computed live ranges for each var (each component of each virtual
* GRF).