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

Remove ClipScrollGroup and PackedLayer. #1981

Merged
merged 1 commit into from Nov 5, 2017

Conversation

@glennw
Copy link
Member

glennw commented Nov 2, 2017

Instead, we provide access to both the clip node and scroll
node for a given primitive in the shader. The shader then
calculated the appropriate local clip rect.

There's a few hacks in here - for example, the way that
I pack the clip/scroll IDs into a single u32 for the
shaders. In the future, we'll be switching the vertex formats
to work on u16 size data fields, so this will become a lot
simpler then.


This change is Reviewable

@glennw
Copy link
Member Author

glennw commented Nov 2, 2017

r? @mrobinson

This is not quite ready for merge yet - there are a couple of failures in the Gecko try and and a couple of failures in the Servo WPT suite I need to fix. But I think those should be fairly minor fixes, so this is probably ready for review.

Gecko try:

https://hg.mozilla.org/try/rev/933c76557503d46ff73501b31ebbda5be1eefe30
https://treeherder.mozilla.org/#/jobs?repo=try&revision=933c76557503d46ff73501b31ebbda5be1eefe30

@glennw
Copy link
Member Author

glennw commented Nov 2, 2017

This simplifies a lot of the CPU code that deals with primitives, and makes it feasible to work on the changes proposed in #1774.

@mrobinson
Copy link
Member

mrobinson commented Nov 2, 2017

@gw I absolutely love this change. I've taken a quick look and don't see any obvious problems, but I'll do a more thorough review today.

@mrobinson
Copy link
Member

mrobinson commented Nov 2, 2017

Okay. I have one question about the ClipScrollNodeData. It seems that it is associated to primitives via their assigned scroll node, yet it contains information about the local clip rect. The local clip rect is a property of the primitive's assigned clip node. Perhaps that is why you are seeing failures on Gecko.

@glennw glennw force-pushed the glennw:remove-clip-scroll branch from fd552ea to 9f43586 Nov 2, 2017
@glennw
Copy link
Member Author

glennw commented Nov 3, 2017

@mrobinson OK, there are three small fix-up commits added. With those changes, all WR / Servo / Gecko tests pass.

Gecko try:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=844bc16b48eea4096461c405e96547755590517b

@glennw glennw force-pushed the glennw:remove-clip-scroll branch from b46ba8c to b5f4a7b Nov 3, 2017
Copy link
Member

mrobinson left a comment

This looks great. I left a couple nit comments, but I still love this PR.

// All the coordinates we receive are relative to the stacking context, but we want
// to convert them to something relative to the origin of the clip.
let negative_origin = -rect.origin.to_vector();
rect = rect.translate(reference_frame_relative_offset);

This comment has been minimized.

@mrobinson

mrobinson Nov 3, 2017

Member

This could use reassignment and you will be able to avoid making this variable mutable.

let complex_clips = match local_clip {
&LocalClip::Rect(_) => Vec::new(),
&LocalClip::RoundedRect(_, ref region) => vec![region.clone()],
};
ClipRegion::create_for_clip_node(*local_clip.clip_rect(), complex_clips, None)
ClipRegion::create_for_clip_node(*local_clip.clip_rect(), complex_clips, None, reference_frame_relative_offset)

This comment has been minimized.

@mrobinson

mrobinson Nov 3, 2017

Member

Nit: This line is longer than 100 characters.


#[derive(Copy, Debug, Clone)]
#[repr(C)]
pub struct ClipScrollNodeId(pub u32);

This comment has been minimized.

@mrobinson

mrobinson Nov 3, 2017

Member

Maybe this should be called ClipScrollNodeIndex to avoid confusing it with the ClipId and also to express that it is an index into the array of ClipScrollNodeData.

None => {
state.combined_outer_clip_bounds = DeviceIntRect::zero();

ClipScrollNodeData {

This comment has been minimized.

@mrobinson

mrobinson Nov 3, 2017

Member

I think it would be good to add an empty() factory on ClipScrollNodeData to make this code a bit clearer.

@glennw glennw force-pushed the glennw:remove-clip-scroll branch from b5f4a7b to c106ab0 Nov 5, 2017
@glennw
Copy link
Member Author

glennw commented Nov 5, 2017

@mrobinson Thanks, fixed those comments up in the last commit. Once you review that change, I'll squash before merge.

Copy link
Member

mrobinson left a comment

Looks good to me!

Instead, we provide access to both the clip node and scroll
node for a given primitive in the shader. The shader then
calculated the appropriate local clip rect.

There's a few hacks in here - for example, the way that
I pack the clip/scroll IDs into a single u32 for the
shaders. In the future, we'll be switching the vertex formats
to work on u16 size data fields, so this will become a lot
simpler then.
@glennw glennw force-pushed the glennw:remove-clip-scroll branch from c106ab0 to 5bdcb95 Nov 5, 2017
@glennw
Copy link
Member Author

glennw commented Nov 5, 2017

Squashed fixup commits.

@bors-servo r=mrobinson

@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2017

📌 Commit 5bdcb95 has been approved by mrobinson

bors-servo added a commit that referenced this pull request Nov 5, 2017
Remove ClipScrollGroup and PackedLayer.

Instead, we provide access to both the clip node and scroll
node for a given primitive in the shader. The shader then
calculated the appropriate local clip rect.

There's a few hacks in here - for example, the way that
I pack the clip/scroll IDs into a single u32 for the
shaders. In the future, we'll be switching the vertex formats
to work on u16 size data fields, so this will become a lot
simpler then.

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

bors-servo commented Nov 5, 2017

Testing commit 5bdcb95 with merge bb73014...

@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: mrobinson
Pushing bb73014 to master...

@bors-servo bors-servo merged commit 5bdcb95 into servo:master Nov 5, 2017
4 checks passed
4 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@glennw glennw deleted the glennw:remove-clip-scroll branch Nov 5, 2017
Copy link
Member

kvark left a comment

This is one long awaited and heck of an awesome change 👍
One thing that's missing is a bit of measurement of the performance impact.

};

Layer fetch_layer(int clip_node_id, int scroll_node_id) {
ClipScrollNode clip_node = fetch_clip_scroll_node(clip_node_id);

This comment has been minimized.

@kvark

kvark Nov 6, 2017

Member

we should have a fast path for clip_node_id == scroll_node_id instead of fetching the same data again


struct Layer {
mat4 transform;
mat4 inv_transform;

This comment has been minimized.

@kvark

kvark Nov 6, 2017

Member

we should gate the inv_transform fetches with the WR_FEATURE_TRANSFORM to save on fetches for a more popular (aligned) case

};

Layer fetch_layer(int clip_node_id, int scroll_node_id) {
ClipScrollNode clip_node = fetch_clip_scroll_node(clip_node_id);

This comment has been minimized.

@kvark

kvark Nov 6, 2017

Member

also note: the clip_note.inv_transform is not used here at all, so we shouldn't fetch it


// Store coord system ID, and also the ID used for shaders to reference this node.
self.coordinate_system_id = state.current_coordinate_system_id;
self.id = ClipScrollNodeIndex(node_data.len() as u32);

This comment has been minimized.

@kvark

kvark Nov 6, 2017

Member

might be useful to have the name of this type reflecting the fact it's for GPU/shader consumption only

@@ -113,11 +113,6 @@ pub struct FrameBuilder {
pub config: FrameBuilderConfig,

stacking_context_store: Vec<StackingContext>,
clip_scroll_group_store: Vec<ClipScrollGroup>,

This comment has been minimized.

@kvark

kvark Nov 6, 2017

Member

sweeeet!

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

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