Repository navigation
Shaders: query untyped buffer dimensions through a raw handle - #129
vicennpacheco wants to merge 1 commit into
Conversation
`victory-gpu` backs structured buffer views with raw views (`raw_window`), and `lower::buffer()` already lowers indexed structured buffer accesses to `ByteAddressBuffer` (`(11 | u, 0)`) handles. However, descriptor-size lowering (`getDimensions`) still annotated `idxen` buffers with `stride >= 4` as `StructuredBuffer` (`(12 | u, stride)`), skipping the `bytes / stride` division below it. Against a raw host view this returns the raw byte count instead of the element count (e.g. 128 instead of 8 for a 16-byte-stride buffer). Use a raw handle (`(11 | u, 0)`) for untyped buffers in `getDimensions` so the existing `UDiv` by `used.stride` produces the element count.
|
Independent test run on commit
AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report. |
|
Thanks for testing this on RDNA4! I double-checked the emitted DXIL against This is also the only non-ignored workspace test that runs
That will tell us whether switching |
|
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 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). |
|
RDNA3 data for this PR: on current Setup: Radeon RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 Pro 22H2 (19045), Rust 1.98.1 MSVC. Base: fxceless
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
Apart 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. |
… through a raw handle) conflitto risolto a mano # Conflicts: # crates/victory-shader/src/emit/lower.rs
Problem
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.)