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
Make render phases render world resources instead of components. #13277
base: main
Are you sure you want to change the base?
Conversation
This commit makes us stop using the render world ECS for `BinnedRenderPhase` and `SortedRenderPhase` and instead use resources with `EntityHashMap`s inside. There are three reasons to do this: 1. We can use `clear()` to clear out the render phase collections instead of recreating the components from scratch, allowing us to reuse allocations. 2. This is a prerequisite for retained bins, because components can't be retained from frame to frame in the render world, but resources can. 3. We want to move away from storing anything in components in the render world ECS, and this is a step in that direction. This patch results in a small performance benefit, due to point (1) above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems relatively straightforward as far as changes go. code flow changes (like !camera.active { continue }
) make sense to me. I was able to run the 3d_shapes
example using this PR and add a system that accessed and logged out the resources, seeing the relevant camera entity.
consider my review partial since I haven't done many rendering reviews yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good.
i guess iterating all views and filtering for those with matching phases could be slower than using query filters (as we were before), but views are very low count so i don't think it'll ever be significant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked at the code yet. I profiled on the following scenes:
- San Miguel
- Bistro
I found no significant performance degradation or improvement on my (extremely GPU bound) laptop (11th gen i7 w/ integrated graphics).
I tested the following examples and found no visual artifacts or other issues compared to current main:
2d_shape
atomospheric_fog
color_animation
pbr
many_foxes
gltf_skinned_mesh
motion_blur
Approving based on tests. Will take a look at the code when I can.
Addressed review comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: all those EntityHashSet
s could be Local
s to avoid allocs each frame
Marking as draft not only because of the review comment but also because this triggered #13402, which it should not have, so I want to figure out why that is. |
This fixes the problem that led to bevyengine#13402. I'm not sure if this had any negative consequences, but it didn't replicate the prior behavior with the `Or` query filter, so I changed it to match.
I found the problem. I don't think they were actually rendered, but this was inefficient, so I added the check back. |
Commit 3f5a090 added a reference to `STANDARD_MATERIAL_FLAGS_BASE_COLOR_UV_BIT`, a nonexistent identifier, in the alpha discard portion of the prepass shader. Moreover, the logic didn't make sense to me. I think the code was trying to choose between the two UV sets depending on which is present, so I made it do that. I noticed this when trying Bistro with #13277. I'm not sure why this issue didn't manifest itself before, but it's clearly a bug, so here's a fix. We should probably merge this before 0.14.
This commit makes us stop using the render world ECS for
BinnedRenderPhase
andSortedRenderPhase
and instead use resources withEntityHashMap
s inside. There are three reasons to do this:We can use
clear()
to clear out the render phase collections instead of recreating the components from scratch, allowing us to reuse allocations.This is a prerequisite for retained bins, because components can't be retained from frame to frame in the render world, but resources can.
We want to move away from storing anything in components in the render world ECS, and this is a step in that direction.
This patch results in a small performance benefit, due to point (1) above.
Changelog
Changed
BinnedRenderPhase
andSortedRenderPhase
render world components have been replaced withViewBinnedRenderPhases
andViewSortedRenderPhases
resources.Migration Guide
BinnedRenderPhase
andSortedRenderPhase
render world components have been replaced withViewBinnedRenderPhases
andViewSortedRenderPhases
resources. Instead of querying for the components, look the camera entity up in theViewBinnedRenderPhases
/ViewSortedRenderPhases
tables.