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

Transition all pipelines to new draw_flags field for fill rule #399

Merged
merged 6 commits into from
Oct 31, 2023

Conversation

armansito
Copy link
Collaborator

This migrates all pipelines downstream of flatten away from the old linewidth encoding which was only being used for the fill rule, which now gets stored in a draw_flags field. I also cleaned up some leftover linewidth transform logic which was no longer used and wired up the new fill rule flag to the CPU version of the coarse stage.

This continues the work outlined in #303. For more details please refer to the individual commit messages.

* Pipelines downstream of flatten (draw_leaf, coarse) now extract the
  fill rule using a "draw flags" field. Flatten still writes this to the
  path bounding-box structure, which gets propagated to the draw info
  list, and eventually translates to the fill rule written to the PTCL.

* draw_leaf no longer deals with transforming the linewidth for strokes.
  This was a leftover from the previous architecture and the logic is no
  longer needed.

* bbox_clear used to contain a duplicate PathBbox data structure. It now
  uses the one from shader/shared/bbox.wgsl

This continues the work outlined in #303
Wired up the even-odd fill-rule to the CPU version of coarse.
@armansito armansito force-pushed the gpu-stroke-rework-contd branch from 71037f1 to fada357 Compare October 28, 2023 06:19
The CPU version of the coarse stage was missing logic to correctly
handle the even-odd fill rule. This change copies over the existing
logic from the GPU version with some added documentation.
Added more draws to the fill_types test scene where different fills
overlap and blend with each other. This is mostly to validate the
even-odd fill logic in the `coarse` stage.
@armansito armansito force-pushed the gpu-stroke-rework-contd branch from fada357 to 161a31c Compare October 28, 2023 06:24
@armansito armansito requested review from dfrg and raphlinus October 31, 2023 08:22
Moved the per-drawobject tile discard logic near the existing tile
inclusion code in the main loop. This avoids the branch conditionals
that were present in each draw tag case branch.
@armansito armansito force-pushed the gpu-stroke-rework-contd branch from b2a232e to 7a84914 Compare October 31, 2023 08:28
Copy link
Contributor

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

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

This all looks good except for a possible tweak to the include_tile logic, see inline. I especially appreciate the code simplification and reduced divergence in coarse. I think divergence could be further improved by grouping the write_paths for the different draw object types, but I'm not sure how much of a real performance improvement that would be.

// backdrop (i.e. the winding number of its top-left corner) is even.
//
// NOTE: A clip should never get encoded with an even-odd fill.
let even_odd_discard = n_segs == 0u && even_odd && (abs(tile.backdrop) & 1) == 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

In my first pass, I was worried that this would be incorrect for even-odd clips. But I now see this can't be encoded, so my concern is more one of style than correctness.

If we ever do support even-odd clips (which is eoclip in PostScript and Core Graphics, W* in PDF), then we'd want to make the change. I think a version that gets this correct is just as concise, and potentially clearer, so suggest something along these lines:

    let backdrop_clear = select(tile.backdrop, tile.backdrop & 1, even_odd) == 0;
    let include_tile = n_segs != 0u || (backdrop_clear == is_clip) || is_blend;

But I wouldn't block the PR on this, it is correct as written.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like your formulation better than what I have as it is concise and doesn't rule out even-odd clips (which I wasn't aware of until now).

let n_segs = tile.segment_count_or_ix;
let include_tile = n_segs != 0 || (tile.backdrop == 0) == is_clip || is_blend;

// If this draw object represents an even-odd fill and we know that no line segment
Copy link
Contributor

Choose a reason for hiding this comment

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

See above comment; if the change is made there, it should be consistent here.

@armansito armansito merged commit ffe89e1 into main Oct 31, 2023
4 checks passed
@armansito armansito deleted the gpu-stroke-rework-contd branch October 31, 2023 21:59
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.

2 participants