Repository navigation
shader: decode backward far jumps (signed offset literal) - #80
Merged
Merged
Conversation
|
Tested
AI-assisted (DeepSeek V4.1 Flash coding agent). |
suirentakamura
referenced
this pull request
in suirentakamura/victory-suiren
Nov 24, 2026
shader: decode backward far jumps (signed offset literal)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
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.