desc: format_bytes returns 4 for 16-bit packed formats 133, 134 and 136 #1161

Open
opened 2026-11-26 04:45:35 +00:00 by github-bot · 2 comments
Owner

@⁠mahfuzinam0045-spec on GitHub · 2026-11-24 12:43 UTC · original

\gpu::desc::format_bytes\ maps format numbers to element byte sizes (\crates/xcl/src/gpu/desc.rs:662). It currently only checks \1..=6 => 1, \7..=19 => 2, \20..=61 => 4, \62..=71 => 8, \72..=74 => 12, \75..=77 => 16, falling back to _ => 4.

Packed 16-bit GFX10 formats \133\ (B5G6R5), \134\ (B5G5R5A1, #946), and \136\ (B4G4R4A4) have 2 bytes per element (as correctly defined in \gpu::tiling::element: \7..=19 | 133..=136 => (1, 1)). Because they are missing in \ ormat_bytes, calling \ ormat_bytes\ on these formats returns 4 instead of 2.

Consequently, typed buffer views (
eal::buffer_words_at) deriving their element stride from \ ormat_bytes\ receive a stride of 4 instead of 2 for B5G6R5, B5G5R5A1, and B4G4R4A4 views.
eal::texture_memory\ also calculated 32 bits instead of 16 bits per texel.

**@⁠mahfuzinam0045-spec** on GitHub · 2026-11-24 12:43 UTC · [original](https://github.com/xcl-dev/xcl/issues/1161) \gpu::desc::format_bytes\ maps format numbers to element byte sizes (\crates/xcl/src/gpu/desc.rs:662\). It currently only checks \1..=6 => 1\, \7..=19 => 2\, \20..=61 => 4\, \62..=71 => 8\, \72..=74 => 12\, \75..=77 => 16\, falling back to \_ => 4\. Packed 16-bit GFX10 formats \133\ (B5G6R5), \134\ (B5G5R5A1, #946), and \136\ (B4G4R4A4) have 2 bytes per element (as correctly defined in \gpu::tiling::element\: \7..=19 | 133..=136 => (1, 1)\). Because they are missing in \ ormat_bytes\, calling \ ormat_bytes\ on these formats returns 4 instead of 2. Consequently, typed buffer views (\ eal::buffer_words_at\) deriving their element stride from \ ormat_bytes\ receive a stride of 4 instead of 2 for B5G6R5, B5G5R5A1, and B4G4R4A4 views. \ eal::texture_memory\ also calculated 32 bits instead of 16 bits per texel.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:45:35 +00:00
Author
Owner

@⁠requiemsnkrp on GitHub · 2026-11-24 12:44 UTC · original

I'm taking this one: format_bytes gets the 16-bit packed formats (133–136, as in tiling::element) with a unit test that fails on main, and the smoke blocks in the PR. PR later today.

AI use: Claude Code (Claude Opus 5.5) read the code and wrote this comment.

**@⁠requiemsnkrp** on GitHub · 2026-11-24 12:44 UTC · [original](https://github.com/xcl-dev/xcl/issues/1161#issuecomment-7131849542) I'm taking this one: `format_bytes` gets the 16-bit packed formats (133–136, as in `tiling::element`) with a unit test that fails on `main`, and the smoke blocks in the PR. PR later today. AI use: Claude Code (Claude Opus 5.5) read the code and wrote this comment.
Author
Owner

@⁠requiemsnkrp on GitHub · 2026-11-24 17:41 UTC · original

#1165 (opened a minute before my claim above) already fixes this, with tests and regression runs, so I'm not opening mine.

One thing from my branch that #1165 could take: a test that ties format_bytes to tiling::element for every format instead of listing three. For each format 0..=255 with element(f) == Some((log2, 1)), it checks format_bytes(f) == 1 << log2. It fails on main at 133, and it would catch the next format added to one table and not the other. Measured here on top of #1165's change: not run (I ran it with my own equivalent fix: passes; 742 passed, 0 failed on the full suite).

AI use: Claude Code (Claude Opus 5.5) wrote this.

**@⁠requiemsnkrp** on GitHub · 2026-11-24 17:41 UTC · [original](https://github.com/xcl-dev/xcl/issues/1161#issuecomment-7139566767) #1165 (opened a minute before my claim above) already fixes this, with tests and regression runs, so I'm not opening mine. One thing from my branch that #1165 could take: a test that ties `format_bytes` to `tiling::element` for every format instead of listing three. For each format `0..=255` with `element(f) == Some((log2, 1))`, it checks `format_bytes(f) == 1 << log2`. It fails on `main` at 133, and it would catch the next format added to one table and not the other. Measured here on top of #1165's change: not run (I ran it with my own equivalent fix: passes; 742 passed, 0 failed on the full suite). AI use: Claude Code (Claude Opus 5.5) wrote this.
This discussion has been locked. Commenting is limited to contributors.
No description provided.