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

Add RenderComponent trait for transient render world marker components #16011

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

tychedelia
Copy link
Contributor

@tychedelia tychedelia commented Oct 19, 2024

Objective

Retained render world caused a number of things to break where previously we had relied on conditional extraction to toggle whether certain rendering features run or not. See the following issues and fixes:

In those fixes, we mostly attempted to restore the previous behavior by forcibly removing components from render world entities where conditional extraction previously would have caused them not to be inserted. While this fixes the superficial bugs, it's messy, error prone, and not how we want to model usage of retained render world to our users.

Solution

This pull request implements a new RenderComponent trait and corresponding derive/RenderComponentPlugin that is used to mark components as being transient markers, used for toggling render features on and off.

The idea here is that rather than relying on the presence of a component like Bloom or even ExtractedCamera to indicate that something should happen, we always try to use a marker component instead. These components are cleanup up at the end of rendering and must be inserted again the next frame during extract.

This makes some queries more complicated, since we have to remember to also add a query filter (see CameraActive, most notably), but should be less error prone overall and more clearly indicate when a certain feature is toggled on versus just having residual data.

This also allows us to mark more components as being generically extracted via ExtractComponent, which should make them easier to desync when removed from the main world, since ExtractComponentPlugin automatically inserts SyncComponentPlugin.

Testing

TODO:

Migration Guide

TODO

@alice-i-cecile
Copy link
Member

Do you want to ship this in 0.15 or save it for 0.16?

@tychedelia tychedelia added A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change X-Contentious There are nontrivial implications that should be thought through S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 19, 2024
@tychedelia tychedelia added this to the 0.15 milestone Oct 19, 2024
@tychedelia
Copy link
Contributor Author

@alice-i-cecile I've marked it contentious and put it in 0.15 for now. I discussed this general approach with @superdump last night and I think there's a general feeling the state of the conditional extraction stuff in 0.15 is pretty undesirable. Things seem to be mostly not-broken now, so we can cut this if needed but I think having a more robust fix would be good.

@alice-i-cecile
Copy link
Member

Yeah, I'm generally in favor of a more robust solution here too. The existing design is really dodgy, and I'd prefer to ship something better.

@tychedelia
Copy link
Contributor Author

@akimakinai would appreciate your opinion here since you've looked most closely at the previous defects.

@EmileGr
Copy link

EmileGr commented Oct 19, 2024

Not for this PR obviously, but could #13120 (and the related follow-up work there) make this a little cleaner in the future?

@tychedelia
Copy link
Contributor Author

Not for this PR obviously, but could #13120 (and the related follow-up work there) make this a little cleaner in the future?

Absolutely, that would be great.

@hymm
Copy link
Contributor

hymm commented Oct 19, 2024

I'm mostly concerned about the perf of this solution. Requiring 2+ archetype moves for every rendered entity every frame is probably pretty expensive.

@tychedelia
Copy link
Contributor Author

tychedelia commented Oct 19, 2024

I'm mostly concerned about the perf of this solution. Requiring 2+ archetype moves for every rendered entity every frame is probably pretty expensive.

Yup, that was our concern too, although just to be clear, it's not for rendered entities which are stored in resources already, but for things like views/lights. So typically this would only be a handful of entities.

@JMS55
Copy link
Contributor

JMS55 commented Oct 20, 2024

I'd rather removing the components from the render world to match than this solution, personally.

@tychedelia
Copy link
Contributor Author

I'd rather removing the components from the render world to match than this solution, personally.

I'm fine with exploring a his design space in 0.16 but the ad hoc removal of components is messy, error prone, and conceptually confusing given our switch to retained entities. Minimally, if the marker components are too noisy, we should still mark per-frame components for removal somehow rather than manually removing them.

@JMS55
Copy link
Contributor

JMS55 commented Oct 20, 2024

I haven't really followed any of this, but iirc the current way it works is that when a component marked for syncing to the render world is removed from the main world, we have some system that also removes it from the render world when syncing right? That seems ideal to me, unless I'm missing something.

Again I haven't followed this work all that much, so maybe I'm wrong somewhere.

@alice-i-cecile
Copy link
Member

I'm fine with exploring a his design space in 0.16 but the ad hoc removal of components is messy, error prone, and conceptually confusing given our switch to retained entities. Minimally, if the marker components are too noisy, we should still mark per-frame components for removal somehow rather than manually removing them.

Why not use TemporaryRenderEntity for this?

@tychedelia
Copy link
Contributor Author

I'm fine with exploring a his design space in 0.16 but the ad hoc removal of components is messy, error prone, and conceptually confusing given our switch to retained entities. Minimally, if the marker components are too noisy, we should still mark per-frame components for removal somehow rather than manually removing them.

Why not use TemporaryRenderEntity for this?

Most of these are views and lights, which are entities we definitely are excited about being retained. The goal here is to mark certain components as temporary, not entire entities.

@tychedelia
Copy link
Contributor Author

I don't think this is going to get review consensus so taking it out of 0.15.

@tychedelia tychedelia removed this from the 0.15 milestone Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Contentious There are nontrivial implications that should be thought through
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

5 participants