Repository navigation
Shaders: extend image_gather4_l(_o) to all address modes, borders, a16, d16, unorm, and 2D arrays - #1853
Shaders: extend image_gather4_l(_o) to all address modes, borders, a16, d16, unorm, and 2D arrays#1853ESAT586 wants to merge 2 commits into
Conversation
…6, d16, unorm, and 2D arrays Extend gather_at_level (image_gather4_l and image_gather4_l_o) beyond 2D transparent-black-border f32 gathers: - Support all six RDNA2 point/gather address modes per axis (including mixed X/Y modes): WRAP (0), MIRROR (1), CLAMP_LAST_TEXEL (2), MIRROR_ONCE_LAST_TEXEL (3), CLAMP_BORDER (6), and MIRROR_ONCE_BORDER (7), using exact IEEE-754 period reduction (u - trunc(u) and u - 2 * trunc(u * 0.5)) for periodic modes and [-64, 64] clamping for clamp/border modes before the 64-bit fixed-point texel index calculation. - Support all three built-in border colours (TRANSPARENT_BLACK, OPAQUE_BLACK returning 1.0 on alpha and 0.0 on RGB, and OPAQUE_WHITE returning 1.0 on every channel), ignoring �order_color_type when neither axis uses a border mode. - Support whole sampler lod_bias, �16 (with f16 whole-LOD provenance tracking in whole_f16 for both low and high halves), d16 packed outputs, unnormalized (unorm / FORCE_UNNORMALIZED) coordinates on clamp/border modes, and Texture2DArray (dim = 5, ties-to-even slice rounding clamped to [0, array_size - 1]). - Add View::MippedArray to the test harness and end-to-end GPU + WARP + DXIL-validated tests verifying all 11 sampler configurations against both the CPU reference and native hardware image_gather4_lz at level 0, plus �16, d16, unorm, Texture2DArray, and negative tests for still-refused sampler options. AI disclosure: implemented and verified with Gemini 4 Neon (Extra High Mode) using only synthetic test cases and public RDNA2 ISA documentation; zero game binaries or copyrighted assets were accessed.
|
NVIDIA run: RTX 3070 8 GB, driver 616.56, plus WARP, Windows 11, debug, On the cases left refused ("a gather at a level that may not be whole", fractional LOD limits and bias): the level rule for a fractional LOD has now been measured on RDNA2 (gfx1036) in boykopovar/AnyPS5#23856 and #23666. LOD bias is added first, then the S# AI-assisted (Claude Code). Synthetic tests only. |
catminou4
left a comment
There was a problem hiding this comment.
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae), cargo test -p victory-shader --locked → 118 passed, 0 failed. GPU execution tests are #[cfg(all(test, windows))] and run only on Windows.
image_gather4_l(_o) extended to all address modes/borders: gather lowering coverage widened.
|
Two independent follow-ups on Null texture and an opaque border. I dispatched the PR's existing address-mode shader twice, keeping the sampler, input coordinates and output layout identical. The second dispatch bound a typed RGBA32F null Texture2D SRV. With opaque white/red or opaque black/alpha, both explicit-level gathers returned four Null-texture fix and regression. The emulation checks the mip-zero width before calculating a footprint or applying a border color. All 11 sampler configurations now return zero for the null view on both backends, with the original live-texture checks still passing. Whole-LOD check for packed A16 array coordinates. For Both commits apply together. Five gather tests passed with both applied, and shader all-targets Clippy passed. The sixth gather test, |
…f in gather_at_level Addresses two review findings on Marvisak#1853: - Null Texture2D/Texture2DArray SRVs (mip-0 width == 0) now return 0.0 for all four channels even with opaque border colors (`OpaqueWhite`, `OpaqueBlack` alpha), matching native D3D12 `textureGather`, and avoid `URem` by zero on wrap/mirror. - `whole_f16` on `v_lshl_or_b32 dst, src0, 16, src2` now requires `src2[31:16]` to be provably zero (or evaluates constant pairs directly) so a non-zero upper half in `src2` cannot turn a whole high-half f16 LOD into a fractional value; 16-bit float ops (`v_pack_b32_f16`, `v_min_f16`, `v_max_f16`) also decode inline float constants `240..=248` as f16 bits. - Adds `View::NullTexture` (`#[cfg(test)]`) and regression tests covering all 11 sampler configs against a null SRV on hardware + WARP plus the 4 `v_lshl_or_b32` packed-LOD validation cases. Clean-room synthetic tests only; zero game data used. AI-assisted with Gemini 4 Neon (Extra High Mode).
|
Thanks @AlanQiang0418 and @upipibi for the thorough hardware runs and exact catches! Both bugs reported by @AlanQiang0418 are now fixed in the latest commit on this branch:
Regarding @upipibi's note on fractional LOD rounding ( Re-verified on Windows 11 with NVIDIA GeForce RTX 3060 Ti + Microsoft D3D12 WARP +
(Clean-room synthetic tests only, zero game data. AI-assisted with Gemini 4 Neon (Extra High Mode).) |
|
Re-checked AI-assisted (Claude Code). |
|
Retested your integrated I found one remaining way for a fractional LOD to pass the updated proof. Take the existing loaded slice word Follow-up commit on your new head caches the proof result and scopes loop assumptions to the incoming edges of each phi. The regression rejects the unmasked copy, accepts a copy masked to 16 bits, and checks both outcomes with a two-iteration loop. With the follow-up and #1887's view change applied, all seven gather tests, the indexed-buffer read test and shader all-targets Clippy passed. |
|
I checked the gather coordinate product on your current head, 59b8454. It sets Int64ShaderOps even though the final coordinate fits in 32 bits for every D3D12 texture dimension. DirectX feature requirements 16a4e77 is one commit directly on that head. It splits the signed product at bit 16 and preserves the exact footprint rounding. I ran the same test before and after on WARP, including a 16,381-texel-wide 2D array plus the A16, D16 and unnormalized cases. The texel readbacks matched on both builds. The SFI0 assertion failed with 0x8000 before and passed with zero after. Full forced-WARP suite: 211 passed / 3 failed / 2 ignored before, 212 / 2 / 2 after. The legacy native gather comparison and lane permute produced the same failures in both runs. Strict shader Clippy and asset policy passed. |
|
I compared the 32-bit coordinate patch with its parent One detail for reproducing boundary comparisons: at width 16,384, normalized |
|
Automated triage for the maintainers. This widens
The host-comparison tests are useful. Please include the results of a run on hardware and WARP. CI: not run on this head. Generated by Claude Code |
|
I tested the two suggested follow-ups together on Windows. The 32-bit footprint change and the packed LOD proof fix merged cleanly on 59b8454. With the test-host delta from #1887 (ccfb029..62bd980), all 7 tests passed with cargo test --locked -p victory-shader --lib synthetic_tests::gathers_at_a_level, including the 16,381-wide array and packed-LOD loop cases. As a control, keeping the combined tests and restoring only lower.rs from the 32-bit patch made the repeated-operand regression fail: translation accepted the unknown upper half. The two fixes can be evaluated together; the coordinate change alone still needs the LOD fix for that case. These synthetic results leave the requested evidence about which modes the title uses open. AI-assisted validation. |
Offline measurement on a retail dumpResult: no count change against I merged head 59b8454 onto No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code). |
Summary
Extends image_gather4_l and image_gather4_l_o emulation (Lower::gather_at_level) on top of 70564ae beyond 2D transparent-black-border 32 gathers: