Skip to content

Shaders: lower signed nibble offsets through Ibfe - #3725

Open
Ingenioeren wants to merge 1 commit into
Marvisak:mainfrom
Ingenioeren:perf/nibble-offset-extract
Open

Ingenioeren wants to merge 1 commit into
Marvisak:mainfrom
Ingenioeren:perf/nibble-offset-extract

Conversation

@Ingenioeren

Copy link
Copy Markdown
Contributor

v_cvt_off_f32_i4 currently sign-extends its low nibble with two shifts. Use DXIL Ibfe(4, 0, src) instead, keeping the conversion to f32, division by 16, output modifiers and EXEC handling. The conversion expression falls from four instructions to three; both dynamic-input synthetic VOP1/VOP3 shaders fall from 19 written DXIL instructions to 18 (5.3%). This measures emitted code, with no GPU-time or frame-rate claim.

Ibfe sign-extends the selected field, so all upper input bits remain ignored and the sixteen signed fractions remain exact. This optimizes the implementation introduced by #1391. Searches across all 1,804 open PR titles/bodies and targeted open/closed searches found no competing offset-conversion optimization; the signed-nibble dot-product and BCPack-test PRs concern different operations.

The execution regression checks 10,112 inputs across 36 forms: both encodings, every output-scale/clamp combination, separate and overlapping destinations, and full/partial EXEC. A wide-integer arithmetic reference supplies exact f32 bit patterns and checks inactive destination preservation. All 364,032 cases per adapter matched on RX 6750 XT and WARP before and after, with zero adapter differences; the emitted shaders validate with dxil.dll.

Validation on fresh origin/main 63bcca4, Windows x64, Rust 1.98.1:

  • Tests-only control: cargo test --locked --offline -p victory-shader nibble_offset_ -- --nocapture --test-threads=1 fails the count assertion at [19, 19] versus [18, 18]; the behavior regression passes. Both pass after the lowering change.
  • cargo test --locked --offline -p victory-shader --lib -- --test-threads=1: baseline 300 passed / 2 failed / 3 ignored. cargo test --locked --offline -p victory-shader --no-fail-fast -- --test-threads=1: branch 302 passed / the same 2 failed / 3 ignored; integration 3 passed / 1 ignored; doc tests 0. The existing failures are rectangles_get_their_fourth_corner and elements_sharing_a_row_keep_their_order, both local Pipeline State Validation mismatches.
  • cargo clippy --locked --offline -p victory-shader --all-targets --all-features -- -D warnings: passes on clean baseline and branch.
  • cargo run --locked --offline -p xtask -- policy --staged: passes (3 changed files). git diff --check passes; changed files retain exactly main's existing formatting deviations.

The instruction counter is the same test-only helper used in #3722 and the preceding lowering PRs; keep one copy when integrating. No game files, extracted shaders or game execution were used. No new graphics/mesh, wave64, RADV/vkd3d runtime or frame-time validation; this does not resolve the separate RADV compiler-hang hold on #3027.

AI assistance: prepared with OpenAI Codex, reviewed by Ingenioeren.

@cloph-dsp

Copy link
Copy Markdown

Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR Shaders: lower signed nibble offsets through Ibfe #3725 at head 14f9d3020735a35fb3215eea2ada199fc416d63e, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-shader --lib -- emit::lower::tests::nibble_offset_uses_one_signed_extract --exact --test-threads=1 --quiet → 1 passed, 0 failed, 306 filtered, exit 0.
  • git grep -F for the test name on the base returned no match (test is new on this PR); git diff --check 63bcca4 HEAD clean (3 files, +131/-3).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic test was replayed; the full workspace suite and clippy were not run locally.
  • GPU/driver: N/A (CPU-only shader lowering test). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

@ColorMeBoom

Copy link
Copy Markdown

Hardware run: RX 5700 XT (Navi 10, RDNA1, 32–64 lanes, driver 32.0.21045.29003, Windows 11 26200), head 14f9d30 on 63bcca4.

  • nibble_offset_matches_signed_fractions passes. All 36 rows (10,112 inputs each, including clamp, the output multipliers, an overlapping destination and partial EXEC) have zero mismatches on the card and on WARP.
  • Full victory-shader --lib --features host: 304 passed, 0 failed, 3 ignored.

AI use: Claude Code (Claude Opus 5.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants