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>
This commit is contained in:
Kenneth Graunke 2025-04-09 16:02:25 -07:00 committed by Marge Bot
parent 4a299bea27
commit ea468412f6
2 changed files with 5 additions and 0 deletions

View file

@ -477,6 +477,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).

View file

@ -246,10 +246,13 @@ brw_live_variables::brw_live_variables(const brw_shader *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);