Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUse z-buffer for rejecting opaque fragments. #648
Conversation
|
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. |
| @@ -286,6 +287,7 @@ struct PrimitiveInstance { | |||
| int clip_task_index; | |||
| int layer_index; | |||
| int sub_index; | |||
| int z; | |||
This comment has been minimized.
This comment has been minimized.
kvark
Dec 15, 2016
Member
we could probably reduce the user_data to a single int in order to keep the 32 byte size
This comment has been minimized.
This comment has been minimized.
| @@ -352,6 +356,7 @@ Primitive load_primitive_custom(PrimitiveInstance pi) { | |||
| prim.prim_index = pi.specific_prim_index; | |||
| prim.sub_index = pi.sub_index; | |||
| prim.user_data = pi.user_data; | |||
| prim.z = pi.z; | |||
This comment has been minimized.
This comment has been minimized.
kvark
Dec 15, 2016
Member
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.
This comment has been minimized.
This comment has been minimized.
glennw
Dec 21, 2016
Author
Member
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.
| } | ||
| } | ||
|
|
||
| pub fn enable_depth(&self) { |
This comment has been minimized.
This comment has been minimized.
kvark
Dec 15, 2016
Member
we could merge those enable_*/disable_* for tinier interface with the device
This comment has been minimized.
This comment has been minimized.
glennw
Dec 21, 2016
Author
Member
Yep, perhaps as a follow up we should tidy up the whole device interface?
| @@ -39,6 +39,7 @@ void main(void) { | |||
| #ifdef WR_FEATURE_TRANSFORM | |||
| TransformVertexInfo vi = write_transform_vertex(segment_rect, | |||
| prim.local_clip_rect, | |||
| prim.z, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
glennw
Dec 21, 2016
Author
Member
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.
| @@ -123,7 +122,6 @@ const CLIP_FEATURE: &'static str = "CLIP"; | |||
|
|
|||
| enum ShaderKind { | |||
| Primitive, | |||
| Clear, | |||
This comment has been minimized.
This comment has been minimized.
| @@ -990,12 +961,87 @@ impl Renderer { | |||
| self.profile_counters.draw_calls.inc(); | |||
| } | |||
|
|
|||
| fn submit_batch(&mut self, | |||
This comment has been minimized.
This comment has been minimized.
| 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(); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Looks good, just had one question |
| @@ -120,7 +120,6 @@ fn main() { | |||
| debug: false, | |||
| enable_subpixel_aa: false, | |||
| clear_framebuffer: true, | |||
| clear_empty_tiles: false, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
kvark
Dec 22, 2016
Member
I think it's already guaranteed to be cleared in draw_target. Not sure though, at what point it became redundant/useless.
This comment has been minimized.
This comment has been minimized.
glennw
Dec 22, 2016
Author
Member
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.
| @@ -120,7 +120,6 @@ fn main() { | |||
| debug: false, | |||
| enable_subpixel_aa: false, | |||
| clear_framebuffer: true, | |||
| clear_empty_tiles: false, | |||
This comment has been minimized.
This comment has been minimized.
kvark
Dec 22, 2016
Member
I think it's already guaranteed to be cleared in draw_target. Not sure though, at what point it became redundant/useless.
|
AMD GCN architecture, covering probably most of the AMD cards on the market, has meta-data for clears, fragment masks, and depth/stencil bounds - all per internal tile. So clearing on them is dirt cheap, you just pay a little before sampling from those targets for the first time, since the driver needs to fill up the untouched tiles. It basically does what is being removed from WR now, just more efficiently ;)
… On Dec 22, 2016, at 18:10, Glenn Watson ***@***.***> wrote:
@glennw commented on this pull request.
In replay/src/main.rs:
> @@ -120,7 +120,6 @@ fn main() {
debug: false,
enable_subpixel_aa: false,
clear_framebuffer: true,
- clear_empty_tiles: false,
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.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@bors-servo r+ |
|
|
Use z-buffer for rejecting opaque fragments. <!-- 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/648) <!-- Reviewable:end -->
|
|
glennw commentedDec 15, 2016
•
edited by larsbergstrom
This change is