Create mesh view bind group layout on demand to remove unused bindings#23982
Create mesh view bind group layout on demand to remove unused bindings#23982alice-i-cecile merged 17 commits intobevyengine:mainfrom
Conversation
IceSentry
left a comment
There was a problem hiding this comment.
Could the logic to create the offsets array be pulled out to a separate system that runs before the various render commands and stores it in as a component on the view? That way it doesn't need to be copy pasted everywhere.
There was a problem hiding this comment.
Thank you for doing this!
I tested it with the 3d_scene example as described and it is no longer broken for me.
This does not fix #23975 but that’s a separate issue. (This PR reduces the sampled textures to 17. I also get some other validation error about dynamic offsets: BindGroup with 'mesh_view_bind_group' label 0 expects 4 dynamic offsets. However 5 dynamic offsets were provided.) That can be a separate PR (and probably should be separate to keep this PR less complicated).
Add MeshViewLayoutKey component Reuse heap allocation in `prepare_mesh_view_bind_groups` Remove contact shadows offset and distance fog offset if disabled
8331905 to
059affa
Compare
059affa to
b3e7359
Compare
kfc35
left a comment
There was a problem hiding this comment.
Thank you for consolidating! It feels cleaner
Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
|
This looks good and cleans up a lot of the code I've been working with. |
…g `MeshPipelineViewLayoutKey` (bevyengine#24090) # Objective - Related bevyengine#24084 - Fixes `atmosphere` example after merging bevyengine#23982 ## Solution - As @beicause mentioned, volumetric frog was calculating `MeshPipelineViewLayoutKey` manually when it could just rely on the `ViewKeyCache` instead, which has centralized logic for calculating it in `check_views_need_specialization` (`STBN` is added in `impl From<MeshPipelineKey> for MeshPipelineViewLayoutKey`) ## Testing - `cargo run --example atmosphere` works now, no strobing! - `cargo run --example volumetric_fog` also works - `cargo run --example scrolling_fog` works
Objective
Fixes #23627.
MeshPipelineViewLayoutKeyuses too many bindings even if features like ssr, environment map are unused.Solution
Don't pre-allocate every combination that grows exponentially. Instead, create mesh view bind group layout on demand so that we can add more view keys to reduce unused bindings.
MeshPipelineViewLayouts::get_view_layoutwill be slower, but I'm not sure how slow it is. My feeling is that the overhead is not high, compared to when we clone it before.Testing