Shaders: query untyped buffer dimensions through a raw handle #129
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!129
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-129"
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?
@vicennpacheco on GitHub · 2026-11-24 21:43 UTC · original
vicennpacheco:fix/raw-buffer-get-dimensions→main· +147 −4 · 2 files · 1 commits · openProblem
victory-gpu(raw_window) converts structured buffer views into raw host views (DXGI_FORMAT_R32_TYPELESS,D3D12_BUFFER_SRV_FLAG_RAW), andlower::buffer()(crates/victory-shader/src/emit/lower.rs) lowersidxenstructured buffer accesses to raw (ByteAddressBuffer,(11 | u, 0)) handles.However, when a shader reads a buffer descriptor's record count (dword 2 ->
dx.op.getDimensions),lower.rsstill annotatedFields::Bufferwith*idxen && format.is_none() && stride >= 4asStructuredBuffer((12 | u, stride)). Becauseprops.0 & 0xFFwas12instead of11, it skipped then / stridedivision right below (lower.rs:5687), returning the raw byte count instead of the element count against a raw host view (reproduced on hardware: a 128-byte buffer withstride = 16returned128instead of8).Fix
Annotate untyped
Fields::Bufferdimension queries as raw ((11 | u, 0)), matchingbuffer()andvictory-gpu'sraw_window, so the existingn / stridedivision returns the element count.Verification
Tested on Windows 11, AMD Radeon Vega 8 iGPU (Ryzen 7 5825U, GCN 5 /
gfx90c, AMD driver31.0.21921.13001), Windows SDKdxil.dll10.0.26100.0, Rust1.98.1(x86_64-pc-windows-msvc), without game files:emit::tests::structured_buffer_record_count_matches_raw_host_view(failed before the fix with128 != 8; passes after on both Vega 8 hardware and WARP,dxil.dll-validated)VICTORY_D3D12_DEBUG=1: clean, no debug-layer errorscargo clippy -p victory-shader --tests -- -D warnings: clean(AI-assisted investigation and patch.)
@adriaespii on GitHub · 2026-11-24 21:51 UTC · original
Independent test run on commit
79b5a82(AMD RDNA4) — deterministic crash in the new test:x86_64-pc-windows-msvc)cargo clippy --workspace --all-targets -- -D warnings: 0 warningscargo test -p victory-shader --lib structured_buffer_record_count_matches_raw_host_view -- --nocapture: crashes deterministically with0xc0000005(STATUS_ACCESS_VIOLATION) both in parallel and when run alone (--test-threads=1).AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.
@vicennpacheco on GitHub · 2026-11-24 22:28 UTC · original
Thanks for testing this on RDNA4!
I double-checked the emitted DXIL against
dxc.exe -T cs_6_6forResourceDescriptorHeap[...].GetDimensions()— the IR (createHandleFromHeap->annotateHandle {11, 0}->getDimensions(72, h, undef)) and metadata match DXC, and the test passesdxil.dll10.0.26100.0,VICTORY_D3D12_DEBUG=1, Vega 8 hardware, and WARP cleanly.This is also the only non-ignored workspace test that runs
dx.op.getDimensionson a heap-indexedByteAddressBufferthroughCreateComputePipelineState, so this may be anamdxc64.dllRDNA4 compiler crash (similar to #3). If you have a moment, could you check whether:0xc0000005happens insideCreateComputePipelineStateon"hardware"(and whether"warp"passes on its own), andlower.rschange (leaving(12, 16)) avoids the crash on32.0.32015.7029or crashes there too?That will tell us whether switching
(12, stride)->(11, 0)ingetDimensionsitself triggers an RDNA4 driver bug.@sawetco on GitHub · 2026-11-25 00:31 UTC · original
On an RTX 5070 the parent lowering returned 32 records for the 128-byte, stride-16 buffer. WARP returned the expected 8 even before the fix. The PR returned 8 on both. All four lanes agreed on each device, and both revisions produced the same indexed data values (1000, 1004, 1008, 1012).
I first ran the unmodified regression test on
79b5a82. For the A/B I kept that test fixture, required both devices to initialize, and printed the count for each lane, once withlower.rsfrom its parent4e17478and once with the PR version. Pipeline creation and dispatch completed on both devices in both runs. Windows 11 Pro build 26300, NVIDIA 621.24, rustc 1.100.0 MSVC,--profile diag --test-threads=1.A WARP-only run would miss the original wrong count on this machine. The RDNA4 pipeline-creation question still needs a run on that adapter.
AI-assisted testing and write-up (Codex).
@HAL9000RELOADED on GitHub · 2026-11-25 19:28 UTC · original
RDNA3 data for this PR: on current
mainthe new test fails on the card, and with the PR it passes.Setup: Radeon RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 Pro 22H2 (19045), Rust 1.98.1 MSVC. Base: fxceless
maind510ee4+ #402 (fb5da17, Agility 1.620.2 beside the test binary, which Windows 10 needs for SM 6.6). WARP has no SM 6.6 on this machine, so it skips: these are hardware results only.mod.rshunk only, 2 runs):hardware lane 0 record count: 128, want 8. So this card returns the byte count, where the RTX 5070 above gave 32 and WARP 8.79b5a82, the head where the RX 9070 above crashed): passes, no crash, and the rest ofvictory-shader --libis unchanged (216 passed, 0 failed, 3 ignored).The same run covered other shader PRs whose tests had only been run on NVIDIA or WARP. Each was merged on the same base; "tests only" means the PR's
*_tests.rschanges applied on the base without the rest:79b5a823600b7a8bc48bf745305cd3c96c36c835cd67f7ff06ccc209fd48164ca5339cscalar_bit_searches_match_the_consolefails (the other is inline)eaeb8f123b63af,6273077,ad4022fd140e4ef8e0450114cc3528b317av_permlane16_and_x16_read_the_lanes_their_selectors_pickfailsb220768v_dot4_i32_i8unsupportedApart from #340 and #808, no other test changed against the base (215 passed, 0 failed, 3 ignored). Details for those two are on their PRs.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.