Skip to content

Comments

Ktx2, Basis, and DDS files ignoring RenderAssetUsages from .meta files#22992

Merged
alice-i-cecile merged 2 commits intobevyengine:mainfrom
mholiv:main
Feb 17, 2026
Merged

Ktx2, Basis, and DDS files ignoring RenderAssetUsages from .meta files#22992
alice-i-cecile merged 2 commits intobevyengine:mainfrom
mholiv:main

Conversation

@mholiv
Copy link
Contributor

@mholiv mholiv commented Feb 17, 2026

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 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.

Edit: Tested this patch in my game, ktx files no longer in system memory after transfer to GPU renderworld.

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.
@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@rparrett rparrett added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 17, 2026
@mholiv
Copy link
Contributor Author

mholiv commented Feb 17, 2026

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.

@rparrett rparrett added this to the 0.18.1 milestone Feb 17, 2026
@kfc35 kfc35 added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Feb 17, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in Rendering Feb 17, 2026
@kfc35
Copy link
Contributor

kfc35 commented Feb 17, 2026

@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 😅

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 17, 2026
Merged via the queue into bevyengine:main with commit 5646b99 Feb 17, 2026
52 checks passed
@github-project-automation github-project-automation bot moved this from Needs SME Triage to Done in Rendering Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Ktx2, Basis, and Dds files ignore RenderAssetUsages policy derived from .meta flies

5 participants