Skip to content

shader: support s_load with register offset through resource heap in gfx2hlsl (Part of #1723) - #2066

Closed
tedin7 wants to merge 2 commits into
R0Y00:mainfrom
tedin7:x2w-r23-bindless-sload
Closed

tedin7 wants to merge 2 commits into
R0Y00:mainfrom
tedin7:x2w-r23-bindless-sload

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Part of #1723

What this unblocks: s_load from 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 any offset: modifier. Unknown registers, m0 and the sampler heap keep their old handling.
  • New test tests/startup_gfx2hlsl_sload_const_offset_check.py, registered in CMakeLists.txt as startup_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 resheap resource.

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.
  • Ran on the Linux worker, not on Win2025: no Windows-only code is touched.

AI-assisted; commands listed were executed locally.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T00:05:26.511987Z bb93833 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread tools/startup/gfx2hlsl.py Resolved
Comment thread tools/startup/gfx2hlsl.py Resolved
Comment thread CMakeLists.txt Resolved
…riptor (R0Y00#1723)

Fold only in shaders without branches, sign-extend s_movk_i32, and document the accepted form.
@tedin7
tedin7 force-pushed the x2w-r23-bindless-sload branch from a8b75ad to eb931ba Compare November 25, 2026 10:25
@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

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

Copy link
Copy Markdown
Contributor

@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:

  1. The body says the tests here ran on the Linux worker only. I can run the tests this PR lists in an isolated Windows 11 VM with WARP and post the results here. That is not the Win2025 runner, so it would be extra evidence, not a replacement for your checks.
  2. You said you will reopen these once the queue is clear. If it would help to hand shader: support s_load with register offset through resource heap in gfx2hlsl (Part of #1723) #2066 and shader: lower s_pack_ll/lh/hh_b32_b16 and s_absdiff_i32 in gfx2hlsl (Part of #1723) #2086 off instead, say so. I would continue from your branches, keep your authorship on the commits, and link back here.

Note: v_add_co_ci_u32 from #2033 is now on main through #2428.

If neither is useful, ignore this.

AI-assisted.

@Leyukaka

Copy link
Copy Markdown
Contributor

@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_i32 sign extension, docs) stay as they are. If you'd rather reopen this one yourself, say so and I'll close mine.

AI-assisted.

@Leyukaka

Copy link
Copy Markdown
Contributor

Opened as #2517: your commit rebased on current main with your authorship. On top: the s_movk_i32 sign extension is dropped because main already applies it (8e0ef14), the default-sampler placeholder is no longer taken as an offset, and there are a few more edge checks.

AI-assisted.

R0Y00 pushed a commit that referenced this pull request Nov 25, 2026
…riptor (continues #2066, Part of #1723) (#2517)

* startup: s_load with a constant register offset reaches the heap descriptor (#1723)

Fold only in shaders without branches, sign-extend s_movk_i32, and document the accepted form.

* startup: drop the s_movk_i32 sign extension that main already applies

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.

* startup: refuse tagged constants as SMEM offsets and cover the edges

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.

---------

Co-authored-by: tedin7 <tommasoderosa94@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants