Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the DirtyRect type #3277

Merged
merged 6 commits into from Nov 23, 2018
Merged

Introduce the DirtyRect type #3277

merged 6 commits into from Nov 23, 2018

Conversation

@nical
Copy link
Collaborator

nical commented Nov 6, 2018

This is Alexis' DirtyRect patch completed and rebased on top of #3272.

It turns Option<Rect> into an explicit type which is a lot easier to understand as None previously meant different things in different areas of the code.


This change is Reviewable

@nical
Copy link
Collaborator Author

nical commented Nov 6, 2018

Try push: https://treeherder.mozilla.org/#/jobs?repo=try&revision=e3bde69a576c86d71a88e80c8c77b4a295562642 I added some fixes to get wrench to build after the try push but the gecko visible parts are in there.

@nical nical force-pushed the nical:dirty-rect-type branch from f1c25b0 to 5f16494 Nov 6, 2018
@Gankra
Copy link
Contributor

Gankra commented Nov 6, 2018

SGTM, but I wrote most of the second commit so I'm not sure if my vote counts 😅

(signed off on the first one in the other PR)

@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2018

The latest upstream changes (presumably #3282) made this pull request unmergeable. Please resolve the merge conflicts.

@nical nical force-pushed the nical:dirty-rect-type branch 2 times, most recently from d220f8d to db20dce Nov 7, 2018
@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2018

The latest upstream changes (presumably #3272) made this pull request unmergeable. Please resolve the merge conflicts.

@nical nical force-pushed the nical:dirty-rect-type branch from db20dce to bdf488f Nov 7, 2018
@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2018

The latest upstream changes (presumably #3284) made this pull request unmergeable. Please resolve the merge conflicts.

@nical nical force-pushed the nical:dirty-rect-type branch from bdf488f to 63e20d2 Nov 16, 2018
@bors-servo
Copy link
Contributor

bors-servo commented Nov 17, 2018

The latest upstream changes (presumably #3321) made this pull request unmergeable. Please resolve the merge conflicts.

@nical nical force-pushed the nical:dirty-rect-type branch 2 times, most recently from c6aa2c4 to 09802fc Nov 19, 2018
bors-servo added a commit that referenced this pull request Nov 19, 2018
Use euclid 0.19.3+ exported from webrender_api.

Extracted this from #3277 to make the diff less scary.

Use euclid 0.19.3 and rather than manage the same dependency in both webrender and webrender_api, just publicly reexport in webrender_api.

<!-- 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/3326)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 19, 2018

The latest upstream changes (presumably #3326) made this pull request unmergeable. Please resolve the merge conflicts.

@nical nical force-pushed the nical:dirty-rect-type branch from 09802fc to e4b5268 Nov 20, 2018
Copy link
Member

kvark left a comment

I'm not entirely convinced about the separate API entry points for the blobs, but I trust your judgement here:)
Anyhow, see notes below

Reviewed 7 of 19 files at r1.
Reviewable status: 4 of 16 files reviewed, 6 unresolved discussions (waiting on @nical)


webrender_api/src/api.rs, line 362 at r1 (raw file):

        &mut self,
        key: BlobImageKey,
        descriptor: ImageDescriptor,

do we need to provide the descriptor here (as opposed to use the old one)?


webrender_api/src/image.rs, line 248 at r1 (raw file):

    /// An series of commands that can be rasterized into an image via an
    /// embedding-provided callback.
    Blob,

why do we still have this variant if blobs are supposed to be separate types with their own entry points for data sources?


webrender_api/src/image.rs, line 387 at r1 (raw file):

pub enum DirtyRect<T: Copy, U> {
    /// Everything is Dirty, equivalent to SomeDirty(image_bounds)
    AllDirty,

can we avoid the Dirty suffix? Maybe DirtyRect::All and DirtyRect::Partial?


webrender_api/src/image.rs, line 402 at r1 (raw file):

    /// Creates an empty DirtyRect (indicating nothing is invalid)
    pub fn empty() -> Self {
        DirtyRect::SomeDirty(TypedRect::zero())

would this be cleaner with another enum variant?


webrender_api/src/image.rs, line 419 at r1 (raw file):

    /// Maps over the contents of SomeDirty.
    pub fn map<F>(self, func: F) -> Self

do we need to support space transition here as well? (e.g. "U -> V")


webrender_api/src/units.rs, line 128 at r1 (raw file):

pub type ImageDirtyRect = DirtyRect<i32, DevicePixel>;
pub type BlobDirtyRect = DirtyRect<i32, LayoutPixel>;

is the space different because of the supposed "infinite" semantics of the blobs?

Copy link
Collaborator Author

nical left a comment

Reviewable status: 4 of 16 files reviewed, 6 unresolved discussions (waiting on @kvark)


webrender_api/src/api.rs, line 362 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

do we need to provide the descriptor here (as opposed to use the old one)?

Probably not. I want to further change the blob specific APIs in followup patches, I'll look into removing this. I agree it would look cleaner at the API level.


webrender_api/src/image.rs, line 248 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

why do we still have this variant if blobs are supposed to be separate types with their own entry points for data sources?

Yeah we should add a different enum to store in image_templates so that the API visible enum doesn't have the Blob placeholder. I'll fix this one before merging.


webrender_api/src/image.rs, line 387 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

can we avoid the Dirty suffix? Maybe DirtyRect::All and DirtyRect::Partial?

Sounds good to me.


webrender_api/src/image.rs, line 402 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

would this be cleaner with another enum variant?

We need to support this representation of empty dirty rects anyway (it'll come up after intersections etc), so I think it's simpler to keep it like that than have either two representations for empty rects or the need to canonicalize after each modification that could lead to an empty rect.


webrender_api/src/image.rs, line 419 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

do we need to support space transition here as well? (e.g. "U -> V")

I like the idea, I'll have a look.


webrender_api/src/units.rs, line 128 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

is the space different because of the supposed "infinite" semantics of the blobs?

Yeah-ish. The dirty rect for blobs is expressed in the same space as the blob's drawing commands which until now sort of matched a sort of translated device space (in part due to how we fit the blob API in the general image API), but I would like to make sure we always consider device space as local to a single rectangle of pixels (an image or a tile), rather than use it for sparse things like tiled blobs.

Separating the two here will hopefully help us avoid trying to mix the blob's layout dirty rect with the other dirty rects in the resource cache which are local to their texture cache entries.

@nical nical force-pushed the nical:dirty-rect-type branch from e4b5268 to 404f1bb Nov 21, 2018
@nical
Copy link
Collaborator Author

nical commented Nov 21, 2018

@nical nical force-pushed the nical:dirty-rect-type branch from 404f1bb to 37d0904 Nov 21, 2018
@kvark
kvark approved these changes Nov 22, 2018
Copy link
Member

kvark left a comment

:lgtm:

Reviewed 1 of 19 files at r1, 13 of 14 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @nical)


webrender_api/src/image.rs, line 402 at r1 (raw file):

Previously, nical (Nicolas Silva) wrote…

We need to support this representation of empty dirty rects anyway (it'll come up after intersections etc), so I think it's simpler to keep it like that than have either two representations for empty rects or the need to canonicalize after each modification that could lead to an empty rect.

I think when intersections are happening, we don't get the empty rect directly anyway. There is code that does a match or unwrap_or with an empty rect, so we might as well just put a strong variant there.
Anyhow, this isn't super important, can leave for follow-ups, if any.


webrender_api/src/image.rs, line 419 at r1 (raw file):

Previously, nical (Nicolas Silva) wrote…

I like the idea, I'll have a look.

figured it's not worth it for now?

@kvark
Copy link
Member

kvark commented Nov 22, 2018

There are R5 failures in the try.

@nical
Copy link
Collaborator Author

nical commented Nov 22, 2018

There are R5 failures in the try.

These are fuzzable and appeared after I rebased the webrender parts so I suspect they come from another commit that doesn't have the corresponding gecko change in the push. There is also an unexpected pas that I can't take credit for.
I just rebased the gecko parts again, I'll land this if the next try push comes back green.

@bors-servo
Copy link
Contributor

bors-servo commented Nov 23, 2018

The latest upstream changes (presumably #3332) made this pull request unmergeable. Please resolve the merge conflicts.

nical added 3 commits Nov 5, 2018
Before this PR each tile stores its own dirty rect relative to the entire image. This is somewhat confusing because this field is used to track partial uploads correctly and uploads reason about dirty rects relative to the tiles so it has to do some conversions. Storing relative to the tile is also truer to the "device space" the rects are tagged with.
Last but not least the image-relative coordinates will make even less sense for tiled blob images as we start trating them as virtually infinite planes.
Previously dirty rects were set up in a subtle way where early in the
pipeline None is used to mean "no information" and therefore "all clean",
but then later on is used to mean "all dirty" on the assumption that if
a texture is still being handled, some dirty information must have been
sent. None is therefore used by the internals as a way to signal
things like missing cache entries without actually bothering to look up
the dimensions of the image (note that "clean" can always be expressed
without knowing dimensions, as it is always the same empty rect).

I change the system to just consistently use a custom enum that has
AllDirty and SomeDirty(empty_rect) to represent these two states. As
a result the code seems much easier to understand.
nical added 3 commits Nov 7, 2018
Blobs will need some extra APIs that don't apply to regular images.
This change will make it easier to add these extra functionalities
without messing with the rest of the code.
The new BlobImageKey type also adds a tiny bit of type safety to
prevent some mixing blob and non blob data on the same image which
is invalid.
@nical nical force-pushed the nical:dirty-rect-type branch from 37d0904 to b18556e Nov 23, 2018
@nical
Copy link
Collaborator Author

nical commented Nov 23, 2018

@bors-servo r=kvark

@bors-servo
Copy link
Contributor

bors-servo commented Nov 23, 2018

📌 Commit b18556e has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Nov 23, 2018

Testing commit b18556e with merge af2b372...

bors-servo added a commit that referenced this pull request Nov 23, 2018
Introduce the DirtyRect type

This is Alexis' [DirtyRect patch](https://phabricator.services.mozilla.com/D9559) completed and rebased on top of #3272.

It turns `Option<Rect>` into an explicit type which is a lot easier to understand as `None` previously meant different things in different areas of the code.

<!-- 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/3277)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 23, 2018

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: kvark
Pushing af2b372 to master...

@bors-servo bors-servo merged commit b18556e into servo:master Nov 23, 2018
3 of 4 checks passed
3 of 4 checks passed
code-review/reviewable 6 files, 2 discussions left (kvark, nical)
Details
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Nov 24, 2018
…9a33e6acd35d (WR PR #3277). r=kats

servo/webrender#3277

Differential Revision: https://phabricator.services.mozilla.com/D12809

--HG--
extra : moz-landing-system : lando
jankeromnes pushed a commit to jankeromnes/gecko that referenced this pull request Nov 24, 2018
@nical nical deleted the nical:dirty-rect-type branch Nov 25, 2018
bors-servo added a commit that referenced this pull request Nov 26, 2018
Fix panic when updating a non-tiled "multi" image cache entry.

In  #3277 I introduced the expectation that if a cached image entry is `ImageResult::Multi(..)` then it must be tiled and we can `unwrap` an optional tiling related variable.

It turns out (from [bug 1509643](https://bugzilla.mozilla.org/show_bug.cgi?id=1509643)) that this assumption doesn't always hold true. This change restores the previous behavior and also invalidates the entire entry if it is tiled but we don't have information about the tile size. I don't know for sure whether this case can happen in practice but I'd rather be conservative about it since invalidation bugs tend to be hard to track down.

<!-- 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/3354)
<!-- Reviewable:end -->
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…9a33e6acd35d (WR PR #3277). r=kats

servo/webrender#3277

Differential Revision: https://phabricator.services.mozilla.com/D12809

UltraBlame original commit: 6d9d2397f1153e5e9062f342015f28ca3576bfee
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…9a33e6acd35d (WR PR #3277). r=kats

servo/webrender#3277

Differential Revision: https://phabricator.services.mozilla.com/D12809

UltraBlame original commit: 6d9d2397f1153e5e9062f342015f28ca3576bfee
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…9a33e6acd35d (WR PR #3277). r=kats

servo/webrender#3277

Differential Revision: https://phabricator.services.mozilla.com/D12809

UltraBlame original commit: 6d9d2397f1153e5e9062f342015f28ca3576bfee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.