startup: gfx2hlsl accepts three compute programs whose descriptor or SCC state differs from program order #2302
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#2302
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?
@NiiRoZz on GitHub · 2026-11-25 11:08 UTC · original
Problem
tools/startup/gfx2hlsl.pytracks descriptor words per scalar register in program order and emits nothing foran in-place ALU instruction on a descriptor word. Three source-built gfx1013 compute programs translate without
a refusal on
main(09551998) although the emitted HLSL does not do what the instructions do. Found whileworking on #2274. Each program is assembled with
llvm-mc15 and translated withComputePipelinethrough thehelpers of
tests/startup_gfx2hlsl_compute_check.py(assemble,root_blob, case A'srsrc2, group size2x3x4). Branch operands are dword offsets.
All three share this head: the table pointer in
s[10:11], an eight-word load, a byte address and the data.Gap 1, CONFIRMED: a store at a loop head, with its descriptor registers written later in the loop body.
Result on
main: no refusal. The loop block emitsu0.Store(a, v5);for both passes and the manifest has thesingle line
uav 0 table 1 16. The second pass runs with the descriptor at table offset 0x20 ins[16:19],so its store belongs to another buffer. The same holds when the loop body modifies a word in place instead
(
s_and_b32 s17, s17, 0xffff, branch operand 65529): no refusal, both passes throughu0.Correct: refuse the store, since the registers at the loop head are not the same on every pass.
Gap 2, CONFIRMED: a reload of another descriptor that a branch skips.
Result on
main: no refusal. The join block emitsu0.Store(a, v5);and the manifest has the single lineuav 0 table 1 32. Whens7 < 4the load is skipped and the store runs through the descriptor at tableoffset 0x10 that the head loaded, but the output always writes the buffer at offset 0x20.
Correct: refuse the store (two paths reach it with different descriptors), or emit both targets and select by
path.
Gap 3, CONFIRMED: an SCC read after an in-place ALU instruction on a descriptor word.
Result on
main: no refusal. The output isscc = s7 < 0x00000004u;thens20 = scc ? 0x00000001u : 0x00000000u;, so the stored word follows the compare. The instruction order makes itfollow the AND result of descriptor word 1, which the translator does not know.
Correct: refuse the SCC read (the existing
scc from descriptor datarefusal fits), or emit the SCC of themasked word once descriptor words are available as values.
Observed where: all three are wrong in the emitted HLSL and manifest only, judged against the instruction
semantics. No wrong output was observed on a GPU read-back. The compute read-back runner binds its own buffers,
so a GPU run would only repeat what the HLSL says; console behaviour is not measured. No count of affected
real programs is claimed.
Proposal
One claimable item per gap, each inside
gfx2hlsl.pyplus a pure-Python control. Each control is the programabove: it must be refused after the fix, and it translates on
main, so the control fails onmain.target. Acceptance: both gap 1 programs are refused; the same loop without a write to
s[16:19]stilltranslates and stores once per pass.
way #2279 drops scalar constants that another path writes. Acceptance: the gap 2 program is refused; the
same program with the reload before the branch still translates with
uav 0 table 1 32.SCC write, and a read of it is refused. Acceptance: the gap 3 program is refused; the same program with the
compare after the AND still translates. Check
s_cselect,s_cmovands_cbranch_scc0/1as readers.Items 1 and 2 may turn out to be one join rule; whoever takes one should say so and take both.
Alternatives
path writes the descriptor registers, which translate correctly today.
manifest line per target; refusing first is the smaller step and loses nothing that is right today.
have.
Verification
mainat09551998,llvm-mc15.lines.
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_'andpython -B tests/startup_gfx2hlsl_compute_check.pystill pass.Checklist
AI-assisted (Claude Code).
@RavenCurseBurg on GitHub · 2026-11-25 11:12 UTC · original
I'll take item 3 (a stale SCC after scalar ALU on descriptor data). I'll use the reported compute program and paired source-built controls for conditional selects, conditional moves and both branch polarities, including a fresh comparison before the read. I'll check that a write reached on only one branch cannot clear the refusal for the other path. Items 1 and 2 remain with the descriptor-join work.
@RavenCurseBurg on GitHub · 2026-11-25 11:47 UTC · original
Item 3 landed in #2305. I also checked the two remaining items against #2292 at
78a1cd09and main at209938b0. The programs below use the shared source prefix from this issue, compiled for gfx1013 with LLVM 15.0.7, and the normal case-A ComputePipeline entry point.I also ran the committed #2292
binary,dispatchandcontrolcases. The recorded words matched LLVM 15's integrated assembler. With DXC 1.9.2609.5, WARP 10.0.26100.9711 and desktop RTX 4060 driver 32.0.15.9579 both matched all 320 words of the same-slot loop, with values 1 and 2 for each of eight lanes. The OUTSIDE control returned 3 in all four channels on both. Both local adapters reported the debug layer unavailable.These are the reported source-built cases and their paired controls. With #2292 covering them, I see no need for a second implementation of items 1 and 2.
@R0Y00 on GitHub · 2026-11-25 12:09 UTC · original
#2305 and #2292 are both on
main. The exact #2292 candidate tested in the report above is the one that merged, so the three source-built gaps now have coverage. The combined join, SCC and offline-cache checks passed locally, and the graphics and compute cache revisions advanced. Is anyone already collecting the remaining before/after refusal census requested here? For one matched cache, counts by newly refused reason are enough. Please keep the shader bytes and raw reports local.@JVProg on GitHub · 2026-11-25 17:32 UTC · original
I ran the before/after refusal census on one matched cache. In this cache neither #2305 nor #2292 turned a request with no recorded refusal into a refused one. The new reasons land on requests that were already refused.
Setup
a6d2c5e6(before),a7353044(#2305),5074371f(#2292). #2305 and #2292 are the only commits in this range that touchtools/startup/gfx2hlsl.py.refusals_report(the function behind--refusals) on a copy of a local cache: 593 graphics request keys and 2,689 compute requests. Slot 57 mesh requests are not examined.pipeline_keyandcompute_keyto 9. Lowering code is unchanged. No key-mismatch refusal in any run.X2W_*variables set. No fxc/DXC compile and no GPU read-back.Totals
a6d2c5e6scc from descriptor datareason at #2305joined at a branch targetreason at #2292Reasons added at #2305 (requests per reason; one request can count in several rows). No reason was removed at this step.
scc from descriptor data in ...psvss_cbranch_scc0s_cbranch_scc1s_cselect_b32s_cselect_b64s_mov_b32s_or_b32s_add_u32s_and_b32s_addc_u32s_mul_i32Join reasons added at #2292
psvsnumeric use of sN holding joined at a branch targetdescriptor operand s[N:N] holds ('joined at a branch target',)s_load through sN holding ('joined at a branch target',)buffer store through s[N:N] holding ('joined at a branch target',)s_addk_i32 on joined at a branch target data#2292 also adds some non-join reasons and removes others (the largest removal in compute is
numeric use of sN holding ptr, 219 requests).It also changes the SCC picture: of the requests that gained an SCC reason at #2305, 126 of 147 graphics and 11 of 112 compute show no SCC reason after #2292. All 126 graphics requests and 9 of the 11 compute requests gain a join reason at that step. I did not trace why.
Limits
internal errorentries on already refused requests (notranslator crash). The per-reason counts above are therefore less reliable than the totals.mainhas moved since5074371f(28 later commits touchgfx2hlsl.py); these numbers do not describe currentmain.AI-assisted (Claude Code).