Skip to content

Handle optional depth and stencil views of view depth and prepass depth texture#24725

Open
beicause wants to merge 5 commits into
bevyengine:mainfrom
beicause:handle-optional-depth-stencil-view
Open

Handle optional depth and stencil views of view depth and prepass depth texture#24725
beicause wants to merge 5 commits into
bevyengine:mainfrom
beicause:handle-optional-depth-stencil-view

Conversation

@beicause

@beicause beicause commented Jun 23, 2026

Copy link
Copy Markdown
Member

Objective

Related: #21358
Supersedes #22556

Solution

To support custom depth formats, we need to handle depth and stencil views depending on usage: only single aspect view can be used as resource binding in shaders, only full aspect view can be used as a render attachment.

Refactor DepthAttachment, ViewDepthTexture and ViewPrepassTextures::depth to handle optional depth and stencil views.

This does not yet support custom depth formats. The depth formats needs to be added to pipeline key similar to how color texture formats are handled, as a followup (adopt #21493)

Testing

CI

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen X-Uncontroversial This work is generally agreed upon D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 23, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Jun 23, 2026
pub use morph::*;
pub use skin::{extract_skins, prepare_skins, skins_use_uniform_buffers, SkinUniforms, MAX_JOINTS};

pub const CORE_3D_SHADOW_MAP_FORMAT: wgpu_types::TextureFormat =

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.

Just to make sure I understand this. Right now this is the same as the default depth format but this is done for when we eventually have configurable depth/stencil attachment so the shadow pass has it's own format?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah. I think there is no reason to use a dpeth format with stencil for shadow map

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.

Yep, agreed. I just wanted to make sure that was the intention for this new const.

@IceSentry IceSentry 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.

LGTM

@kfc35 kfc35 self-requested a review June 26, 2026 04:32

@kfc35 kfc35 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.

Just comments on whether it’s valuable to re-name in this PR, and some two other smaller things. Looks good to me though

Comment thread crates/bevy_render/src/texture/texture_attachment.rs Outdated
Comment thread crates/bevy_render/src/texture/texture_attachment.rs Outdated
Comment thread crates/bevy_render/src/view/mod.rs Outdated
Comment thread _release-content/migration-guides/depth_attachment_changes.md
(None, Some(shadow_occlusion_culling)) => &shadow_occlusion_culling.depth_texture_view,
(None, None) => {
// No depth texture
continue;

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.

This used to panic before if I understand correctly. Is this now an acceptable thing to just ignore? Should there be a warning just in case?

@kfc35 kfc35 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 27, 2026
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 D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants