Skip to content

Shaders: truncate s_buffer_load offset terms independently - #3

Closed
makmatvey wants to merge 1 commit into
mainfrom
cursor/shaders-s-buffer-load-align-2ac3
Closed

makmatvey wants to merge 1 commit into
mainfrom
cursor/shaders-s-buffer-load-align-2ac3

Conversation

@makmatvey

Copy link
Copy Markdown
Owner

What

s_buffer_load_dword* on RDNA adds the immediate offset and soffset after clearing each term's two LSBs (RDNA ISA guide §8, Scalar Memory Operations). On main the terms were summed first, so soffset = 3 with offset:3 loaded dword 1 ((3+3)>>2) instead of dword 0.

Tracked as VIC-BT-025 in Marvisak#1249. Related open head Marvisak#1939 (triage: needs work) — this is a focused slice with the citation and distinguishing soffset=3, offset:3 case from that triage.

Change

In crates/victory-shader/src/emit/lower.rs, mask only the instruction operands (imm & !3, soffset & !3) before adding. Descriptor base / dynamic extra stay unmasked.

Tests

  • cargo test -p victory-shader --locked --lib s_buffer_load_with_unaligned_soffset_and_offset_lowers — pass (Linux)
  • s_buffer_load_truncates_offset_terms_independently (Windows GPU / WARP): soffset=3,offset:3 → dword 0; soffset=7,offset:7 → dword 2
  • cargo clippy -p victory-shader --locked -- -D warnings — clean

No game data used.

Open in Web Open in Cursor 

RDNA ISA §8 ignores the two LSBs of the immediate offset and of soffset
separately before they are summed. Adding first then shifting made
soffset=3 offset:3 load dword 1 instead of dword 0.
@makmatvey

Copy link
Copy Markdown
Owner Author

Opened against the fork by mistake; upstream PR is Marvisak#2438

@makmatvey makmatvey closed this Nov 25, 2026
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.

1 participant