TrackedRenderPass Ergonomics#7227
Closed
kurtkuehnert wants to merge 2 commits intobevyengine:mainfrom
Closed
Conversation
bcdef6b to
bb7b5d4
Compare
kurtkuehnert
commented
Jan 23, 2023
| .set_label("bloom_prefilter_pass") | ||
| .add_color_attachment(view) | ||
| .begin() | ||
| .set_camera_viewport(camera) |
Contributor
Author
There was a problem hiding this comment.
I should probably remove this line.
kurtkuehnert
commented
Jan 23, 2023
|
|
||
| impl ClearColorConfig { | ||
| #[inline] | ||
| pub fn load_op(&self, world: &World) -> LoadOp<RawColor> { |
Contributor
Author
There was a problem hiding this comment.
Todo: needs documentation
kurtkuehnert
commented
Jan 23, 2023
Comment on lines
+336
to
+354
| pub(crate) fn begin_tracked_render_pass<'a>( | ||
| &'a mut self, | ||
| descriptor: RenderPassDescriptor<'a, '_>, | ||
| view_entity: Entity, | ||
| ) -> TrackedRenderPass<'a> { | ||
| // Cannot use command_encoder() as we need to split the borrow on self | ||
| let command_encoder = self.command_encoder.get_or_insert_with(|| { | ||
| self.render_device | ||
| .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()) | ||
| }); | ||
| TrackedRenderPass::new( | ||
| &self.render_device, | ||
| command_encoder.begin_render_pass(&descriptor), | ||
| view_entity, | ||
| ) | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This method is still required, due to the split borrow.
Contributor
Author
|
IMO we should consider merging |
2 tasks
26dc71f to
4ff6233
Compare
…r API updated builder API to support arbitrary attachments TrackedRenderPass methods can be chained associated TrackedRenderPass with the view Entity added render_phase method to TrackedRenderPass added TrackedRenderPassBuilder changed set_camera_viewport method to take &Camera instead of &Viewport
4ff6233 to
23b9e18
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
The current code for creating render passes and executing render phases is quite indentation-heavy and repetitive.
I have experimented with further improving the API, based on the proposal by @cart (posted in #7043 (comment)):
Example
First, let me show you a comparison between the old and the new API.
Solution
Cart's solution is not directly realizable, since we have no central camera object.
Instead, I propose a builder-style API for setting up the
TrackedRenderPass.This PR comprises multiple improvements (which can be split apart and merged separately, if desired. I wanted to showcase them all at once first.)
1. I have added a
TrackedRenderPassBuilder, which sets up the render pass's attachments.ViewTargetand theViewDepthTextureinto a single struct (in a follow up PR).2. The
RenderPhases are now executed directly using theTrackedRenderPass, with the API described above.TrackedRenderPassis associated with aview_entity.view_entitys in the render method ofDrawfunctions. Instead, they can be accessed directly from theTrackedRenderPassif they are needed.3. Changed
TrackedRenderPass::set_camera_viewportto take a&ExtractedCamerainstead of a&Viewport4. Chainable
TrackedRenderPassmethodsTrackedRenderPassreturn a mutable reference to Self.5. Added
load_opmethod toClearColorConfigChangelog
Todo
Migration Guide
Todo