Conversation
- Check if the entity path is a directory before trying to load mod-specific sub-textures. - For single-file entity textures, load the image once and reuse the texture handle across mod types instead of reloading the file up to 8 times into GPU memory. - In ClearCustomItems, use AssetsUnloadEntitiesPreview to properly unload deduplicated texture handles.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues remain, and the changes address redundant loading and safe texture cleanup.
Review effort: Lite
Findings: None
What changed in this PR
Prevents redundant entity texture loading and safely unloads shared handles to avoid VRAM exhaustion.
Changes:
- Detects entity folders before loading mod-specific textures.
- Shares fallback textures across mod types.
- Deduplicates texture cleanup.
| File | Description |
|---|---|
src/game/client/components/menus_settings_assets.cpp |
Updates entity texture loading and cleanup logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
Fixes an issue where opening the Assets settings tab causes an out-of-VRAM crash (
GFX_ERROR_TYPE_OUT_OF_MEMORY_IMAGE), particularly when custom high-resolution entity textures (e.g. 2K or 4K) are present inassets/entities.Details
Deduplicate texture loading for single-file entities:
CMenus::LoadEntities(), when an entity item is a single PNG file rather than a directory, the loop previously calledLoadTexture()repeatedly for each of theMAP_IMAGE_MOD_TYPE_COUNTmod types during fallback.VK_ERROR_OUT_OF_DEVICE_MEMORY.FolderExistsfirst to avoid spamming file read errors for non-existent subpaths, load the fallback texture only once, and share the texture handle across mod types.Safe texture unloading:
CMenus::ClearCustomItems(), useAssetsUnloadEntitiesPreview(Entity, Graphics())(matchingRemoveCustomAssetFromList) to cleanly deduplicate and invalidate shared handles before destroying textures.