nouveau/nir: Allow up to 6 nested joins
authorM Henning <drawoc@darkrefraction.com>
Tue, 8 Feb 2022 06:00:02 +0000 (01:00 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 15 Apr 2022 01:22:03 +0000 (01:22 +0000)
This matches what the tgsi path does and doesn't regress any tests. (For
comparison, unlimited join nesting does regress tests in deqp and piglit)

Fixes graphical artifacts from stack overflows in
https://www.shadertoy.com/view/Xds3zN
with nir on kepler

Reviewed-by: Emma Anholt <emma@anholt.net>
Acked-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15597>

src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp

index f9703fe..192f2f5 100644 (file)
@@ -1485,9 +1485,9 @@ Converter::visit(nir_if *nif)
       insertJoins = insertJoins && bb->getExit()->op == OP_BRA;
    }
 
-   /* only insert joins for the most outer if */
-   if (--curIfDepth)
+   if (curIfDepth > 6) {
       insertJoins = false;
+   }
 
    /* we made sure that all threads would converge at the same block */
    if (insertJoins) {
@@ -1498,6 +1498,8 @@ Converter::visit(nir_if *nif)
       mkFlow(OP_JOIN, NULL, CC_ALWAYS, NULL)->fixed = 1;
    }
 
+   curIfDepth--;
+
    return true;
 }