Stop using instancing in WebRender
Categories
(Core :: Graphics: WebRender, enhancement)
Tracking
()
People
(Reporter: kvark, Assigned: kvark)
References
Details
Attachments
(4 files, 2 obsolete files)
There is information telling that our use of instancing may not be most efficient: https://www.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau
Slide 19 says "Don't use DrawInstanced for creating sprites on AMD or NV hardware".
What we could do instead is - provide the instance data in shader storage buffers. According to wiki, they are in OpenGL ES 3.1 core, and available as https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shader_storage_buffer_object.txt extension elsewhere. Angle should not have a problem supporting this either, although I haven't checked specifically yet.
We'd then issue regular DrawIndexed
calls instead of the instanced ones. The vertex shader would then compute something like uint instanceId = gl_VertexId / 4;
, and fetch the instance data from the storage buffer.
Once problem with this approach is the index buffer. Unless "base vertex" semantics is supported (e.g. glDrawElementsBaseVertex
), we'd need the index buffer to be big, and used for all draw calls, and we'll need to potentially cut batches that are too big and not fitting into the index buffer range.
A nice side effect from this change is that we'd no longer be blocked on bug 1636630 for implementing efficient draw calls.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 1•4 years ago
|
||
we only draw quads, and for quads we have a fixed vertex buffer with positions.
If we get stop using instancing, we'll no longer have the luxury of 4 vertices there.
Given that they are trivial to compute, it seems simpler to just do that in the shader today.
So this PR is a required step on the way to instance-less rendering.
Updated•4 years ago
|
Comment 3•4 years ago
|
||
bugherder |
Assignee | ||
Comment 4•4 years ago
|
||
I found it hard to understand the code that builds shader features,
and even harder to modify it with a new feature. This PR refactors the shader
building code by removing the macro and introducing a FeatureList abstraction, internally.
It also sorts the features on both ends (alternatively, we could use a set).
Assignee | ||
Comment 5•4 years ago
|
||
Comment 6•4 years ago
|
||
Backed out for causing bug 1541711
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=309734885&repo=autoland&lineNumber=71896
Backout: https://hg.mozilla.org/integration/autoland/rev/3331412297ae61337781969d5602edc1a1a88ae1
Updated•4 years ago
|
Comment 8•4 years ago
|
||
bugherder |
Comment 9•4 years ago
|
||
The backout got merged together with the changeset in comment 8: https://hg.mozilla.org/mozilla-central/rev/3331412297ae
Comment 10•4 years ago
|
||
Comment 11•4 years ago
|
||
bugherder |
Assignee | ||
Comment 12•4 years ago
|
||
The first version of the change got backed out. I investigated the problem, which I concluded to be the driver bug on macOS/Intel, and included the workaround in the second version of the change that has just landed.
Assignee | ||
Comment 13•4 years ago
|
||
Andreea, can we back out https://phabricator.services.mozilla.com/D83391 again? I suspect it to be related to https://bugzilla.mozilla.org/show_bug.cgi?id=1653210
Comment 14•4 years ago
|
||
Backed out as requested.
Backout link: https://hg.mozilla.org/integration/autoland/rev/1b693164de4389acfa4b73167b56ad65341de09f
Comment 15•4 years ago
|
||
Comment 16•4 years ago
|
||
bugherder |
Comment 17•4 years ago
|
||
(In reply to Bogdan Tara[:bogdan_tara | bogdant] from comment #16)
I'm seeing bug 1653283 again in today's nightly, was it cause by this landing?
Assignee | ||
Comment 18•4 years ago
|
||
I'm looking into this now. If we don't find a quick and simple solution, we should back out the original patch.
Assignee | ||
Comment 19•4 years ago
|
||
Dave, would you be able to reproduce the issue on these two builds?
- https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/L5qTeODqScSGhfYqfqi_2A/runs/1/artifacts/public/build/target.dmg
- https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/bTQM-QNnRauAzck-uwJAPw/runs/0/artifacts/public/build/target.dmg
Both of these are produced by Firefox CI with my fix candidates (first and second).
Comment 20•4 years ago
|
||
(In reply to Dzmitry Malyshau [:kvark] from comment #19)
Dave, would you be able to reproduce the issue on these two builds?
- https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/L5qTeODqScSGhfYqfqi_2A/runs/1/artifacts/public/build/target.dmg
- https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/bTQM-QNnRauAzck-uwJAPw/runs/0/artifacts/public/build/target.dmg
Both of these are produced by Firefox CI with my fix candidates (first and second).
Yes I can reproduce the issue with both builds.
Assignee | ||
Comment 21•4 years ago
|
||
Alright, thank you for testing quickly!
Atila, could you help backing out https://hg.mozilla.org/mozilla-central/rev/4b66ae956966 please?
Looks like the driver bugs have no end :(
Comment 22•4 years ago
|
||
So I will say that while I can't reproduce this on-demand it will show up after a bit of clicking between tabs. For the first test build that took longer than normal so maybe it happens less then, maybe it was a fluke. The second build I saw it very quickly and so stopped testing so no idea there.
Comment 23•4 years ago
|
||
(In reply to Dzmitry Malyshau [:kvark] from comment #21)
Alright, thank you for testing quickly!
Atila, could you help backing out https://hg.mozilla.org/mozilla-central/rev/4b66ae956966 please?
Looks like the driver bugs have no end :(
Backed out as requested.
Backout link: https://hg.mozilla.org/integration/autoland/rev/b56eb8203c9c12d5ef7a87fc4af7cab7226f836e
Comment 24•4 years ago
•
|
||
Backout merged to central: https://hg.mozilla.org/mozilla-central/rev/f4703bddd567ffe954073b70a7fe1b4dfa752281
Updated•4 years ago
|
Assignee | ||
Comment 25•4 years ago
|
||
this change adds a code path to avoid instancing.
It's not universally supported, unfortunately.
Also, OSMESA appears to produce corrupted visuals on this path:
https://hg.mozilla.org/mozilla-central/raw-file/tip/layout/tools/reftest/reftest-analyzer.xhtml#logurl=https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/OkjOmxCVSO6QaiNQaCc0SA/runs/0/artifacts/public/logs/live_backing.log&only_show_unexpected=1
Side note: we still need a plan on what to do on devices that support neither of base-instance or SSBO.
Assignee | ||
Comment 26•4 years ago
|
||
About this plan I mentioned in the previous comment - we discussed it with Glenn. The outcomes are:
- we still want to land SSBO support, even if optional. However, we need to figure out the problem with OSMESA first, ideally.
- to cover other platforms, we'll need to experiment with the other ways of providing the data, such as textures, or vertex attributes
Comment 27•4 years ago
|
||
Comment 28•4 years ago
|
||
Backed out for wrench failures on shadow-transforms.yaml
backout: https://hg.mozilla.org/integration/autoland/rev/9336e818075218a89eaa854948062db24f249923
failure log: https://treeherder.mozilla.org/logviewer?job_id=321985704&repo=autoland&lineNumber=13541
[task 2020-11-16T23:49:36.325Z] REFTEST reftests/text/shadow-partial-glyph.yaml == reftests/text/shadow-partial-glyph-ref.yaml
[task 2020-11-16T23:49:36.354Z] REFTEST reftests/text/shadow-transforms.yaml == reftests/text/shadow-transforms.png
[task 2020-11-16T23:49:36.547Z] REFTEST TEST-UNEXPECTED-FAIL | reftests/text/shadow-transforms.yaml == reftests/text/shadow-transforms.png | image comparison, max difference: 1, number of differing pixels: 185 | 185 differences > 0 and <= 2 (allowed 120);
Comment 29•4 years ago
|
||
Comment 30•4 years ago
|
||
bugherder |
Comment 31•4 years ago
|
||
Backed out changeset dbcc7614b8f0 (Bug 1640960) for causing rendering issues on Linux (Bug 1677728) a=backout
Backout link: https://hg.mozilla.org/mozilla-central/rev/8b19c30190d5c1548231daf6c9d04c5bda309f0f
Assignee | ||
Comment 32•4 years ago
|
||
Thanks for the backout! I'm going to test this on Intel NV and possibly re-land in a disabled form with a pref.
Comment 33•4 years ago
•
|
||
deleted
Updated•4 years ago
|
Updated•4 years ago
|
Comment 34•4 years ago
|
||
I apologise for this late regression, seems like I linked this bug directly to the alert.
Assignee | ||
Comment 35•4 years ago
|
||
We are adding the "enable_instancing" flag, enabled by default. When it's not true
,
we are duplicating the per-vertex data and issuing non-instanced draw calls.
This is currently regressing the Talos tests.
Comment 36•4 years ago
|
||
Comment 37•4 years ago
|
||
bugherder |
Assignee | ||
Comment 38•4 years ago
|
||
This is a small extract from a change I tried to land earlier.
It refactors the GL version queries, no functional changes here.
Comment 39•4 years ago
|
||
Comment 40•4 years ago
|
||
bugherder |
Assignee | ||
Comment 41•4 years ago
|
||
We dug more information about instancing, and apparently the data from AMD presentation is no longer reflecting what the HW does.
Today, both AMD and NV are packing multiple instances into a wavefront, so removing instancing would cause us a perf regression.
Updated•4 years ago
|
Description
•