Skip to content

[Impeller] Geometry overdraw protection can be handled by the depth compare function #179107

@flar

Description

@flar

(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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work liste: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.r: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions