shader: support computed buffer byte and halfword loads #29
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/29"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by shabouwcaw on 2026-11-26T10:11:50Z.
Rebased onto current main after #27 merged; both adjacent documentation bullets are preserved. The original implementation's Windows CI passed, including
computed_buffer_subword_loads_preserve_values_and_bounds. The subsequent adversarial-review correction to mode-0 bounds and explicit acceptance cases is included here; Windows CI is green on the rebased head (cff296e, run 45800535053). This correction postdates the original approval and is called out for review.The tests validate translated execution against a reference model, not AMD hardware. Console alignment remains the documented guessed-path assumption below.
Computed pixel-buffer descriptors currently reject
buffer_load_ubyte,buffer_load_sbyte,buffer_load_ushort, andbuffer_load_sshort. Lower these through title memory with zero/sign extension and element-width bounds checks.Each byte gets its own page-table lookup, so a halfword can span dwords, separately backed 64 KiB pages, or the low 32-bit address boundary. This favors correctness over lookup count; halfwords currently perform two lookups. Typed accesses, stores, atomics, swizzling, ADD_TID, LDS and TFE remain unsupported on this path. The shared OOB_SELECT=2 case now also returns zero when the descriptor record count is zero, as specified in AMD's RDNA2 ISA table 35; mode 0 now checks the starting offset (rather than the end), following table 35. Explicit per-case acceptance masks replace the test's duplicated bounds expressions, so the old mode-0 comparison fails the revised halfword-at-stride-minus-one case. Modes 1 and 3 retain the existing interpretation; scalar offsets are excluded from bounds checks following LLVM's buffer-intrinsic contract.
Related to #4, not a claim to close it or fix any of the seven reported title shaders. This PR is independent of #27 and uses only hand-assembled synthetic shaders.
Validation:
cargo test -j6 --locked -p victory-shader -p xtask: 224 passed after rebasing; 2 ignored benchmarks.cargo clippy -j6 --workspace --all-targets --all-features --locked --target x86_64-pc-windows-gnullvm -- -D warnings: passed, including compilation of the new Windows execution test.cargo xtask policyandgit diff --check: passed.cargo test -j6 --locked -p victory-shader -p victory-hle -p victory -p victory-gpu -p xtask: 500 passed, 0 failed, 4 ignored on native Apple Silicon. LLVM/LLD/MinGW-w64 and Apple-signed Metal Shader Converter 3.0 are now available; the converter is supplied throughVICTORY_MSC_DYLIBfrom outside the repository. The previous dependency blockers are resolved.The new Windows GPU/WARP test checks exact signed/unsigned results, bounds, indexing, scalar offsets, empty descriptors, page transitions, 32-bit address carry and unmapped bytes. It uses graphics descriptor classification with a synthetic compute entry point solely to read back integer results. This test, including the revised bounds cases, passed in Windows CI run 45800535053.
Documented assumption: the guessed path does not decode
SH_MEM_CONFIG.alignment_mode. These subword loads assume UNALIGNED mode; DWORD/strict modes are not emulated. Reference: AMD RDNA2 ISA, sections 8.1.5 and 8.1.7 and the MUBUF opcode table.Adversarial review follow-up: reran the 224 shader/policy tests after rebasing and Windows all-feature Clippy after the mode-0 correction. Remaining verification work is the console alignment setting and AMD-vs-translator behavior. The unsigned-byte path has no halfword alignment ambiguity. LLVM's buffer intrinsic documentation explicitly excludes SOFFSET from bounds checking; the AMD guide's mode-3 prose is less clear, so this still merits hardware confirmation.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T10:17:34Z.
Review: DISMISSED
Reviewed and tested on top of current main together with #30: victory-shader/gpu/hle/victory/xtask tests, clippy (Windows target) and policy pass. Per-byte lookups are the right call for correctness here, and dropping the
subguard is safe sincesubonly covers these four loads and stores stay refused. The OOB_SELECT=2 empty-descriptor change matches the ISA table. Thanks!Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T10:17:47Z.
Approved. Merging #27 left a small conflict here in
docs/native-host.md(your Computed pixel buffers bullet sits next to #27's Pixel primitive mask bullet). Could you rebase onto main? I'll merge once CI is green.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T10:35:18Z.
Review: APPROVED
Re-reviewed after the rebase and
cff296e: the mode-0 start-offset check follows the ISA table you cite and only changes components that straddle the stride end. All tests (shader 219, gpu 144, hle 122), clippy and policy pass merged with current main. Merging, thanks!