startup: gfx2hlsl folds a loop counter to its value before the loop, so translated loops run to the 65,536-iteration guard #2278
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#2278
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?
@lukaslw-lab on GitHub · 2026-11-25 09:28 UTC · original
Commit or build
main07c1c20f.Reproduction
A source-built program, no shader machine code needed:
Translate it with
gfx2hlsl.Stage.translate()(the harness oftests/startup_gfx2hlsl_readfirstlane_uniform_check.py).Expected behavior
Inside the loop the counter is read as the register:
s14 = s14 + 0x00000001u;andv13 = U(float(int(s14)));.Observed behavior
The value from before the loop is folded into the loop body:
The counter is 1 on every pass, so the exit test only fires for a trip count of 1. Any other loop runs until the dispatcher guard (
guard < 65536), and everything computed from the counter (sample offsets, buffer strides) is frozen at the first iteration's value.Cause: at a branch target
Stage.translateclears the uniformity proofs (uniform_v,since_join,scc_uniform) but keeps the('const', n)entries inself.sym. A forward branch has the same problem: after a join, a register written only on the fall-through path is still folded to its earlier value.Effect in a local startup run (Windows 10 19045, RTX 3080 Ti,
-Render -Translate, post-confirmation load):Environment
Windows 10 22H2 (19045), Python 3.13, RTX 3080 Ti. The reproduction above is pure Python and needs no device.
AI-assisted (Claude Code).