From 90f29c4458853419c6173145b49dca2f0164c5a5 Mon Sep 17 00:00:00 2001 From: Jamie Nicol Date: Mon, 19 Jul 2021 21:17:07 +0000 Subject: [PATCH] Bug 1720841 - Clamp loop condition variable to static value in cs_blur. r=gw In the cs_blur fragment shader there is a for loop with a number of iterations determined by a flat varying. On some old Adreno drivers this causes severe issues including hangs and crashes. These can be avoided by clamping the number of iterations to a statically known value. Differential Revision: https://phabricator.services.mozilla.com/D120281 --- gfx/wr/webrender/res/cs_blur.glsl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gfx/wr/webrender/res/cs_blur.glsl b/gfx/wr/webrender/res/cs_blur.glsl index 17413537c376..e3aaa40be062 100644 --- a/gfx/wr/webrender/res/cs_blur.glsl +++ b/gfx/wr/webrender/res/cs_blur.glsl @@ -154,8 +154,12 @@ void main(void) { // // for some t. So we can let `t = k1/(k0 + k1)` and effectively evaluate // Equation 1 with a single texture lookup. - - for (int i = 1; i <= vSupport; i += 2) { + // + // Clamp loop condition variable to a statically known value to workaround + // driver bug on Adreno 3xx. vSupport should not exceed 300 anyway, due to + // the max blur radius being 100. See bug 1720841 for details. + int support = min(vSupport, 300); + for (int i = 1; i <= support; i += 2) { gauss_coefficient.xy *= gauss_coefficient.yz; float gauss_coefficient_subtotal = gauss_coefficient.x;