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

Conversation

@bdero
Copy link
Member

@bdero bdero commented Oct 3, 2023

Update the coverage docstrings to clarify which space the coordinates are given in. Up until now, I've been using the phrase "screen space" to convey that coverage is counted in framebuffer pixels and is unaffected by the subpass transform basis. But a more accurate way to describe this would be "pass space", since it counts pixels relative to the top left corner of the framebuffer that the Entity is being drawn to during rendering.

@bdero bdero self-assigned this Oct 3, 2023

//----------------------------------------------------------------------------
/// @brief Get the screen space bounding rectangle that this contents affects.
/// @brief Get the pass space bounding rectangle that this contents affects.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps something like "Get the area of the current render pass that is affected by these contents." The bit about the top-left relativity is simply whats in go/impeller-coordinates right? I suppose it doesn't hurt to reiterate.

Also, can we clarify what std::nullopt would mean and why we don't use empty rects?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I meant to include that it's counted in pixels here. I updated this to a slightly more generic version "Get the area that will be affected when this contents is rendered" with a clarifying "During rendering, coverage coordinates count pixels from the top left corner of the framebuffer".

Added a note about the return values too. std::nullopt just means no coverage... I do think we should move to using empty coverage instead here in the future, since we also confusingly have a case where std::nullopt means "no bounds restriction" in Aiks (added much more recently, of course).

@bdero bdero force-pushed the bdero/coverage-space-clarification branch 2 times, most recently from a6ed347 to 0be0f19 Compare October 3, 2023 22:36
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

I think this clears things up a bit.

Let me just say I found it really easy working with Unity3D. There everything is either specified as being in global space or local space and having a way to calculate intermediate transforms if you want but querying without a reference will give you local or global and it's documented what returns what.

I guess in this instance you are referring to "local space" since its relative to its parent (the pass). You should probably add a docstring for Entity::SetTransformation too.


//----------------------------------------------------------------------------
/// @brief Get the screen space bounding rectangle that this contents affects.
/// @brief Get the area that will be affected when this contents is
Copy link
Member

Choose a reason for hiding this comment

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

"the current render pass" missing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

//----------------------------------------------------------------------------
/// @brief Get the screen space bounding rectangle that this contents affects.
/// @brief Get the area that will be affected when this contents is
/// rendered.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Indent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@bdero bdero force-pushed the bdero/coverage-space-clarification branch 3 times, most recently from e1f3c05 to 337338c Compare October 4, 2023 03:35
@bdero
Copy link
Member Author

bdero commented Oct 4, 2023

I guess in this instance you are referring to "local space" since its relative to its parent (the pass). You should probably add a docstring for Entity::SetTransformation too.

Added a docstring to [Set|Get]Transformation.

All Entity and layer transforms are recorded as global -- this offsetting behavior is kind of a hack to get things aligned due to coverage optimizations (conceptually, all layers cover the entire screen; if we weren't using coverage to compute minimal subpass texture sizes, we wouldn't need to perform this offsetting at render time). And so at render time the Entity transform isn't relative to the user-controlled parent layer transform as "local space" implies, we just slide it over a bit just-in-time to align with coverage rectangle we computed for the current pass on the fly.

One potentially cool way we could slide this offset in without performing this confusing "slide the Entity around on the screen just before rendering" would be to adjust the viewport, but that's an exploration for another day. :p

@bdero bdero force-pushed the bdero/coverage-space-clarification branch from 337338c to 79e51c6 Compare October 4, 2023 04:39
@bdero bdero added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 4, 2023
@auto-submit auto-submit bot merged commit e0baf28 into flutter:main Oct 4, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 4, 2023
@gaaclarke
Copy link
Member

One potentially cool way we could slide this offset in without performing this confusing "slide the Entity around on the screen just before rendering" would be to adjust the viewport, but that's an exploration for another day. :p

Yea, that is sort of tripping me up. Instead of mutating an entities transform I'd prefer a way to crawl up and down the layers and build the necessary transform. For rendering to the subpass's texture we'd use the local transform, for doing coverage tests we'd calculate the global transform, etc. There's no need to mutate.

@bdero
Copy link
Member Author

bdero commented Oct 6, 2023

Yea, that is sort of tripping me up. Instead of mutating an entities transform I'd prefer a way to crawl up and down the layers and build the necessary transform.

Conceptually, this Entity transform mutation we're doing isn't moving the Entity to the correct scene position -- the Entity already has the correct global transform in the scene as defined by the user. What we're actually doing is aligning the orthographic camera based on where the minimal layer texture is going to be drawn.

If we wanted to avoid mutating the Entity transform, we could for example add a camera concept, or pass the offset as an extra param to Entity::Render() and let the Contents choose how to handle it during Command construction. But FWIW, I actually think what we're doing today is... pretty OK, barring better documentation.

@gaaclarke
Copy link
Member

If we wanted to avoid mutating the Entity transform, we could for example add a camera concept,

Yea, I like that idea. It's a more clear concept, involves less mutating, easier math, has more opportunities to bake since the geometry will be static.

harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
Update the coverage docstrings to clarify which space the coordinates are given in. Up until now, I've been using the phrase "screen space" to convey that coverage is counted in framebuffer pixels and is unaffected by the subpass transform basis. But a more accurate way to describe this would be "pass space", since it counts pixels relative to the top left corner of the framebuffer that the Entity is being drawn to during rendering.
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

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants