D3D12.X: format_bytes returns 2 for 16-bit packed formats 133-136 (#1161) #1165
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1165
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1165"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@mahfuzinam0045-spec on GitHub · 2026-11-24 12:45 UTC · original
mahfuzinam0045-spec:fix/desc-format-bytes-packed-16bit→main· +13 −3 · 1 files · 1 commits · opengpu::desc::format_bytesmaps format numbers to element byte sizes (crates/xcl/src/gpu/desc.rs:662). It previously only covered format ranges 0–77 and fell back to 4 for unrecognized formats. Packed 16-bit GFX10 formats133(B5G6R5),134(B5G5R5A1, #946), and136(B4G4R4A4) have 2 bytes per element (as defined ingpu::tiling::element:7..=19 | 133..=136 => (1, 1)).Because
format_bytesreturned 4 for these formats, typed buffer views created with them received an element stride of 4 instead of 2 inbuffer_words_at, andtexture_memorycalculated 32 bits instead of 16 bits per texel.format_bytesnow maps133..=136to 2 and130 | 132to 4.Fixes #1161.
What is in it
crates/xcl/src/gpu/desc.rs: informat_bytes, map packed 16-bit formats133..=136to 2 and 32-bit formats130 | 132to 4.crates/xcl/src/gpu/desc.rs: add unit testformat_bytes_covers_packed_16bit_and_32bit_formatschecking element byte counts across standard, packed 16-bit, and 32-bit formats.Tested
format_bytes_covers_packed_16bit_and_32bit_formatsassertingformat_bytesreturns 2 forB5G6R5_UNORM,B5G5R5A1_UNORM, andB4G4R4A4_UNORM(fails returning 4 on main without this change, passes with 2 with this change).cargo testpasses (751 passed, 0 failed, 45 ignored).Regression run
XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s (courtesy of @Anon64).main
47efa2e:this PR:
Not tested
AI use
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@juliptree on GitHub · 2026-11-24 12:51 UTC · original
Independently reproduced #1161 on main@47efa2ecea0a12934719ae69b81930cf02a4b1c3. With only a regression test added, format_bytes returned [4, 4, 4] for formats 133, 134, and 136. The same test returned [2, 2, 2] after a local fix.
On an RTX 5060 Ti verified by adapter LUID, D3D12 GetCopyableFootprints reported 128 unpadded bytes per 64-texel row for B5G6R5, B5G5R5A1, and B4G4R4A4, confirming 2 bytes per texel for all three mappings.
This run used my local patch and synthetic fixtures. PR head, format 135, typed-buffer loads, and retail smoke remain outside this validation. Codex (GPT-6) assisted with testing and reporting.
@Anon64 on GitHub · 2026-11-24 12:52 UTC · original
Regression run for this PR: head
c2bdbf5, based onmain47efa2e. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s.Tested
cargo test -p xcl --release --lib -- format_bytesonc2bdbf5: 1 passed, 0 failed.main
47efa2e:this PR:
No device removals or crashes; 94 % of main's frames, 105 % of its peak commit.
Not tested: the whole suite; whether the title reaches the changed path in these 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@JoaoPauluu on GitHub · 2026-11-24 14:21 UTC · original
A regression run under Wine on Linux, on a retail title.
Tested
x86_64-pc-windows-gnu.c2bdbf5as it is (merge base47efa2e) andmain47efa2e, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Twelve runs in a row,mainfirst and last, other PRs in between.Regression run
main (first run):
this PR:
The last
mainrun: 1425 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
@mahfuzinam0045-spec on GitHub · 2026-11-24 15:26 UTC · original
Additional testing: Windows / NVIDIA RTX 4060
I ran the full test suite locally on Windows after building the workspace.
Test environment
real)cargo build --workspacecargo testBuild result
cargo build --workspacecompleted successfully.Test results
Unit tests
Integration tests
Notable integration results:
GPU testing
The real D3D12 backend initialized successfully on the NVIDIA RTX 4060.
GPU-related unit tests passed, including:
gpu_typed_buffer_loads_and_storesgpu_images_sample_load_store_atomicgpu_images_a16_d16gpu_tsharp_to_d3d12_resourcesgpu_format_stores_atomics_global_ldsgpu_console_format_allocation_info_is_sanegpu_console_depth_formats_are_supportedThe GPU compute and PSO integration suites also completed without failures.
Previously failing E2E test
The previously failing test:
test_title_runs_and_game_folder_is_untouchednow passes after running
cargo build --workspacefirst. All three tests intests/e2e.rspassed.Conclusion
The complete
cargo testrun finished successfully:This provides positive regression-testing evidence on a real NVIDIA D3D12 backend, including GPU resource, compute, and PSO paths.
Scope note: These results validate the broader GPU and resource functionality. They do not independently verify the exact
format_bytesreturn value for each affected format (133–136).@kacper-serewis on GitHub · 2026-11-24 20:41 UTC · original
Halving the element size also halves the address space
texture_memoryreserves for a committed texture. For 2048x130 in B5G6R5, B5G5R5A1 and B4G4R4A4 it becomes smaller than the 64KB_S layout (c2bdbf5).Tested: Windows 11, debug, CPU only.
47efa2ec2bdbf5xg::Texture)So the estimate is already short for 16-bit texels on the base; the old four-byte size hid it for these three formats. Suggested: in
texture_memory, reserve at least the largest console layout of the texture that fits.Not tested: writing through the reservation; the test repeats the formula of
texture_memorywith the PR'sformat_bytes. The suggestion was not applied to this PR's head.Test (append to real.rs)
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. I checked the reservation claim in an earlier version of this comment; the R16_UNORM comparison was added after that, and no person has checked it.
@DavidM1911 on GitHub · 2026-11-25 07:46 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.