Skip to content

Use z-buffer for rejecting opaque fragments. - #648

Merged
bors-servo merged 5 commits into
servo:masterfrom
glennw:zb
Dec 23, 2016
Merged

bors-servo merged 5 commits into
servo:masterfrom
glennw:zb

Conversation

@glennw

@glennw glennw commented Dec 15, 2016 •

Copy link
Copy Markdown
Member

This change is Reviewable

@glennw

glennw commented Dec 15, 2016

Copy link
Copy Markdown
Member Author

This still needs a little bit of cleanup - but it implements the functionality and passes all tests. So it should be fairly close to the final version.

int clip_task_index;
int layer_index;
int sub_index;
int z;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could probably reduce the user_data to a single int in order to keep the 32 byte size

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think it's fine to do this as a follow up though.

Comment thread webrender/res/prim_shared.glsl Outdated
prim.prim_index = pi.specific_prim_index;
prim.sub_index = pi.sub_index;
prim.user_data = pi.user_data;
prim.z = pi.z;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some compilers may require an explicit cast here.
Moreover, what are you going to do with this Z value? We need to scale it down into [-1, 1] region before passing into gl_Position, and I don't see this happening anywhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the cast. The vertices are transformed by uTransform, which is an orthographic projection matrix at the end of the function. This converts the z values to NDC.

Comment thread webrender/src/device.rs
}
}

pub fn enable_depth(&self) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could merge those enable_*/disable_* for tinier interface with the device

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, perhaps as a follow up we should tidy up the whole device interface?

#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(segment_rect,
prim.local_clip_rect,
prim.z,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point, we might as well want to just pass prim there directly

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the shaders generate the local rect separately (as in the case above), which is why I wasn't passing in the prim directly - to avoid bugs where that code accesses the prim.local_rect accidentally. But we could probably tidy up those structure definitions in the shader code.

Comment thread webrender/src/renderer.rs

enum ShaderKind {
Primitive,
Clear,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweeet!

Comment thread webrender/src/renderer.rs
self.profile_counters.draw_calls.inc();
}

fn submit_batch(&mut self,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread webrender/src/renderer.rs
let needs_clipping = batch.key.flags.needs_clipping();
debug_assert!(!needs_clipping || batch.key.blend_mode == BlendMode::Alpha);
self.device.enable_depth();
self.device.enable_depth_write();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we set the depth function anywhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@glennw

glennw commented Dec 21, 2016

Copy link
Copy Markdown
Member Author

@kvark @pcwalton I think this is ready for review now.

@glennw glennw changed the title [WIP] Use z-buffer for rejecting opaque fragments. Use z-buffer for rejecting opaque fragments. Dec 21, 2016

@pcwalton pcwalton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just had one question

Comment thread replay/src/main.rs
debug: false,
enable_subpixel_aa: false,
clear_framebuffer: true,
clear_empty_tiles: false,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we not clear empty tiles anymore?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's already guaranteed to be cleared in draw_target. Not sure though, at what point it became redundant/useless.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have to clear the z-buffer now, I figure we might as well just do a clear of the color buffer as well. This also makes it perform much better on mobile / tiled GPUs which rely on a clear due to the way tiling works. We could definitely re-instate this later as an optimization if it makes sense to.

@kvark kvark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glennw I agree with all the "let's do X as follow up" requests, the PR looks good!

Comment thread replay/src/main.rs
debug: false,
enable_subpixel_aa: false,
clear_framebuffer: true,
clear_empty_tiles: false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's already guaranteed to be cleared in draw_target. Not sure though, at what point it became redundant/useless.

@kvark

kvark commented Dec 23, 2016 via email

Copy link
Copy Markdown
Member

@kvark

kvark commented Dec 23, 2016

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 7eb458c has been approved by kvark

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 7eb458c with merge 56131c9...

bors-servo pushed a commit that referenced this pull request Dec 23, 2016
Use z-buffer for rejecting opaque fragments.


This change is [https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/648)
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - status-travis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants