D3D12.X: format_bytes returns 2 for 16-bit packed formats 133-136 (#1161) #1156
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by mahfuzinam0045-spec on 2026-11-24T12:45:55Z.
gpu::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
Imported from ivall/xcl. Originally posted by juliptree on 2026-11-24T12:51:37Z.
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.
Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-24T12:52:28Z.
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.
Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-24T14:21:33Z.
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
Imported from ivall/xcl. Originally posted by mahfuzinam0045-spec on 2026-11-24T15:26:24Z.
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).Imported from ivall/xcl. Originally posted by kacper-serewis on 2026-11-24T20:41:10Z.
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.
upstream-sync referenced this pull request2026-11-24 23:06:49 +00:00
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T07:46:49Z.
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!
upstream-sync referenced this pull request2026-11-25 12:04:57 +00:00
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:19:19Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:57:48Z.
Triage (#1607) – head
c2bdbf5#1432 (opened later) contains the same format_bytes change for 133-136 inside a broader audit of format mappings (it also changes gfx10_format, depth formats and BC block sizes). This PR is the first and the minimal fix for #1161.
No problems found in the diff: 133-136 (5_6_5, 1_5_5_5, 5_5_5_1, 4_4_4_4) are 16-bit. The
130 | 132 => 4arm is a no-op, since the default arm already returns 4.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.