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

Open
opened 2026-11-24 12:43:02 +00:00 by mahfuzinam0045-spec · 2 comments
mahfuzinam0045-spec commented 2026-11-24 12:43:02 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by mahfuzinam0045-spec on 2026-11-24T12:43:02Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:6582042320 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1161). Originally posted by [mahfuzinam0045-spec](https://github.com/mahfuzinam0045-spec) on 2026-11-24T12:43:02Z. --- \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.
requiemsnkrp commented 2026-11-24 13:03:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by requiemsnkrp on 2026-11-24T12:44:14Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7131849542 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/1161#issuecomment-7131849542). Originally posted by [requiemsnkrp](https://github.com/requiemsnkrp) on 2026-11-24T12:44:14Z. --- 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 commented 2026-11-24 18:09:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by requiemsnkrp on 2026-11-24T17:41:36Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7139566767 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1161#issuecomment-7139566767). Originally posted by [requiemsnkrp](https://github.com/requiemsnkrp) on 2026-11-24T17:41:36Z. --- #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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#1152
No description provided.