Skip to content
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

[Merged by Bors] - Improve render phase documentation #7016

Conversation

kurtkuehnert
Copy link
Contributor

@kurtkuehnert kurtkuehnert commented Dec 23, 2022

Objective

The documentation of the bevy_render crate is still pretty incomplete.
This PR follows up on #6885 and improves the documentation of the render_phase module.
This module contains one of our most important rendering abstractions and the current documentation is pretty confusing. This PR tries to clarify what all of these pieces are for and how they work together to form bevy`s modular rendering logic.

Solution

Code Reformating

  • I have moved the rangefinder into the render_phase module since it is only used there.
  • I have moved the PhaseItem (and the BatchedPhaseItem) from render_phase::draw over to render_phase::mod. This does not change the public-facing API since they are reexported anyway, but this change makes the relation between RenderPhase and PhaseItem clear and easier to discover.

Documentation

  • revised all documentation in the render_phase module
  • added a module-level explanation of how RenderPhases, RenderPasses, PhaseItems, Draw functions, and RenderCommands relate to each other and how they are used

Changelog

  • The rangefinder module has been moved into the render_phase module.

Migration Guide

  • The rangefinder module has been moved into the render_phase module.
//old
use bevy::render::rangefinder::*;

// new
use bevy::render::render_phase::rangefinder::*;

@IceSentry IceSentry added C-Docs An addition or correction to our documentation A-Rendering Drawing game state to the screen labels Dec 23, 2022
@james7132
Copy link
Member

@kurtkuehnert Do you think you can isolate this from the other PRs? Chained PRs like this tend to be a nightmare to contend with in terms of merge conflicts, and even harder to review while those other PRs are in flux.

@kurtkuehnert
Copy link
Contributor Author

kurtkuehnert commented Dec 24, 2022

I could probably separate this PR from #7017 #7013 due to its small scope. But this PR largely depends on your #6885 and is meant to be merged after it. I could split them, but I fear that this would lead to inconsistencies, which would require further PRs to fix. It should be possible to rebase this PR if/once #6885 is merged.

@JoJoJet
Copy link
Member

JoJoJet commented Dec 24, 2022

I could probably separate this PR from #7017

Did you mean #7013?

@kurtkuehnert
Copy link
Contributor Author

@JoJoJet Yes.

@kurtkuehnert kurtkuehnert force-pushed the improve_render_phase_documentation branch from 9286dc2 to 30d3f3d Compare December 24, 2022 09:09
@kurtkuehnert
Copy link
Contributor Author

@james7132 This PR now only depends on #6885 and should be rebased+merged once your PR has been merged.

@kurtkuehnert
Copy link
Contributor Author

kurtkuehnert commented Dec 24, 2022

For now, reviewers can just take a look at commit 384a287 following.

@james7132
Copy link
Member

@kurtkuehnert with #6885 merged, can you rebase this PR so it can be reviewed?

@kurtkuehnert kurtkuehnert force-pushed the improve_render_phase_documentation branch from 70d3233 to 78195de Compare January 4, 2023 10:28
@kurtkuehnert
Copy link
Contributor Author

@james7132 I have rebased this PR onto main.
It is now ready for review.

Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a cursory run through. Will give a thorough review later.

crates/bevy_render/src/render_phase/draw.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw_state.rs Outdated Show resolved Hide resolved

/// A resource to collect and sort draw requests for specific [`PhaseItems`](PhaseItem).
/// A render phase sorts and renders all [`PhaseItem`]s (entities) that are assigned to it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A render phase sorts and renders all [`PhaseItem`]s (entities) that are assigned to it.
/// A collection of all rendering commands for a single rendering phase for a single view.
///
/// These commands are included as individual [`PhaseItem`] that encodes how to draw one ore more
/// entities to the screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not really collecting rendering commands, but rather PhaseItems.
How about

/// A collection of all [`PhaseItem`]s for a single rendering phase for a single view.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a way, each phase item is a bundle of rendering commands. As a summary of what the type does, I'd rather us avoid referential descriptions, especially when it's not clear to the normal user what a PhaseItem is from a glance.

Copy link
Contributor Author

@kurtkuehnert kurtkuehnert Jan 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use the term rendering instructions instead of rendering commands because the latter are stored in DrawFunctionsInternal instead. I think this is a good compromise. Do you agree?

/// A collection of all rendering instructions, that will be executed by the GPU, for a
/// single rendering phase for a single view.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, though it could be a bit confusing since "instructions" usually imply CPU/GPU machine instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhh, yeah both are not ideal. I will change it back to commands if other reviewers agree that this is the better term. 👍

@kurtkuehnert kurtkuehnert force-pushed the improve_render_phase_documentation branch from d37e989 to a641ca1 Compare January 8, 2023 09:37
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally a clear improvement.

Some doc suggestions, and TODO comments should be moved into issues instead so they can be better tracked and discussed.

crates/bevy_render/src/render_phase/draw.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw_state.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/mod.rs Outdated Show resolved Hide resolved
@kurtkuehnert kurtkuehnert force-pushed the improve_render_phase_documentation branch from bce5792 to d7e2357 Compare January 11, 2023 13:04
Copy link
Contributor

@djeedai djeedai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly OK for me, some minor corrections.

crates/bevy_render/src/render_phase/draw.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw_state.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/draw_state.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/mod.rs Show resolved Hide resolved
crates/bevy_render/src/render_phase/mod.rs Show resolved Hide resolved
crates/bevy_render/src/render_phase/mod.rs Show resolved Hide resolved
crates/bevy_render/src/render_phase/mod.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/render_phase/mod.rs Outdated Show resolved Hide resolved
@alice-i-cecile
Copy link
Member

If you would like, then I can extend the documentation with further details tomorrow.

Once this is in I intend to merge this PR :)

@kurtkuehnert
Copy link
Contributor Author

Once this is in I intend to merge this PR :)

@alice-i-cecile I have addressed the feedback :).

@alice-i-cecile
Copy link
Member

bors r+

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jan 12, 2023
bors bot pushed a commit that referenced this pull request Jan 12, 2023
# Objective

The documentation of the bevy_render crate is still pretty incomplete.
This PR follows up on #6885 and improves the documentation of the `render_phase` module.
This module contains one of our most important rendering abstractions and the current documentation is pretty confusing. This PR tries to clarify what all of these pieces are for and how they work together to form bevy`s modular rendering logic.

## Solution

### Code Reformating
- I have moved the `rangefinder` into the `render_phase` module since it is only used there.
- I have moved the `PhaseItem` (and the `BatchedPhaseItem`) from `render_phase::draw` over to `render_phase::mod`. This does not change the public-facing API since they are reexported anyway, but this change makes the relation between `RenderPhase` and `PhaseItem` clear and easier to discover.

### Documentation
- revised all documentation in the `render_phase` module
- added a module-level explanation of how `RenderPhase`s, `RenderPass`es, `PhaseItem`s, `Draw` functions, and `RenderCommands` relate to each other and how they are used

---

## Changelog

- The `rangefinder` module has been moved into the `render_phase` module.

## Migration Guide

- The `rangefinder` module has been moved into the `render_phase` module.

```rust
//old
use bevy::render::rangefinder::*;

// new
use bevy::render::render_phase::rangefinder::*;
```
@bors bors bot changed the title Improve render phase documentation [Merged by Bors] - Improve render phase documentation Jan 12, 2023
@bors bors bot closed this Jan 12, 2023
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
# Objective

The documentation of the bevy_render crate is still pretty incomplete.
This PR follows up on bevyengine#6885 and improves the documentation of the `render_phase` module.
This module contains one of our most important rendering abstractions and the current documentation is pretty confusing. This PR tries to clarify what all of these pieces are for and how they work together to form bevy`s modular rendering logic.

## Solution

### Code Reformating
- I have moved the `rangefinder` into the `render_phase` module since it is only used there.
- I have moved the `PhaseItem` (and the `BatchedPhaseItem`) from `render_phase::draw` over to `render_phase::mod`. This does not change the public-facing API since they are reexported anyway, but this change makes the relation between `RenderPhase` and `PhaseItem` clear and easier to discover.

### Documentation
- revised all documentation in the `render_phase` module
- added a module-level explanation of how `RenderPhase`s, `RenderPass`es, `PhaseItem`s, `Draw` functions, and `RenderCommands` relate to each other and how they are used

---

## Changelog

- The `rangefinder` module has been moved into the `render_phase` module.

## Migration Guide

- The `rangefinder` module has been moved into the `render_phase` module.

```rust
//old
use bevy::render::rangefinder::*;

// new
use bevy::render::render_phase::rangefinder::*;
```
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

The documentation of the bevy_render crate is still pretty incomplete.
This PR follows up on bevyengine#6885 and improves the documentation of the `render_phase` module.
This module contains one of our most important rendering abstractions and the current documentation is pretty confusing. This PR tries to clarify what all of these pieces are for and how they work together to form bevy`s modular rendering logic.

## Solution

### Code Reformating
- I have moved the `rangefinder` into the `render_phase` module since it is only used there.
- I have moved the `PhaseItem` (and the `BatchedPhaseItem`) from `render_phase::draw` over to `render_phase::mod`. This does not change the public-facing API since they are reexported anyway, but this change makes the relation between `RenderPhase` and `PhaseItem` clear and easier to discover.

### Documentation
- revised all documentation in the `render_phase` module
- added a module-level explanation of how `RenderPhase`s, `RenderPass`es, `PhaseItem`s, `Draw` functions, and `RenderCommands` relate to each other and how they are used

---

## Changelog

- The `rangefinder` module has been moved into the `render_phase` module.

## Migration Guide

- The `rangefinder` module has been moved into the `render_phase` module.

```rust
//old
use bevy::render::rangefinder::*;

// new
use bevy::render::render_phase::rangefinder::*;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Docs An addition or correction to our documentation S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants