shader: decode backward far jumps (signed offset literal) #80
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!80
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/80/head"
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?
@tedin7 on GitHub · 2026-11-24 00:17 UTC · original
tedin7:vic-far-jump-backward→main· +30 −1 · 1 files · 1 commits · merged 2026-11-24 00:37 UTCWhat
The far-jump resolver in the GFX10 decoder read the 32-bit literal of
s_add_u32 sn, sn, literalas unsigned. It now reads it as a signed offset.Why
Compilers reach past a branch's +-128 KB range with
s_getpc_b64,s_add_u32(low dword of a signed 64-bit offset),s_addc_u32(high dword),s_setpc_b64. A backward far jump has a negative low dword (for example 0xFFFFFFF8) and a high dword of -1. The old code turned that into a target about 4 GB ahead, found it outside the code, and failed the whole shader withfar jump target outside the code. So a shader with a loop body over 128 KB could not be translated. Forward jumps behave as before (the literal is small and positive), and so does thes_sub_u32form.Tested
Linux x86_64 only:
gfx10::tests::follows_far_jumps_backward(synthetic words in memory, no game data). Before the fix it fails withIsa { offset: 24, reason: "far jump target outside the code" }; after the fix it passes.cargo test -j4 -p victory-shader: 52 passed, 0 failed.cargo clippy -j4 -p victory-shader --tests: no new warnings (one existing dead_code warning for a Windows-only helper).rustfmt --check --edition 2024on the touched file: clean.Not run: Windows runtime, GPU, or any real console shader. The encoding of the backward jump follows how LLVM-style compilers emit it; I did not have a real shader to confirm the console compiler does the same.
@DaviTostes on GitHub · 2026-11-24 00:23 UTC · original
Tested
c963b71stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.cargo test --workspace: 156 passed, 0 failed, 3 ignored; merge with #39 clean.#[test]s (the signed far-jump decode cases), included in that run.AI-assisted (DeepSeek V4.1 Flash coding agent).