UASTC KTX2 with a single (R) channel fails to load: "Failed to transcode mip level 0 from UASTC to BC4: TranscodeFailed"
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
Direzione di ricerca
Start in crates/bevy_image/src/ktx2.rs at the TranscodeFormat::Uastc branch and trace how source mip and layer slices are sized for each target format. The report shows BC4 fails because its 8-byte blocks are used to size 16-byte UASTC source blocks; compare the BC target fix with the separate uncompressed fallback, which has its own reported failure. Done means single-channel UASTC KTX2 loads on the affected compressed targets without regressing RGBA UASTC.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bevy version
0.20.0 (bevy_image 0.20.0). The code in question is unchanged on main as of 2026-10-24; 0.19.1 has it too.
What you did
Loaded a single-channel UASTC KTX2 (a height map) on a GPU with BC support:
ktx create --format R8_UNORM --encode uastc --generate-mipmap --assign-tf linear h.png h.ktx2 # KTX-Software 4.4.2
Image::from_buffer(&bytes, ImageType::Extension("ktx2"), CompressedImageFormats::BC,
false, ImageSampler::Default, RenderAssetUsages::default())
What went wrong
failed to decompress an image: Failed to transcode mip level 0 from UASTC to BC4: TranscodeFailed
An RGBA UASTC file built the same way loads fine as Bc7RgbaUnorm.
Cause
In crates/bevy_image/src/ktx2.rs, the TranscodeFormat::Uastc branch works out how many bytes of source data each level and layer takes using the target format's block size:
let block_bytes = texture_format_info.block_copy_size(None).unwrap(); // target format: BC4 = 8
let level_bytes = (num_blocks_x * num_blocks_y * block_bytes) as usize;
transcoder.transcode_slice(&level_data[offset..(offset + level_bytes)], ...)
UASTC blocks are always 4×4 and 16 bytes. BC4 and EacR11Unorm blocks are 8 bytes, so the transcoder gets only half of each level. basisu_lowlevel_uastc_transcoder::transcode_slice checks image_data_size < total_expected_block_bytes and returns false. BC7, BC5 and ASTC 4×4 targets work only because their blocks happen to be 16 bytes too. This affects every UASTC texture with TextureChannelLayout::Rrr on BC- or ETC2-capable hardware.
Fix (tested for BC targets)
Size the source slice in UASTC blocks:
// The source is UASTC whatever the target: 4x4 blocks of 16 bytes.
let (block_width_pixels, block_height_pixels) = (4, 4);
let block_bytes = 16;
I patched a local copy of bevy_image 0.20.0 with this and loaded the following with CompressedImageFormats::BC:
| file | stock 0.20.0 | patched |
|---|---|---|
| R8 UASTC 64×64, 7 mips | TranscodeFailed (BC4) |
Bc4RUnorm, 7 mips |
| R8 UASTC 60×36, 6 mips | TranscodeFailed (BC4) |
Bc4RUnorm, 6 mips |
| RGBA8 UASTC 64×64, 7 mips | Bc7RgbaUnorm |
Bc7RgbaUnorm |
Related: the uncompressed fallback
With CompressedImageFormats::NONE the same branch is also wrong, and the fix above does not repair it:
- stock: R8 UASTC gives
TranscodeFailed(RGBA32), and RGBA8 UASTC panics on the out-of-range slice; - patched: the process aborts with
malloc(): corrupted top sizeinsidetranscode_slice(basis-universal 0.3.1).
So that path needs its own look: its output is RGBA32, while get_transcoded_formats labels it R8Unorm / Rg8Unorm. I haven't dug further. A fix for the compressed targets alone shouldn't change it, since it can't load either way today.
- Lingua principale
- Rust
- Stelle
- 49.7k
- Fork
- 5k
- Merge medio
- 3g 19h
- PR unite (30g)
- 134
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bevyengine/bevy
-
C-Bug S-Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
bevyengine/bevy#26536 ·
I maintainer di solito rispondono entro 2 giorni
-
Placeholder has no defaultForse già presa Una pull request collegata a questa issue è aperta o già unita. ApertaC-Feature S-Needs-Triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
bevyengine/bevy#26532 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
C-Feature S-Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
bevyengine/bevy#26500 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
C-Feature S-Needs-Triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
bevyengine/bevy#26499 ·
I maintainer di solito rispondono entro 2 giorni
-
`compute_histogram` in auto exposure writes past the end of the 64-bin histogramForse già presa @dev-matru l’ha presa 3 giorni fa. ApertaA-Rendering C-Bug D-Straightforward S-Ready-For-Implementation X-Uncontroversial
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
bevyengine/bevy#26479 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di bevyengine/bevy
Issue simili
-
bug UI
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
wardian-app/Wardian#1746 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
jlcodes99/cockpit-tools#3125 ·
I maintainer di solito rispondono entro 2 giorni
-
bug user-sprint
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Vondor/KassenSturz#967 ·
I maintainer di solito rispondono entro 1 giorno
-
area/ci
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Incremental sync warns "no stored highest_uid" on every round for folders with no new mailApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
rustmailer/bichon#411 ·