Ktx2, Basis, and DDS files ignoring RenderAssetUsages from .meta files#22992
Ktx2, Basis, and DDS files ignoring RenderAssetUsages from .meta files#22992alice-i-cecile merged 2 commits intobevyengine:mainfrom
Conversation
Objective Fixes bevyengine#22969 Setting asset_usage in a .meta file (e.g. RenderAssetUsages("RENDER_WORLD")) is silently ignored for KTX2, Basis, and DDS textures. The texture always loads with the default MAIN_WORLD | RENDER_WORLD, so CPU-side pixel data is never freed after GPU upload. This happens because asset_usage is only applied inside the catch-all _ arm of the format match in Image::from_buffer. The KTX2, Basis, and DDS arms call their own *_buffer_to_image functions which create an Image::default(), bypassing the setting entirely. Solution Set `image.asset_usage = asset_usage` after the format match in from_buffer, right next to where image.sampler is already set. This applies the correct usage for all formats uniformly. Testing cargo test -p bevy_image, all tests pass.
|
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
|
Thanks everyone for the reviews. I’m excited to see this (admittedly trivial) fix get merged. What is the process of cutting a 0.18.1 vs 0.19 release? Personally I would hope this makes it into the next minor release given that it is purely a bug fix. I look at the contribution docs and didn’t see anything in that regard. |
|
@mholiv Thanks for your first contribution! Someone else already added it to the 0.18.1 milestone, but I just wanted to add that there isn’t really a formal process except letting everyone know your desire (which you did with your PR comment), and someone on the triage team can tag it appropriately for you for review. It’s a good point that maybe we should note that in the contribution docs or something 😅 |
Objective
Fixes #22969
Setting asset_usage in a .meta file (e.g.
RenderAssetUsages("RENDER_WORLD")) is silently ignored for KTX2, Basis, and DDS textures. The texture always loads with the defaultMAIN_WORLD | RENDER_WORLD, so CPU-side pixel data is never freed after GPU upload.This happens because
asset_usageis only applied inside the catch-all_arm of the format match inImage::from_buffer. The KTX2, Basis, and DDS arms call their own *_buffer_to_image functions which create anImage::default(), bypassing the setting entirely.Solution
Set
image.asset_usage = asset_usageafter the format match in from_buffer, right next to whereimage.sampleris already set. This applies the correct usage for all formats uniformly.Testing
cargo test -p bevy_image, all tests pass.
Edit: Tested this patch in my game, ktx files no longer in system memory after transfer to GPU renderworld.