Closed Bug 1420674 Opened 7 years ago Closed 7 years ago

Support tiling in Advanced Layers

Categories

(Core :: Graphics: Layers, enhancement)

40 Branch
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: dvander, Assigned: dvander)

Details

Attachments

(5 files)

Advanced Layers doesn't support TiledContentHosts. This will eventually block enabling Skia (or D2D) tiling on Windows, so I'd like to get it out of the way.
PaintedLayers can either receive their textures through a ContentHostTexture or a TiledContentHost. Currently, AL assumes it will be a ContentHostTexture, so the first step is removing this assumption. TiledContentHosts can now be assigned to a PaintedLayerMLGPU, though nothing will render.

Both host types have the concept of an "origin offset," though it is computed differently in the tiling case. I split that out into a separate member variable so RenderPassMLGPU doesn't have to start doing lots of casts.
Attachment #8931912 - Flags: review?(rhunt)
Currently, AL expects one texture per layer. TiledContentHost breaks this assumption by giving each PaintedLayer a grid of textures.

We already handle a similar case for ImageLayers - but tiling for those is extremely rare. AL takes a dumb approach and create a temporary one-off layer for each tile, and throws them away at the end of the frame. We don't want to do this with tiled PaintedLayers since they are much more common when tiling is enabled.

The simplest approach to making this work is to simply run the same PaintedLayer through the batching algorithm, over and over once for each tile. Each time we'll change its internal state, and restore the original state after having processed all tiles. That will trick the batching process into treating each iteration as a new item.

The caveat is that, when batching, we can't assume the same layer will always have the same texture. ComponentAlphaPass makes this assumption, which means if we add the same layer twice, we'll include the second one in the same batch. If the texture changed, we'll draw the wrong texture.

This patch fixes ComponentAlphaPass by extracting everything out of the layer that it cares about (like opacity, sampling mode, texture pointer), and using those properties as a batching key instead. If the texture changes, we'll have to start a new batch.
Attachment #8931913 - Flags: review?(rhunt)
Somehow I missed this during the TextureSourceProvider refactoring. TiledContentHost assumes we have a Compositor, which is not true for AL.
Attachment #8931914 - Flags: review?(matt.woodrow)
This overrides LayerMLGPU::AssignToView, and moves ContentHost-specific stuff down. AssignToView can now peek to see if there is a TiledContentHost, and handle it accordingly. The code for that is in the next patch.
Attachment #8931916 - Flags: review?(matt.woodrow)
This adds support for the high-res tile buffer. As noted in comment #2, each tile will overwrite the state in PaintedLayerMLGPU. After all tiles are processed, the original state is restored.

This patch makes no attempt to improve batching. What we really want here is dynamic indexing which looks specific to Direct3D 12. It might be worthwhile to create a new shader for tiles, but I don't think that's worth investigating yet.

Low-res tiling is slightly more complicated since the old compositor lowers their opacity and draws a background color. Probably we'll have to create a one-off ColorLayer to handle that (or create a new shader for low-res tiles). Anyway - that'll come in a separate patch, perhaps a separate bug since it's not super important.
Attachment #8931921 - Flags: review?(matt.woodrow)
Attachment #8931914 - Flags: review?(matt.woodrow) → review+
Attachment #8931916 - Flags: review?(matt.woodrow) → review+
Comment on attachment 8931921 [details] [diff] [review]
part 5, high res tiling support

Review of attachment 8931921 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/layers/mlgpu/PaintedLayerMLGPU.cpp
@@ +103,5 @@
>                                  RenderViewMLGPU* aView,
>                                  Maybe<Polygon>&& aGeometry)
>  {
>    if (TiledContentHost* tiles = mHost->AsTiledContentHost()) {
> +    // Note: we do not support the low-res buffer yet.

Maybe throw in an assertion just in case someone tries to enable the low-res buffer and wants to know why it's not drawing?

@@ +194,5 @@
> +    mComputedOpacity = tile.GetFadeInOpacity(baseOpacity);
> +    mDestOrigin = offset;
> +
> +    Maybe<Polygon> geometry = aGeometry;
> +    LayerMLGPU::AssignToView(aBuilder, aView, Move(geometry));

This is a bit confusing how we make repeated calls to the same function (with the same parameters) and it works.

Maybe add a comment about how it uses the visible region internally, and modifying that before the call is sufficient.
Attachment #8931921 - Flags: review?(matt.woodrow) → review+
Attachment #8931912 - Flags: review?(rhunt) → review+
Attachment #8931913 - Flags: review?(rhunt) → review+
Pushed by danderson@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/eeb25dc98529
Don't hardcode ContentHostTexture in PaintedLayerMLGPU. (bug 1420674 part 1, r=rhunt)
https://hg.mozilla.org/integration/mozilla-inbound/rev/5af1da25ee57
Fix ComponentAlphaPass for painted layers with multiple textures. (bug 1420674 part 2, r=rhunt).
https://hg.mozilla.org/integration/mozilla-inbound/rev/7f416f3bbacd
Use TextureSourceProvider instead of Compositor in TiledContentHost. (bug 1420674 part 3, r=mattwoodrow)
https://hg.mozilla.org/integration/mozilla-inbound/rev/22e1aa958dd2
Override PaintedLayerMLGPU::AssignToView in preparation for supporting TiledContentHost. (bug 1420674 part 4, r=mattwoodrow)
https://hg.mozilla.org/integration/mozilla-inbound/rev/89e84473d524
Add high-res tiling support to Advanced Layers. (bug 1420674 part 5, r=mattwoodrow)
Pushed by danderson@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/cf996ac2fb8f
Don't hardcode ContentHostTexture in PaintedLayerMLGPU. (bug 1420674 part 1, r=rhunt)
https://hg.mozilla.org/integration/mozilla-inbound/rev/a6e766e2a280
Fix ComponentAlphaPass for painted layers with multiple textures. (bug 1420674 part 2, r=rhunt).
https://hg.mozilla.org/integration/mozilla-inbound/rev/5e33db544617
Use TextureSourceProvider instead of Compositor in TiledContentHost. (bug 1420674 part 3, r=mattwoodrow)
https://hg.mozilla.org/integration/mozilla-inbound/rev/dddda7de674b
Override PaintedLayerMLGPU::AssignToView in preparation for supporting TiledContentHost. (bug 1420674 part 4, r=mattwoodrow)
https://hg.mozilla.org/integration/mozilla-inbound/rev/c20dea44664e
Add high-res tiling support to Advanced Layers. (bug 1420674 part 5, r=mattwoodrow)
Flags: needinfo?(dvander)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: