startup: a compute buffer load in gfx2hlsl ignores an edit to word 1–3 of its descriptor #2901
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#2901
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Not-Saii on GitHub · 2026-11-26 17:36 UTC · original
Summary
In
tools/startup/gfx2hlsl.py, a computebuffer_load_dword … offenresolves its descriptor operand withStage.descriptor, which reads only the symbol of the first register. If an earlier scalar instruction has replaced or edited word 1, 2 or 3 (for example NUM_RECORDS in word 2), the load still translates as a read of the unmodified buffer, and the edit is dropped. A buffer store through the same edited descriptor is refused (buffer store through a modified descriptor), so the two paths disagree.This matters when the edit changes what the load returns. On RDNA 2, a raw buffer with NUM_RECORDS = 0 returns zeros for every offen load. The translation instead reads the bound buffer.
For in-place edits this is a known choice. The descriptor-data path in
Stage.scalarsays "Keep the resource identity for loads; stores refuse the unproved value". But that choice also covers a word replaced with a different value, and a size word set to 0.Reproduction (upstream main
b505c32b, source-built, no capture input)Case A of
tests/startup_gfx2hlsl_compute_check.pyloadsbuffer_load_dword v5, v4, s[12:15], 0 offenand storesbuffer_store_dword v5, v4, s[16:19], 0 offen, with both descriptors from ones_load_dwordx8. Splice each edit below just before the load (on s[12:15]), and the same edit just before the store (on s[16:19]), then translate. Run from the repository root:Observed
s_lshr_b32 s21, s14, 2/s_mov_b32 s13, s21(word 1)s_lshr_b32 s21, s14, 2/s_mov_b32 s14, s21(word 2)s_lshr_b32 s21, s14, 2/s_mov_b32 s15, s21(word 3)s_lshr_b32 s21, s14, 2/s_lshr_b32 s14, s21, 0(word 2, ALU result)s_and_b32 s14, s14, 0(word 2 zeroed in place)s_mov_b32 s14, 0(word 2 set to 0)For the five descriptor-derived edits, the translated HLSL is byte-identical to unedited case A. For
s_mov_b32 s14, 0, the only difference is a deads14 = 0x00000000u;assignment. In every case the load line isv5 = r0.Load(a + 0);, as in case A.Expected
A buffer load whose descriptor has an edited or replaced word 1–3 should refuse, as the store does, unless the edit is one a proof accepts. Two examples:
Scope and notes
buffer_load_dword … offenwith a descriptor loaded through a table pointer. I didn't check theidxenforms,s_buffer_load, the format loads, descriptors built from a pointer (first wordptr), or the vertex stage.s_cselect_b32 sX, 0, sXondescnumFIX on #2618. That change refuses its own select result in any descriptor word and doesn't fix this general gap.AI-assisted (Claude Code).
github-bot referenced this issue2026-11-27 01:28:36 +00:00