Skip to content

Reuse ViewKeyCache where possible#22809

Open
levydsa wants to merge 2 commits intobevyengine:mainfrom
levydsa:reuse_view_key_cache
Open

Reuse ViewKeyCache where possible#22809
levydsa wants to merge 2 commits intobevyengine:mainfrom
levydsa:reuse_view_key_cache

Conversation

@levydsa
Copy link

@levydsa levydsa commented Feb 5, 2026

Objective

  • Creating a MeshPipelineKey is tricky and can lead to easily avoidable errors: Atmosphere with Gizmos is broken #21784
  • We already cache the MeshPipelineViewLayoutKey part of MeshPipelineKey for each view in ViewKeyCache with the correct layout for any draw call that uses SetMeshViewBindGroup
  • Instruct users to use ViewKeyCache to properly setup the pipeline for any view features.

Solution

  • Reuse ViewKeyCache where possible in the engine and examples.
  • Attempt at adding documentation for ViewKeyCache

@levydsa levydsa force-pushed the reuse_view_key_cache branch from 6f334eb to 938ac5e Compare February 5, 2026 02:48
@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 5, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in Rendering (2026 Proposal) Feb 5, 2026
@alice-i-cecile alice-i-cecile added the C-Examples An addition or correction to our examples label Feb 5, 2026
Copy link
Contributor

@atlv24 atlv24 left a comment

Choose a reason for hiding this comment

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

very nice cleanup. my only concern was maybe system ordering related regarding cache not being up to date for a frame when a view changes but i spot checked a few and the ordering looks right.

}

/// This resource caches [`MeshPipelineKey`]s for each view with pre-enabled features needed to properly
/// setup the [`MeshViewBindGroup`] layout in specialized [`MeshPipeline`]s.
Copy link
Contributor

Choose a reason for hiding this comment

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

note that bevy_sprite_render has a ViewKeyCache also, may be worth giving it a similar doc

@kristoff3r kristoff3r 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 Feb 6, 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-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: No status
Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

5 participants