Repository navigation
Conversation
|
Tested Environment: Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1 Tested
A gap in the regression test. It only uses I added a local variant (below, not pushed). It reuses
So the lowering is right; the test just doesn't pin that part down yet. Adding a narrower load at a non-zero in-row offset (e.g. Local variant (throwaway: patches the load opcode through a static)- 0xE038_2000 | (u32::from(dynamic) << 12) | u32::from(byte_offset),
+ 0xE000_2000 | (LOCAL_OP.load(std::sync::atomic::Ordering::Relaxed) << 18) | (u32::from(dynamic) << 12) | u32::from(byte_offset),static LOCAL_OP: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(14);
#[test]
fn local_probe_partial_rows() {
let input: Vec<u32> = (0u32..192)
.map(|i| (i + 1).wrapping_mul(0x91de_2f71).rotate_left(i % 32))
.collect();
// (op, count): dword 12, dwordx2 13, dwordx4 14, dwordx3 15
for (op, count) in [(12u32, 1usize), (13, 2), (15, 3), (14, 4)] {
for offset in (0u16..=28).step_by(4) {
LOCAL_OP.store(op, std::sync::atomic::Ordering::Relaxed);
let shader = build_indexed_cbv_cs(offset, false);
for (label, warp) in [("hardware", false), ("warp", true)] {
let Ok(host) = Host::new(warp) else { continue };
let (root, pso) = host.compute_pipeline(&shader).expect("pipeline");
let mut ud = vec![0u32; shader.user_data_dwords() as usize];
for u in &shader.user_data {
ud[u.index as usize] = match (u.root, u.slot) {
(RootType::Table, 1) => 32,
_ => 0,
};
}
let actual = host
.dispatch(&root, &pso, &Dispatch {
roots: vec![(0, Root::Constants(ud))],
views: &[View::Cbv(&input), View::RawUav(256)],
samplers: &[],
groups: [2, 1, 1],
})
.expect("dispatch");
let dword = usize::from(offset) / 4;
for (g, group) in actual[0].as_chunks::<128>().0.iter().enumerate() {
for lane in 0..32 {
let got = &group[lane * 4..lane * 4 + count];
let want = &input[lane * 4 + dword..lane * 4 + dword + count];
assert_eq!(got, want, "{label} op {op} offset {offset} group {g} lane {lane}");
}
}
}
}
}
}Not tested: the timing (the harness isn't in the PR); no game data used. AI-assisted (Claude Code) ran the checks and drafted this comment. |
Expand the GPU readback regression to the immediate offsets in two rows, plus dynamic offsets for each width. Credit the regression matrix and mutation suggested by fromthemoonx in PR Marvisak#511. Co-authored-by: fromthemoonx <114431313+fromthemoonx@users.noreply.github.com>
|
@fromthemoonx Thanks for spotting the coverage gap and proposing the expanded matrix. I credited the contribution in The final regression passed 48 cases per adapter on AMD, NVIDIA and WARP with full GPU-based validation. With your mutation changing |
catminou4
left a comment
There was a problem hiding this comment.
Test-merge with current main (ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touched lower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.
Expand the GPU readback regression to the immediate offsets in two rows, plus dynamic offsets for each width. Credit the regression matrix and mutation suggested by fromthemoonx in PR Marvisak#511. Co-authored-by: fromthemoonx <114431313+fromthemoonx@users.noreply.github.com>
0b3c1fd to
ff96ffe
Compare
|
@catminou4 The #566 conflict is resolved in |
|
@catminou4 Update to the re-review request: main advanced after the clean ffe310e check. GitHub now shows a conflict with 70564ae. I resolved the test-file conflict locally, and full GPU-based validation exposed a material change in 683ad7a: table constant buffers now bind as raw SRVs, while #511's historical regression binds CBVs. The 48-case AMD/NVIDIA/WARP results apply to ff96ffe on ffe310e. I'm checking the remaining native-CBV path before asking for review against the new main. AI-assisted using Codex. |
|
The current-main table-constant binding has now been tested separately. On 70564ae it is a raw SRV path. A local same-row vector experiment passed 240 cases each on AMD and WARP with full validation. The old CBV regression remains useful historical evidence. A mechanical port also needs a new alignment proof for indexed built root descriptors: current lowering folds the descriptor stride into the address before the old row proof. I'm coordinating the raw case with #1393 and recommend superseding this PR's table-CBV approach once that direction is agreed. AI-assisted using Codex. |
|
Automated triage for the maintainers. Merge candidate. The new head I re-read the native CBV path of the MUBUF lowering in CI: passing ( Generated by Claude Code |
|
@catminou4 The branch now merges cleanly with main at |
…nce/pr511-ccfb029
# Conflicts: # crates/victory-shader/src/emit/valu_tests.rs
|
Code review and RTX 5090 + WARP + DXIL verification at head
LGTM. |
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on Windows (RTX 5090 + WARP):
- Coalescing into a single
cbufferLoadLegacy.i32when!offen && !scalar_offset && base == 0 && extra.is_none() && row_aligned_index && offset % 4 == 0 && first + count <= 4is sound and cleanly avoids redundant row loads cargo test -p victory-shader --lib indexed_cbv_loads_match_their_byte_addressespassed on RTX 5090 and underVICTORY_WARP=1cargo clippy -p victory-shader --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (191 files ok)
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Change
When the per-lane MUBUF CBV path proves a vector read stays within one 16-byte DXIL row, issue one
cbufferLoadLegacy.i32and extract the required dwords. Unaligned offsets, row crossings, variable byte offsets and unproven built bases keep the existing lowering.Current upstream integration
Head
02dc7b2merges cleanly with upstream42363ab. Coalescing applies to the native root CBV lowering. Main routes table CBVs through raw SRVs, and this PR preserves the table lowering. A built root view falls back to scalar loads when an index can shift the address within a 16-byte row, as with a stride of four bytes.The regression runs 176 synthetic dispatches per adapter across raw tables and native root views, including strides of 4, 16, and 32 bytes. AMD Radeon Graphics, GeForce RTX 5070 Laptop GPU, and WARP passed with the D3D12 debug layer and full GPU-based validation. The explicit-adapter run used Agility SDK 1.620.2 and a local startup sampler-heap workaround outside the PR. The unmodified PR head also passed the normal matrix and strict shader Clippy.
The current DXIL dump shows one native row load for the aligned four-dword case and four for the stride-four or dynamic-offset cases. A two-dword row crossing still uses two loads. Current-head GPU timing and title performance have yet to be measured.
Synthetic reproduction and validation
On Windows with Shader Model 6.6, run
cargo test -p victory-shader indexed_cbv_loads_match_their_byte_addresses -- --nocapture. The synthetic GFX10 fixture compares dword, dwordx2, dwordx3 and dwordx4 loads against the CPU reference at every aligned immediate byte offset from 0 to 28, plus dynamic byte offsets 0, 4, 12 and 16 for each width. The regular test runs on the available default hardware adapter and WARP. An explicit-adapter Agility SDK 1.620.2 run of the expanded matrix at0b3c1fdpassed all 48 cases per adapter on AMD Radeon Graphics, NVIDIA RTX 5070 Laptop GPU and WARP with the debug layer and full GPU-based validation. A mutation using the row’s first dword instead of the requested in-row dword failed at byte offset 4, group 0, lane 0. fromthemoonx identified the gap, provided the mutation, and independently validated the preceding lowering on desktop RTX 3060 and WARP. Independent review · Expanded regressionA separate earlier explicit-adapter harness compared baseline and candidate on six offset cases. The aligned module’s input-row loads fell from four to one and channel selects from 12 to zero. Dynamic and row-crossing modules were byte-identical.
Earlier synthetic GPU timing
One dispatch of 4,096 groups × 32 threads wrote a 2 MiB UAV. Both PSOs were created outside the timing brackets. Four warm-up pairs were discarded and 32 measured pairs alternated variants with debug and GPU-based validation off.
NVIDIA improved in all 32 pairs. AMD variation was larger than the median difference. The figures apply to this workload. Title shader frequency and frame impact remain unmeasured.
This PR contains only the shader lowering and its regression. AI-assisted with OpenAI Codex.
Current main validation
Rebased onto
ffe310eafter #566. The per-lane constant-buffer lowering and the expanded 48-case matrix are intact. Seven focused tests passed, including the expanded CBV matrix, the upstream FP16 class case, and all five waterfall tests. A test-only adapter-selection run verified all CBV cases on AMD Radeon Graphics, RTX 5070 Laptop GPU, and WARP with Agility 1.620 and full GPU-based validation.