Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFix an issue on some nvidia cards with texelFetch. #3073
Conversation
|
r? @kvark This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1491911 Surprisingly enough, this doesn't seem to have broken anything on a try: It's still pending but so far no changes on Linux and a new PASS in OSX. |
|
Yep, try run looks good. |
|
I added an entry in the driver issues page. The entry is a bit hand-wavey and it'd be sad if we have to give up on texelFetch. Don't hesitate to add more information. |
|
@nical that entry link is broken, FYI |
| void write_clip(vec4 world_pos, ClipArea area) { | ||
| vec2 uv = world_pos.xy * uDevicePixelRatio + | ||
| void write_clip(vec4 world_pos, vec2 snap_offset, ClipArea area) { | ||
| vec2 uv = snap_offset + world_pos.xy * uDevicePixelRatio + |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| ivec3 tc = ivec3(mask_uv, vClipMaskUv.z); | ||
| return texelFetch(sCacheA8, tc, 0).r; | ||
|
|
||
| // TODO(gw): texelFetch here fails on some nVidia hardware in |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
In the do_clip() function, texelFetch is sometimes returning invalid results on some nVidia GPUs. To work around that, use UVs as normalized float coordinates and fetch via texture(). This fixes the problems on nVidia cards. This exposed a bug in how we handle vertex snapping with clips. Previously, we just cast the float UVs to an int before passing to texelFetch. Now, pass in the snap offset and apply that to the UVs for the clip mask.
|
@kvark Thanks for the review, this is ready to go now, I think. |
|
webrender/res/prim_shared.glsl, line 268 at r2 (raw file):
we can at least use the LOD-selecting variant |
webrender/res/prim_shared.glsl, line 268 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Does that make any difference, when we know the sCacheA8 texture never has mips? Maybe it's a theoretical performance hint to the driver? |
|
@bors-servo r=kvark |
|
|
Fix an issue on some nvidia cards with texelFetch. In the do_clip() function, texelFetch is sometimes returning invalid results on some nVidia GPUs. To work around that, use UVs as normalized float coordinates and fetch via texture(). This fixes the problems on nVidia cards. This exposed a bug in how we handle vertex snapping with clips. Previously, we just cast the float UVs to an int before passing to texelFetch. Now, pass in the snap offset and apply that to the UVs for the clip mask. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3073) <!-- Reviewable:end -->
|
|
|
@jrmuizel found out that this PR fixes a few reftests on Gecko side that aren't related to NVidia, and are reproducible on both OSX and Windows. It means that we weren't doing the Re-reading the patch, I noticed a few things. First, the new code doesn't sample the same texels: since we are using the nearest sampling now, we are rounding up the sampling coordinate (e.g. 0.7 -> 1.0). Secondly, the old code wasn't properly clamping the upper sampling bounds: bvec4 inside = lessThanEqual(
vec4(vClipMaskUvBounds.xy, mask_uv),
vec4(mask_uv, vClipMaskUvBounds.zw));Notice the second part of comparison - it would pass even if With this in mind, there is a hope that we aren't really seeing a driver bug here. I'll prepare a patch to test things out. |
|
@gw3583 I missed this one:
The texture doesn't have mips, right, so the texture unit knows it doesn't need to load them at run-time. But the shader compiler doesn't know that, and can't possibly (since the texture can be changing at run-time). In modern GPUs, the LOD selection appears to be computed with shader instructions, according to Humus:
It would be great to confirm with something like a shader analyzer, but the reasoning is sound to me, and I see no downside to use Also, interesting (distantly related) tip from a similar document:
|
--HG-- extra : rebase_source : 7d090510f12caceaff8c2329e47871dbb5f4de55
Bring back texelFetch from clip surface This PR reverts #3073, leaves the snapping offsets around, and fixes the concern spotted in #3073 (comment) Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=2fce2addd97b66f044ecc83a46c7f45b53dc5381&selectedJob=200247696 WIP because: needs @gw3583 to check if it fixes their test on Nvidia GPU. cc @jrmuizel <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3086) <!-- Reviewable:end -->
UltraBlame original commit: 16995931c819acec7bbf665fe635da7430602c85
UltraBlame original commit: 25b839b8e6a98334398c16a89aa03009481a640e
UltraBlame original commit: 16995931c819acec7bbf665fe635da7430602c85
UltraBlame original commit: 25b839b8e6a98334398c16a89aa03009481a640e
UltraBlame original commit: 16995931c819acec7bbf665fe635da7430602c85
UltraBlame original commit: 25b839b8e6a98334398c16a89aa03009481a640e
gw3583 commentedSep 18, 2018
•
edited by larsbergstrom
In the do_clip() function, texelFetch is sometimes returning
invalid results on some nVidia GPUs.
To work around that, use UVs as normalized float coordinates
and fetch via texture(). This fixes the problems on nVidia
cards.
This exposed a bug in how we handle vertex snapping with clips.
Previously, we just cast the float UVs to an int before passing
to texelFetch. Now, pass in the snap offset and apply that to
the UVs for the clip mask.
This change is