Skip to content
This repository was archived by the owner on Oct 21, 2026. It is now read-only.

Emit override-redirected functions in deterministic order - #137

Merged
robtfm merged 1 commit into
bevyengine:masterfrom
robtfm:fix/deterministic-redirector-order
Jul 4, 2026
Merged

robtfm merged 1 commit into
bevyengine:masterfrom
robtfm:fix/deterministic-redirector-order

Conversation

@robtfm

@robtfm robtfm commented Jun 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Redirector::into_module topologically sorts functions so dependents are emitted before their callers, but it drives the emission order by iterating a HashMap. That order is valid but arbitrary and reseeds every process, so a module that uses a function override (the redirector only runs when an override is present) composes to byte-different output on every run. This breaks gpu-driver shader caching.

Fix

Use an IndexMap so the retain() loop visits functions in the deterministic source-arena order; same-level functions then emit in a stable order. Behaviour is otherwise unchanged, this path is only reachable when a function override exists, and indexmap is already a dependency.

`Redirector::into_module` drove emission order by iterating a `HashMap`, so a
module that uses a function override composed to byte-different output each run,
defeating caches keyed on the generated source. Use an `IndexMap` for stable,
deterministic source-arena order.
@robtfm
robtfm merged commit 32fc887 into bevyengine:master Jul 4, 2026
7 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants