ttn: Set nir->info.separate_shader
authorAlyssa Rosenzweig <alyssa@collabora.com>
Tue, 21 Jun 2022 17:00:42 +0000 (13:00 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 5 Jul 2022 17:38:54 +0000 (17:38 +0000)
TGSI has no legitimate[1] notion of linked shaders, which means tgsi_to_nir
should conservatively assume everything all shaders are separable. This requires
setting nir->info.separate_shader to warn drivers that shader CSOs might be
mixed and matched. Otherwise, the driver might enable optimizations that
are invalid for separate shaders, causing issues when the shaders are
later treated as separable.

This will fix varying linking with u_blitter's shaders on Panfrost (Bifrost and
older), when util_blitter_clear is used with Panfrost.

[1] There was a TGSI property added recently to forward
nir->info.separate_shader up to virglrenderer, but it's not actually used for
anything in virglrenderer and I am still struggling to understand what the use
case would be. My gut says we should revert b63403054237 ("tgsi: Add
SEPARABLE_PROGRAM property"), but I'm not interested in fighting that yak right
now. Notably, the u_blitter and hud shaders are separable but are not marked
with this property.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17282>

src/gallium/auxiliary/nir/tgsi_to_nir.c

index 1525462..a55f460 100644 (file)
@@ -2341,6 +2341,9 @@ ttn_compile_init(const void *tgsi_tokens,
    BITSET_SET32(s->info.samplers_used, scan.samplers_declared);
    s->info.internal = false;
 
+   /* Default for TGSI is separate, this is assumed throughout the tree */
+   s->info.separate_shader = true;
+
    for (unsigned i = 0; i < TGSI_PROPERTY_COUNT; i++) {
       unsigned value = scan.properties[i];