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

[Impeller] HAL: Allow for asymmetrical stencil configuration in Pipelines #129855

Closed
bdero opened this issue Jun 30, 2023 · 3 comments
Closed

[Impeller] HAL: Allow for asymmetrical stencil configuration in Pipelines #129855

bdero opened this issue Jun 30, 2023 · 3 comments
Assignees
Labels
e: impeller Impeller rendering backend issues and features requests engine flutter/engine repository. See also e: labels. P1 High-priority issues at the top of the work list team-engine Owned by Engine team triaged-engine Triaged by Engine team

Comments

@bdero
Copy link
Member

bdero commented Jun 30, 2023

Currently, it's only possible to configure the stencil operation symmetrically (for frontfaces and backfaces at the same time), but all of the graphics backends Impeller supports (and will support) allow for differing configuration between frontfaces and backfaces. This can be used for some 3D rendering tricks, like Carmack's Reverse.

Specifically, this would mean adding/renaming stuff in StencilAttachmentDescriptor to allow for configuring the stencil operation separately for frontfaces and backfaces, and then making it work on Metal, OpenGL, and Vulkan.
Before making a decision about how it should look, definitely check out how this works in our backends (like Metal) or other HALs (like WebGPU).

Also, it occurs to me that we don't have anything that just shows off the raw stencil ops working, so it would be nice if we could add something to renderer_unittests.cc that updates the stencil and uses it to clip another draw call, for example.

@bdero bdero added the e: impeller Impeller rendering backend issues and features requests label Jun 30, 2023
@bdero bdero added the engine flutter/engine repository. See also e: labels. label Jul 5, 2023
@chinmaygarde chinmaygarde added the P1 High-priority issues at the top of the work list label Jul 5, 2023
@flutter-triage-bot flutter-triage-bot bot added team-engine Owned by Engine team triaged-engine Triaged by Engine team labels Jul 8, 2023
@johnmccutchan
Copy link
Contributor

Digging into this more it looks like PipelineDescriptor already supports specifying front and back face stencil descriptors already.

PipelineDescriptor& SetStencilAttachmentDescriptors(
      std::optional<StencilAttachmentDescriptor> front_and_back);

  PipelineDescriptor& SetStencilAttachmentDescriptors(
      std::optional<StencilAttachmentDescriptor> front,
      std::optional<StencilAttachmentDescriptor> back);

This also appears to be wired up correctly for the Metal backend but I don't think it is wired up in the Vulkan or GLES backends.

Perhaps we want to rename StencilAttachmentDescriptor to StencilFaceAttachmentDescriptor but I'm not sure if the extra word is really adding that much. I am leaning towards not renaming anything but just fixing the implementation for Vulkan and GLES to do the right thing.

@bdero
Copy link
Member Author

bdero commented Jul 11, 2023

Ah great, yeah fixing up the existing stuff and throwing in a playground test SGTM.

johnmccutchan added a commit to flutter/engine that referenced this issue Jul 12, 2023
Fixes for asymmetric stencil descriptors

- Fix GLES implementation to properly set back and front face options in
the case that they aren't identical.
- Add write_mask to hash function.

flutter/flutter#129855
kjlubick pushed a commit to kjlubick/engine that referenced this issue Jul 14, 2023
Fixes for asymmetric stencil descriptors

- Fix GLES implementation to properly set back and front face options in
the case that they aren't identical.
- Add write_mask to hash function.

flutter/flutter#129855
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e: impeller Impeller rendering backend issues and features requests engine flutter/engine repository. See also e: labels. P1 High-priority issues at the top of the work list team-engine Owned by Engine team triaged-engine Triaged by Engine team
Projects
No open projects
Archived in project
Development

No branches or pull requests

3 participants