bevy/crates/bevy_render/src
Carter Anderson abcb0661e3 Camera Output Modes, MSAA Writeback, and BlitPipeline (#7671)
# Objective

Alternative to #7490. I wrote all of the code in this PR, but I have added @robtfm as co-author on commits that build on ideas from #7490. I would not have been able to solve these problems on my own without much more time investment and I'm largely just rephrasing the ideas from that PR.

Fixes #7435
Fixes #7361
Fixes #5721

## Solution

This implements the solution I [outlined here](https://github.com/bevyengine/bevy/pull/7490#issuecomment-1426580633).


 * Adds "msaa writeback" as an explicit "msaa camera feature" and default to msaa_writeback: true for each camera. If this is true, a camera has MSAA enabled, and it isn't the first camera for the target, add a writeback before the main pass for that camera.
 * Adds a CameraOutputMode, which can be used to configure if (and how) the results of a camera's rendering will be written to the final RenderTarget output texture (via the upscaling node). The `blend_state` and `color_attachment_load_op` are now configurable, giving much more control over how a camera will write to the output texture.
 * Made cameras with the same target share the same main_texture tracker by using `Arc<AtomicUsize>`, which ensures continuity across cameras. This was previously broken / could produce weird results in some cases. `ViewTarget::main_texture()` is now correct in every context.
 * Added a new generic / specializable BlitPipeline, which the new MsaaWritebackNode uses internally. The UpscalingPipelineNode now uses BlitPipeline instead of its own pipeline. We might ultimately need to fork this back out if we choose to add more configurability to the upscaling, but for now this will save on binary size by not embedding the same shader twice.
 * Moved the "camera sorting" logic from the camera driver node to its own system. The results are now stored in the `SortedCameras` resource, which can be used anywhere in the renderer. MSAA writeback makes use of this.

---

## Changelog

- Added `Camera::msaa_writeback` which can enable and disable msaa writeback.
- Added specializable `BlitPipeline` and ported the upscaling node to use this.
- Added SortedCameras, exposing information that was previously internal to the camera driver node.
- Made cameras with the same target share the same main_texture tracker, which ensures continuity across cameras.
2023-03-01 20:35:13 +00:00
..
camera Camera Output Modes, MSAA Writeback, and BlitPipeline (#7671) 2023-03-01 20:35:13 +00:00
color Fix clippy clamp warning (#7697) 2023-02-16 02:13:25 +00:00
mesh Fix some typos (#7763) 2023-02-20 22:56:57 +00:00
primitives Derive Copy for Aabb (#7401) 2023-01-30 18:27:58 +00:00
render_graph Use position in code when possible (#7621) 2023-02-11 08:28:14 +00:00
render_phase implement TypeUuid for primitives and fix multiple-parameter generics having the same TypeUuid (#6633) 2023-02-16 17:09:44 +00:00
render_resource Only execute #define if current scope is accepting lines (#7798) 2023-02-24 02:44:28 +00:00
renderer Wgpu 0.15 (#7356) 2023-01-29 20:27:30 +00:00
texture Fix some typos (#7763) 2023-02-20 22:56:57 +00:00
view Camera Output Modes, MSAA Writeback, and BlitPipeline (#7671) 2023-03-01 20:35:13 +00:00
extract_component.rs Support system.in_schedule() and system.on_startup() (#7790) 2023-02-24 18:33:55 +00:00
extract_param.rs Migrate engine to Schedule v3 (#7267) 2023-02-06 02:04:50 +00:00
extract_resource.rs Support system.in_schedule() and system.on_startup() (#7790) 2023-02-24 18:33:55 +00:00
globals.rs Support system.in_schedule() and system.on_startup() (#7790) 2023-02-24 18:33:55 +00:00
globals.wgsl Refactor Globals and View structs into separate shaders (#7512) 2023-02-11 17:55:18 +00:00
lib.rs Fix some typos (#7763) 2023-02-20 22:56:57 +00:00
pipelined_rendering.rs Rename schedule v3 to schedule (#7519) 2023-02-06 18:44:40 +00:00
render_asset.rs Support system.in_schedule() and system.on_startup() (#7790) 2023-02-24 18:33:55 +00:00
settings.rs add OpenGL and DX11 backends (#7481) 2023-02-04 23:20:20 +00:00
spatial_bundle.rs enum Visibility component (#6320) 2022-12-25 00:39:29 +00:00