Reallocate materials when they change.#17979
Merged
superdump merged 1 commit intobevyengine:mainfrom Feb 22, 2025
Merged
Conversation
PR bevyengine#17898 regressed this, causing much of bevyengine#17970. This commit fixes the issue by freeing and reallocating materials in the `MaterialBindGroupAllocator` on change. Note that more efficiency is possible, but I opted for the simple approach because (1) we should fix this bug ASAP; (2) I'd like bevyengine#17965 to land first, because that unlocks the biggest potential optimization, which is not recreating the bind group if it isn't necessary to do so.
Contributor
|
With this PR I am now seeing the same panic I was seeing in This may be metal-specific. |
pcwalton
added a commit
to pcwalton/bevy
that referenced
this pull request
Feb 21, 2025
This patch fixes two bugs in the new non-bindless material allocator that landed in PR bevyengine#17898: 1. A debug assertion to prevent double frees had been flipped: we checked to see whether the slot was empty before freeing, while we should have checked to see whether the slot was full. 2. The non-bindless allocator returned `None` when querying a slab that hadn't been prepared yet instead of returning a handle to that slab. This resulted in a 1-frame delay when modifying materials. In the `animated_material` example, this resulted in the meshes never showing up at all, because that example changes every material every frame. Together with bevyengine#17979, this patch locally fixes the problems with `animated_material` on macOS that were reported in bevyengine#17970.
superdump
approved these changes
Feb 22, 2025
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 22, 2025
This patch fixes two bugs in the new non-bindless material allocator that landed in PR #17898: 1. A debug assertion to prevent double frees had been flipped: we checked to see whether the slot was empty before freeing, while we should have checked to see whether the slot was full. 2. The non-bindless allocator returned `None` when querying a slab that hadn't been prepared yet instead of returning a handle to that slab. This resulted in a 1-frame delay when modifying materials. In the `animated_material` example, this resulted in the meshes never showing up at all, because that example changes every material every frame. Together with #17979, this patch locally fixes the problems with `animated_material` on macOS that were reported in #17970.
atlv24
approved these changes
Feb 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #17898 regressed this, causing much of #17970. This commit fixes the issue by freeing and reallocating materials in the
MaterialBindGroupAllocatoron change. Note that more efficiency is possible, but I opted for the simple approach because (1) we should fix this bug ASAP; (2) I'd like #17965 to land first, because that unlocks the biggest potential optimization, which is not recreating the bind group if it isn't necessary to do so.