-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
(Replaces #178951)
Currently if a geometry creates a set of triangles that might overlap then it can request that we use a stencil-then-cover operation to resolve their overlapping areas before we apply the rendering operation. This adds time by requiring multiple passes to complete the operation. The stencil-then-cover processing is set up in clip_contents.cc:
| // If overdraw prevention is enabled (like when drawing stroke paths), we |
Another way to prevent overdraw would be to use the fact that we already test against the depth buffer. This test is meant to clip primitives by only allowing drawing at Z values that are greater or equal (kGreaterEqual) to the current value in the depth buffer. This is used to perform complex clipping by rendering an inversion of a clip at a depth that is higher than the primitives it will clip - thus causing them to fail their Z >= depth_buffer_sample test. This test is set up in contents.cc:
| opts.depth_compare = CompareFunction::kGreaterEqual; |
Using thekGreaterEqual prevents drawing where the clip has already drawn higher (in Z) values, but does not prevent drawing over previous rendering operations that were drawn at lower (in Z) values. It also does not prevent drawing over parts of the current rendering operation when its geometry (triangular tessellation) has multiple triangles that contain the same pixels.
But, the depth comparison function kGreater would also enforce clipping for the same reason and allow drawing over prior rendering operations, again for the same reason, but in this case, the current rendering primitive could only visit the pixel once and then its own Z value put into the depth buffer would prevent the same primitive from painting that pixel a second time.
Since simply changing the depth compare function doesn't require a second pass, all cases where the Geometry objects request overdraw protection could provide that service in the normal pixel processing by simply using kGreater.