servo / webrender

A GPU-based renderer for the web
https://doc.servo.org/webrender/
Mozilla Public License 2.0
3.1k stars 276 forks source link

Gradients are broken with the Mac driver of my integrated GPU #1368

Closed mstange closed 6 years ago

mstange commented 7 years ago

On my machine, when the integrated GPU is use, repeating radial gradients are non-repeating, and non-repeating radial gradients are repeating. See bug 1372299 for testcases.

I'm on macOS 10.12.5 Beta (16F71b), Intel HD Graphics 530 1536 MB

glennw commented 7 years ago

It's possible that https://github.com/servo/webrender/pull/1328 or https://github.com/servo/webrender/pull/1348 may fix / work around this apparent driver bug. These changes modify how gradients are stored, into what is (probably) a more common driver path. After the next WR update lands in Gecko, we should check if this still occurs.

cc @staktrace

staktrace commented 7 years ago

@mstange you can try the build from https://treeherder.mozilla.org/#/jobs?repo=try&revision=671e529cecd8e824a08cdcde17b14edbdb44cd98 which should have the above PRs to see if it fixes the problem.

mstange commented 7 years ago

I tested the build, and the bug is still present.

kvark commented 7 years ago

@mstange could you provide an apitrace/renderdoc capture?

mstange commented 7 years ago

Maybe, but it would be a bit of work.

I can reproduce this bug by pinning my GPU to the integrated one and then running cargo run show reftests/gradient/radial-circle.yaml. You could do the same and then capture whatever trace you want on your machine :)

kvark commented 7 years ago

Ok, I'll do that next time I'm on Mac ;)

On Jun 15, 2017, at 16:27, Markus Stange notifications@github.com wrote:

Maybe, but it would be a bit of work.

I can reproduce this bug by pinning my GPU to the integrated one and then running cargo run show reftests/gradient/radial-circle.yaml. You could do the same and then capture whatever trace you want on your machine :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

kvark commented 7 years ago

@mstange do the WR's reftests report any errors for you?

mstange commented 7 years ago

Yes, but unfortunately that's due to #1394. I'll retest once that bug is fixed.

mstange commented 7 years ago

I've now updated to the release version of 10.12.5, and the issue still happens. If we can make a reduced testcase and submit a bug to Apple, they might fix it.

mstange commented 6 years ago

This shader change seems to "fix" the bug:

diff --git a/gfx/webrender/res/ps_radial_gradient.glsl b/gfx/webrender/res/ps_radial_gradient.glsl
--- a/gfx/webrender/res/ps_radial_gradient.glsl
+++ b/gfx/webrender/res/ps_radial_gradient.glsl
@@ -47,17 +47,17 @@ void main(void) {
     vStartCenter.y *= ratio_xy;
     vEndCenter.y *= ratio_xy;
     vTileSize.y *= ratio_xy;
     vTileRepeat.y *= ratio_xy;

     vGradientAddress = prim.specific_prim_address + VECS_PER_GRADIENT;

     // Whether to repeat the gradient instead of clamping.
-    vGradientRepeat = float(int(gradient.start_end_radius_ratio_xy_extend_mode.w) == EXTEND_MODE_REPEAT);
+    vGradientRepeat = float(int(gradient.start_end_radius_ratio_xy_extend_mode.w) != EXTEND_MODE_CLAMP);
 }
 #endif

 #ifdef WR_FRAGMENT_SHADER
 void main(void) {
     vec2 pos = mod(vPos, vTileRepeat);

     if (pos.x >= vTileSize.x ||

Very similar to https://github.com/servo/webrender/issues/1728#issuecomment-331227852.

mstange commented 6 years ago

My integrated GPU shows the same type of bug for linear gradients, and making the same corresponding change to ps_angle_gradient.glsl fixes that one as well.