-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Merge Draw function and RenderCommand #7172
Merge Draw function and RenderCommand #7172
Conversation
372d415
to
570d23c
Compare
I have updated the documentation and rebased it onto main. This PR should now be ready for review. |
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.
Please fix the CI issues. Not sure if this fully compiles or not.
let draw_function = draw_functions.get_mut(item.draw_function()).unwrap(); | ||
draw_function.draw(world, render_pass, view, item); | ||
} | ||
let render_commands = world.resource::<RenderCommands<P>>(); |
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.
Curious if we could use &mut World and World::resource_scope here. It would allow us to remove the internal RwLock on RenderCommands.
This is probably at odds with parallelizing the render phase (i.e. with wgpu's RenderBundles), so feel free to ignore this.
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.
I am not too familiar with the ECS internals, but could we move the RenderCommandState::prepare
logic out of the render graph? Maybe into the actual RenderStage::Prepare
?
It seems like the only thing inside the RenderCommandState::render
method that requires a mutable reference to self is the line: let param = self.state.get(world);
.
This seems linked to #7084. But there the line: let param = self.state.get_manual(world);
, still requires a mutable reference to self. Would it be possible to change that or is SystemState
fundamentally different from QueryState
in this regard?
Given that we could make the render method immutable and run the prepare method before the render graph, then we could eliminate the need for the RwLock, right?
db49394
to
08edef5
Compare
08edef5
to
bc66cac
Compare
bc66cac
to
8101e7c
Compare
8101e7c
to
5150e68
Compare
/// When fetching resources, note that, due to lifetime limitations of the `Deref` trait, | ||
/// [`SRes::into_inner`] must be called on each [`SRes`] reference in the | ||
/// [`RenderCommand::render`] method, instead of being automatically dereferenced as is the | ||
/// case in normal `systems`. | ||
/// | ||
/// All parameters have to be read only. | ||
/// | ||
/// [`SRes`]: bevy_ecs::system::lifetimeless::SRes | ||
/// [`SRes::into_inner`]: bevy_ecs::system::lifetimeless::SRes::into_inner |
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.
This should not be removed.
Objective
Currently, you can choose between a
Draw
function and aRenderCommand
to render yourPhaseItems
.Inspired by the recent merge of
PhaseItem
andEntityPhaseItem
(#6885), this PR does the same forDraw
andRenderCommand
.Are there use cases that are not covered by the RenderCommand abstraction?
This change aims to reduce the (irrelevant) decisions our users have to make and simplify our rendering terminology.
I believe that this is now much simpler: A
RenderPhase
renderers multipleRenderItems
via the composableRenderCommand
s, by changing the state of theTrackedRenderPass
.We can still decide how we name this
RenderCommand
/DrawFunction
, or maybe evenDrawCommand
.Let me know which name you like best.
Solution
Changelog
Todo
Migration Guide
Todo