Repository navigation
startup: s_load with a constant register offset reaches the heap descriptor (continues #2066, Part of #1723) - #2517
Merged
Merged
Conversation
…riptor (R0Y00#1723) Fold only in shaders without branches, sign-extend s_movk_i32, and document the accepted form.
8e0ef14 sign-extends the SOPK i32 immediates through sopk_imm before this branch, so a 0x8000..0xffff value can no longer reach it. The startup_gfx2hlsl_sload_const_offset checks for the sign-extended value and the refused negative offset still pass on main's path. AI-assisted.
const_soffset now takes only an untagged ('const', value) symbol, so the
('const', 0, 'unassigned') default-sampler placeholder is not folded to
offset 0. New checks: s_mov_b32 0x8000 stays 0x8000, a constant plus an
offset: modifier above 0xfffff is refused, the placeholder is refused, and a
sampler-heap register offset is not folded.
List startup_gfx2hlsl_sload_const_offset_check.py in AGENTS.md and the Linux
CI Python list next to startup_gfx2hlsl_smem_offset_check.py, and drop the
OS from the docs' evidence line.
AI-assisted.
tedin7
reviewed
Nov 25, 2026
tedin7
left a comment
Collaborator
There was a problem hiding this comment.
Review of head 75141d9 (comment only, no approval).
Code (tools/startup/gfx2hlsl.py, const_soffset and the op_s_load_dwordx4 hook): looks correct.
- The constant is used only without branches, only for an untagged
('const', v)symbol, only for s0..s105, and only when the total withoffset:is within 0..0xfffff.has_branchesis set at line 1961 and the default is the safe one. - The sampler heap keeps its old handling. The refusal message for a too-large total is kept.
- Sibling checks left out: none found.
startup_gfx2hlsl_smem_offset_check.pystill passes. - No other open or merged PR covers this slice (#2066 is closed, this continues it).
Tests (Linux, at this head):
tests/startup_gfx2hlsl_sload_const_offset_check.py: 0 failed.tests/startup_gfx2hlsl_smem_offset_check.py: 0 failed.tests/docs_links_check.py: passed.tests/bidi_controls_check.py: passed.git diff --check origin/main...HEAD: clean.- Mutations (each made the new check fail, then reverted): the branch guard removed; the 0xfffff total check removed.
Scope notes:
- This is a scalar symbol-state change, not an HLSL math lowering, so the checks that drive the handlers are fair. There is no GPU readback and none is needed for this slice.
- The title and the "first refusal for 174 requests" figure frame it as advancing start-up. I have no executable to confirm that, so I report only code and fixture results. The merge and any start-up claim stay with MasterDomino or @R0Y00, who can verify on the game.
.github/workflows/windows.ymlonly adds the new check to the Python list (one line). Its own CI run exercises it.- No Windows WARP run was done by me; this change has no GPU path.
AI-assisted; commands listed were executed locally.
legacy-code-archaeologist
added a commit
to legacy-code-archaeologist/Xbox2Windows
that referenced
this pull request
Nov 25, 2026
# Conflicts: # docs/experiments.md # tests/startup_gfx2hlsl_sload_const_offset_check.py # tools/startup/gfx2hlsl.py
legacy-code-archaeologist
added a commit
to legacy-code-archaeologist/Xbox2Windows
that referenced
this pull request
Nov 25, 2026
…on (R0Y00#2517 union merge) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continues #2066 by @tedin7 (paused to keep the Windows test queue short; takeover note). Part of #1723.
The first commit is tedin7's
eb931ba9, cherry-picked onto main6d2d3bewith his authorship. It includes his fixes for the three review findings on #2066.An
s_load_dword*whose offset register holds a known constant now uses it as the literal byte offset, plus anyoffset:modifier. Such a constant comes from ans_mov_b32ors_movk_i32before the load. This reaches descriptors in the resource heap. Limits, unchanged from #2066:m0and the run-time sampler heap keep their old handling. A constant whose total with theoffset:modifier is above 0xfffff is refused (SMEM register offset ...).resheapresource.Rebase. One conflict in
CMakeLists.txt: both sides add a test next tostartup_gfx2hlsl_loop_constants, so I kept both.Two commits of mine on top.
The first drops #2066's
s_movk_i32sign extension inStage.scalar. Main has sign-extended the SOPK i32 immediates throughsopk_immsince 8e0ef14, sos_movk_i32 s9, 0x8000already records0xffff8000, and the removed branch could no longer run. The checks for that value, and for the refused negative offset, now exercise main's path. The behaviour #2066 asked for is kept.The second:
const_soffsettake only an untagged('const', value)symbol, so the('const', 0, 'unassigned')default-sampler placeholder is not folded to offset 0;s_mov_b32 0x8000(not sign-extended), a total above 0xfffff, the placeholder and a sampler-heap register offset;Tests. Run on Windows 11 with Python 3.14 at this branch's head, all passing:
tests/startup_gfx2hlsl_sload_const_offset_check.py(new, from shader: support s_load with register offset through resource heap in gfx2hlsl (Part of #1723) #2066);startup_gfx2hlsl_smem_offset_check.py;startup_translator_check.py;startup_gfx2hlsl_scalar_m0_check.py;startup_gfx2hlsl_loop_constants_check.py;startup_gfx2hlsl_join_symbols_check.py;startup_gfx2hlsl_sopk_signext_check.py.docs_links_check.pywas not run: it needs a git checkout, and these tests ran on a copy of the tree without.git.Mutation checks, run by hand.
startup_gfx2hlsl_sload_const_offset_check.pyfails on each:offset:modifier ignored;s_movk_i32sign extension turned off (sopk_imm(..., False)), whichstartup_gfx2hlsl_sopk_signext_check.pyalso catches;Why. In a local first-refusal census of captured start-up requests at main
6d2d3be,s_load with a register offset through ('resheap',)is the first refusal for 174 requests (private inputs, counts only). I have not measured how many of those are branch-free shaders with a constant offset, which is the case this slice handles.No GPU run; the checks drive the load handlers on a scalar symbol state.
AI-assisted.