Skip to content

Resolve one compositing space per camera stack - #25481

Open
stuartparmenter wants to merge 4 commits into
bevyengine:mainfrom
stuartparmenter:hdr-wave2-resolved-compositing-space
Open

Resolve one compositing space per camera stack#25481
stuartparmenter wants to merge 4 commits into
bevyengine:mainfrom
stuartparmenter:hdr-wave2-resolved-compositing-space

Conversation

@stuartparmenter

@stuartparmenter stuartparmenter commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Objective

Part of the HDR upstreaming work. The display pipeline coming in later PRs needs cameras that share a render target to agree on one compositing space, since they composite into one shared buffer and later passes have to know how it's encoded. Two follow-up PRs build directly on this, the camera-stack composition contract and the shared writer-encode path.

Getting there also fixes real bugs that exist today. Stacked cameras can request different CompositingSpaces, and each keys its own pipelines, so they write differently encoded pixels into one buffer and silently composite garbage. Oklab on a texture format that can't store its negative values breaks just as silently, as do requests on render paths that never encode.

Solution

A new bevy_render::view::composition module resolves every view's request once per frame into a ResolvedCompositingSpace component. A stack resolves to the single distinct encoded request among its members, or to linear when there is none. Misconfigured shapes resolve to linear with a warning. Solo views and non-stack groups keep their own requests.

Every consumer reads the resolved value instead of the raw request, including the sprite and mesh2d keys, the clear-color conversion, and the upscaling blit key. ViewTarget::compositing_space is removed, with a migration guide entry. Two 2D specialization systems move later in the schedule so their caches see this frame's resolved value.

Testing

Added lots of new tests, Check, clippy, and tests pass.


This PR was built by me with the assistance of Claude Code w/ Fable 5

@stuartparmenter
stuartparmenter force-pushed the hdr-wave2-resolved-compositing-space branch from 2bd8146 to 0e03988 Compare August 20, 2026 04:31
@stuartparmenter
stuartparmenter requested a review from mate-h August 20, 2026 04:32
@stuartparmenter stuartparmenter added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Aug 20, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Aug 20, 2026

@JMS55 JMS55 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review of things minus composition.rs (haven't gotten to it yet).

Idea is sound to me, mostly some nits and some things I'm worried about changing.

Comment thread crates/bevy_render/src/view/mod.rs Outdated
Comment thread crates/bevy_sprite_render/src/mesh2d/mesh.rs
Comment thread crates/bevy_sprite_render/src/mesh2d/mesh.rs Outdated
Comment thread crates/bevy_sprite_render/src/mesh2d/mesh.rs Outdated
Comment thread crates/bevy_sprite_render/src/mesh2d/wireframe2d.rs
Comment thread crates/bevy_sprite_render/src/render/mod.rs Outdated

@JMS55 JMS55 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed composition.rs now. Overall idea is fine, but the comments could use a lot of work. They're making things more confusing, not less.

Comment thread crates/bevy_render/src/view/composition.rs Outdated
Comment thread crates/bevy_render/src/view/composition.rs Outdated
Comment thread crates/bevy_render/src/view/composition.rs
Comment thread crates/bevy_render/src/view/composition.rs Outdated
Comment thread crates/bevy_render/src/view/composition.rs Outdated
Comment thread crates/bevy_render/src/view/composition.rs Outdated
Comment thread crates/bevy_render/src/view/composition.rs Outdated
Comment thread crates/bevy_render/src/view/composition.rs Outdated
Comment thread crates/bevy_render/src/view/composition.rs Outdated
Comment thread crates/bevy_render/src/view/composition.rs Outdated
@stuartparmenter
stuartparmenter requested a review from JMS55 August 22, 2026 01:16
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-Feature A new feature, making something new possible S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

2 participants