shader: support s_load with register offset through resource heap in gfx2hlsl (Part of #1723) #2066
No reviewers
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!2066
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2066/head"
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?
@tedin7 on GitHub · 2026-11-24 23:57 UTC · original
tedin7:x2w-r23-bindless-sload→main· +101 −0 · 4 files · 2 commits · closed without mergingPart of #1723
What this unblocks:
s_loadfrom the resource heap (and any descriptor table) now works when the byte offset sits in a register that an earlier move filled with a known constant, so those descriptor loads stop being refused as "register offset" (first slice of the bindless refusals).Change:
tools/startup/gfx2hlsl.py:s_load*reads an offset register with a known constant value as that literal byte offset, plus anyoffset:modifier. Unknown registers,m0and the sampler heap keep their old handling.tests/startup_gfx2hlsl_sload_const_offset_check.py, registered inCMakeLists.txtasstartup_gfx2hlsl_sload_const_offset.Not in this slice: offsets that are truly run-time values (a heap table indexed in the shader). The manifest still refuses a
resheapresource.Verification:
python3 -B tests/startup_gfx2hlsl_sload_const_offset_check.py: 0 failed (same file against the old translator: 3 failed).python3 -B tests/startup_gfx2hlsl_smem_offset_check.py: 0 failed.python3 -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.py: 0 failed.python3 -B tests/startup_translator_check.py: 0 failed.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:58 UTC · original · edited 2026-11-25 00:05 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
bb93833ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@ -2177,2 +2192,4 @@# 'off' names no offset operand at all, so the byte offset is zero, as for the literal 0.token = smem_offset(ops[2])known = self.const_soffset(token) if p[1] != ('smpheap',) else Noneif known is not None:@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:05 UTC · original
When a branch can skip the offset's defining move,
self.symdoes not prove its runtime value:Stage.translate()processes instructions linearly without merging symbols at control-flow joins. I reproduced a synthetic root-buffer pipeline that initializess12to 0, conditionally skipss_movk_i32 s12, 0x40, then loads throughs12; this fold emitsr0.Load(64)even on the path that requires offset 0. The parent commit refused this pipeline. Restrict the new folding to straight-line code until a CFG-aware constant proof is available, rather than silently loading the wrong buffer word or descriptor.Useful? React with 👍 / 👎.
@ -2162,0 +2171,4 @@if r and r[0] == 's' and r[1] == r[2] and r[1] <= 105:value = self.is_const(r[1])if value is not None and 0 <= value <= 0xfffff:return value@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:05 UTC · original
For an encoded
s_movk_i32 s12, 0x8000, the disassembler prints the raw 16-bit immediate andscalar()currently records('const', 0x8000), so this new check accepts it as a positive offset. However, MOVK sign-extends its immediate, making the actual SGPR word0xffff8000. A complete synthetic root-buffer pipeline now succeeds and emitsr0.Load(32768)where the parent commit refused the register-offset load. Track the sign-extended MOVK value before using it in this fold, or keep these cases refused, so newly accepted shaders do not read the wrong address.Useful? React with 👍 / 👎.
@ -3404,1 +3404,4 @@"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_loop_constants_check.py")# Startup shader translator: s_load with a register offset holding a known constant reaches the heap descriptor (#1723).add_test(NAME startup_gfx2hlsl_sload_const_offset COMMAND "${INTAKE_PYTHON}" -B"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_sload_const_offset_check.py")@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:05 UTC · original
This adds a public scalar-load capability and a reproduction check, but the commit updates neither the README nor
docs/experiments.md. In particular, the existing “SMEM offset operands” table still classifies offsets other than literal,off, andm0forms as refused, which is now incorrect for constant SGPR offsets.AGENTS.mdexplicitly requires documenting public capability or reproduction-command changes; update the relevant experiment entry with the accepted form, bounds, remaining refusals, and Linux-only translation evidence.AGENTS.md reference: AGENTS.md:L211-L212
Useful? React with 👍 / 👎.
@ -2177,2 +2192,4 @@# 'off' names no offset operand at all, so the byte offset is zero, as for the literal 0.token = smem_offset(ops[2])known = self.const_soffset(token) if p[1] != ('smpheap',) else Noneif known is not None:@tedin7 on GitHub · 2026-11-25 01:01 UTC · original
Fixed in c28366b3 (rebased on current main, pending push to this branch). The fold now applies only in shaders without branches; s_movk_i32 sign-extends its immediate (0x8000 and above stay refused as offsets); docs/experiments.md has the accepted form, limits and CPU-only evidence. Controls added to tests/startup_gfx2hlsl_sload_const_offset_check.py.
AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_sload_const_offset_check.py, startup_gfx2hlsl_smem_offset_check.py, startup_translator_check.py, startup_gfx2hlsl_scalar_m0_check.py, docs_links_check.py.
@ -2162,0 +2171,4 @@if r and r[0] == 's' and r[1] == r[2] and r[1] <= 105:value = self.is_const(r[1])if value is not None and 0 <= value <= 0xfffff:return value@tedin7 on GitHub · 2026-11-25 01:01 UTC · original
Fixed in c28366b3 (rebased on current main, pending push to this branch). The fold now applies only in shaders without branches; s_movk_i32 sign-extends its immediate (0x8000 and above stay refused as offsets); docs/experiments.md has the accepted form, limits and CPU-only evidence. Controls added to tests/startup_gfx2hlsl_sload_const_offset_check.py.
AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_sload_const_offset_check.py, startup_gfx2hlsl_smem_offset_check.py, startup_translator_check.py, startup_gfx2hlsl_scalar_m0_check.py, docs_links_check.py.
@ -3404,1 +3404,4 @@"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_loop_constants_check.py")# Startup shader translator: s_load with a register offset holding a known constant reaches the heap descriptor (#1723).add_test(NAME startup_gfx2hlsl_sload_const_offset COMMAND "${INTAKE_PYTHON}" -B"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_sload_const_offset_check.py")@tedin7 on GitHub · 2026-11-25 01:01 UTC · original
Fixed in c28366b3 (rebased on current main, pending push to this branch). The fold now applies only in shaders without branches; s_movk_i32 sign-extends its immediate (0x8000 and above stay refused as offsets); docs/experiments.md has the accepted form, limits and CPU-only evidence. Controls added to tests/startup_gfx2hlsl_sload_const_offset_check.py.
AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_sload_const_offset_check.py, startup_gfx2hlsl_smem_offset_check.py, startup_translator_check.py, startup_gfx2hlsl_scalar_m0_check.py, docs_links_check.py.
@tedin7 on GitHub · 2026-11-25 13:51 UTC · original
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is.
We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here.
AI-assisted; commands listed were executed locally.
@Leyukaka on GitHub · 2026-11-25 18:40 UTC · original
@tedin7, a question about this PR and #2086, which you paused today.
In a local first-refusal census of captured start-up requests at main
dbab543, the refusal this PR targets,s_load with a register offset through ('resheap',), is the first refusal for 174 requests. I have not checked how many of those have the constant offset in a branch-free shader that this PR handles.s_pack_ll_b32_b16(#2086) is the first refusal for 59. These are counts only; the inputs are private.Two offers, whichever helps more:
Note:
v_add_co_ci_u32from #2033 is now on main through #2428.If neither is useful, ignore this.
AI-assisted.
@Leyukaka on GitHub · 2026-11-25 19:15 UTC · original
@tedin7, no reply here yet to my question from 18:40Z, and you said you plan to reopen this, so tell me if you'd rather I stop: I'm picking this up the same way as #2086 (now #2512): a new PR with your commits rebased on current main, keeping your authorship, linked here. Your fixes for the three review findings (branch-free shaders only,
s_movk_i32sign extension, docs) stay as they are. If you'd rather reopen this one yourself, say so and I'll close mine.AI-assisted.
@Leyukaka on GitHub · 2026-11-25 19:26 UTC · original
Opened as #2517: your commit rebased on current main with your authorship. On top: the
s_movk_i32sign extension is dropped because main already applies it (8e0ef148), the default-sampler placeholder is no longer taken as an offset, and there are a few more edge checks.AI-assisted.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:05 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
bb9383321cℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Pull request closed