Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Oct 28, 2024

Using primitive restart we can avoid tracking even odd or inserting degenerate triangles. Instead a special index value 0xFFFF is used to signal a break. This can be combined with triangle fan on vulkan for a dramatically simpler tessellation.

Additionally, switches to a two pass system where we first estimate the storage required by the path so tha the host buffer can be written to directly.


/// @brief A vertex writer that generates a triangle fan and requires primitive
/// restart.
class FanVertexWriter : public VertexWriter {
Copy link
Member

Choose a reason for hiding this comment

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

This will only work for 16-bit index types. Perhaps you can take a void* index buffer and an IndexType argument to make this utility more generally usable. The restart marker you select can then depend on the index type passed in. Or you could template it.

This looks like a generally useful utility and its in the common geometry classes, so making it only work with 16 bit index types seems odd. And there are very guardrails against someone casting the wrong pointer type to uint16_t.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only use 16 bit index types though. If we need to make this configurable we can template-tize it if needed.

size_t count_ = 0;
size_t index_count_ = 0;
size_t contour_start_ = 0;
Point* point_buffer_;
Copy link
Member

Choose a reason for hiding this comment

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

Zero these out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (count_ == 0) {
return;
}
index_buffer_[index_count_++] = 0xFFFF;
Copy link
Member

Choose a reason for hiding this comment

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

Probably being paranoid, but can you double check that the restart markers are the same in all APIs?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind, I checked that they are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think in GL you can configure a specific restart value with some APIs but I hope to never need that

Copy link
Member

Choose a reason for hiding this comment

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

Isn't that desktop GL? On ES 3.0 and above, you specify GL_PRIMITIVE_RESTART_FIXED_INDEX to glEnable and get the same behavior as Metal and Vulkan.

Copy link
Member

Choose a reason for hiding this comment

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

You can't configure the index in ES.

return false;
}

bool CapabilitiesVK::SupportsPrimitiveRestart() const {
Copy link
Member

Choose a reason for hiding this comment

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

You can do the same thing unconditionally for Metal. Metal enables primitive restart by default without any additional configuration. In fact, it don't think it is possible to disable it.

Copy link
Contributor Author

@jonahwilliams jonahwilliams Oct 29, 2024

Choose a reason for hiding this comment

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

This is wired up for metal in this PR.

@jonahwilliams jonahwilliams changed the title [Impeller] use primtiive restart for faster tessellation: write directly into host buffer. [Impeller] use primitive restart for faster tessellation: write directly into host buffer. Oct 29, 2024
jonahwilliams added 2 commits October 28, 2024 18:28
@jonahwilliams jonahwilliams marked this pull request as ready for review October 29, 2024 03:36
@jonahwilliams jonahwilliams marked this pull request as draft October 29, 2024 04:21
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

@jonahwilliams jonahwilliams marked this pull request as ready for review October 29, 2024 20:14
@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 31, 2024
@auto-submit auto-submit bot merged commit 48a63fe into flutter:main Oct 31, 2024
30 checks passed
@jonahwilliams jonahwilliams deleted the compute_tessellator branch October 31, 2024 02:29
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Oct 31, 2024
…157926)

flutter/engine@c40b0b6...f2154ef

2024-10-31 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Skwasm single threaded (#56206)" (flutter/engine#56264)
2024-10-31 skia-flutter-autoroll@skia.org Roll Skia from 4f8f2ecadfb6 to 3c628426f85f (1 revision) (flutter/engine#56261)
2024-10-31 skia-flutter-autoroll@skia.org Roll Skia from 7e79a516284b to 4f8f2ecadfb6 (1 revision) (flutter/engine#56255)
2024-10-31 skia-flutter-autoroll@skia.org Roll Dart SDK from 6a8058eef22c to f3e3dc44b1dc (1 revision) (flutter/engine#56253)
2024-10-31 skia-flutter-autoroll@skia.org Roll Skia from 3c62d4a94d78 to 7e79a516284b (1 revision) (flutter/engine#56252)
2024-10-31 jonahwilliams@google.com [Impeller] use primitive restart for faster tessellation: write directly into host buffer. (flutter/engine#56173)
2024-10-31 jacksongardner@google.com Skwasm single threaded (flutter/engine#56206)
2024-10-31 jonahwilliams@google.com [Impeller] expose reference to tessellator instead of shared_ptr. (flutter/engine#56244)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC chinmaygarde@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
nick9822 pushed a commit to nick9822/flutter that referenced this pull request Dec 18, 2024
…tly into host buffer. (flutter/engine#56173)

Using primitive restart we can avoid tracking even odd or inserting degenerate triangles. Instead a special index value `0xFFFF` is used to signal a break. This can be combined with triangle fan on vulkan for a dramatically simpler tessellation.

Additionally, switches to a two pass system where we first estimate the storage required by the path so tha the host buffer can be written to directly.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants