bevyengine / bevyengine/bevy

Add verification to the specialized material pipeline cache

Open
#23,119 0 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Feature S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

The renderer keeps a cache of specialized material pipelines as an optimization - see `SpecializedMaterialPipelineCache` and variants. But it's easy for the cache to accidentally become stale and cause issues that are hard to debug, like #18712 and #23118.

## What solution would you like?

There should be a feature flag and/or runtime toggle that enables cache verification. So when specialization gets a cache hit, it should continue to recalculate the pipeline and verify it's the same as the cached pipeline. Ideally it would also log details on what inputs were different, like `MeshPipelineKey`.

Currently the cache logic is semi-duplicated in several specialization functions - `specialize_material_meshes`, `specialize_prepass_material_meshes`, and `specialize_shadows`. So some refactoring might be needed if they want to share verification.

## What alternative(s) have you considered?

Add a toggle that simply disables the cache. This is more limited, but still useful for testing.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.