Skip to content

Commit

Permalink
Add a PrepareBatches render set that runs after PrepareResources.
Browse files Browse the repository at this point in the history
PR bevyengine#10231 needs to add some logic that runs as part of
`PrepareResources` but before batch building, because it creates data
that batch building needs. This commit adds a new render set for this.
It was split out of bevyengine#10231 at reviewer request.
  • Loading branch information
pcwalton committed Oct 23, 2023
1 parent e59085a commit 2568518
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ impl Plugin for MeshRenderPlugin {
batch_and_prepare_render_phase::<Opaque3dDeferred, MeshPipeline>,
batch_and_prepare_render_phase::<AlphaMask3dDeferred, MeshPipeline>,
)
.in_set(RenderSet::PrepareResources),
.in_set(RenderSet::PrepareBatches),
write_batched_instance_buffer::<MeshPipeline>
.in_set(RenderSet::PrepareResourcesFlush),
.in_set(RenderSet::PrepareBatchesFlush),
prepare_skins.in_set(RenderSet::PrepareResources),
prepare_morphs.in_set(RenderSet::PrepareResources),
prepare_mesh_bind_group.in_set(RenderSet::PrepareBindGroups),
Expand Down
15 changes: 13 additions & 2 deletions crates/bevy_render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ pub enum RenderSet {
Prepare,
/// A sub-set within [`Prepare`](RenderSet::Prepare) for initializing buffers, textures and uniforms for use in bind groups.
PrepareResources,
/// The copy of [`apply_deferred`] that runs between [`PrepareResources`](RenderSet::PrepareResources) and ['PrepareBindGroups'](RenderSet::PrepareBindGroups).
/// The copy of [`apply_deferred`] that runs between [`PrepareResources`](RenderSet::PrepareResources) and ['PrepareBatches'](RenderSet::PrepareBatches).
PrepareResourcesFlush,
/// A sub-set within [`Prepare`](RenderSet::Prepare) that prepares batches of meshes.
PrepareBatches,
/// The copy of [`apply_deferred`] that runs between [`PrepareBatches`](RenderSet::PrepareBatches) and ['PrepareBindGroups'](RenderSet::PrepareBindGroups).
PrepareBatchesFlush,
/// A sub-set within [`Prepare`](RenderSet::Prepare) for constructing bind groups, or other data that relies on render resources prepared in [`PrepareResources`](RenderSet::PrepareResources).
PrepareBindGroups,
/// The copy of [`apply_deferred`] that runs immediately after [`Prepare`](RenderSet::Prepare).
Expand Down Expand Up @@ -137,6 +141,7 @@ impl Render {
schedule.add_systems((
apply_deferred.in_set(ManageViewsFlush),
apply_deferred.in_set(PrepareResourcesFlush),
apply_deferred.in_set(PrepareBatchesFlush),
apply_deferred.in_set(RenderFlush),
apply_deferred.in_set(PrepareFlush),
apply_deferred.in_set(CleanupFlush),
Expand Down Expand Up @@ -166,7 +171,13 @@ impl Render {
.after(prepare_assets::<Mesh>),
);
schedule.configure_sets(
(PrepareResources, PrepareResourcesFlush, PrepareBindGroups)
(
PrepareResources,
PrepareResourcesFlush,
PrepareBatches,
PrepareBatchesFlush,
PrepareBindGroups,
)
.chain()
.in_set(Prepare),
);
Expand Down

0 comments on commit 2568518

Please sign in to comment.