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

Closed
tedin7 wants to merge 2 commits from upstream-pr/2066 into main
tedin7 commented 2026-11-24 23:57:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:57:51Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593910700 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:57:51Z. --- 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[bot commented 2026-11-25 01:01:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:05:22Z.

Review: COMMENTED


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049473170 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#pullrequestreview-6049473170). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T00:05:22Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `bb9383321c` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). 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". </details>
tedin7 commented 2026-11-25 01:01:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:01:22Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049943642 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#pullrequestreview-6049943642). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:22Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 01:01:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:01:24Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049943960 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#pullrequestreview-6049943960). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:24Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-25 01:02:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:58:05Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147991825 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#issuecomment-7147991825). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:58:05Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"bb9383321c8da4a0bf8ab1969289f43ca5d8616d","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T00:05:26.511987Z">2026-11-25T00:05:26.511987Z</relative-time> | `bb93833` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). 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. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-25 01:02:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:05:23Z.

Code review location: tools/startup/gfx2hlsl.py; line 991

@@ -978,6 +987,14 @@ def op_s_load_dwordx4(self, ops, mods, count=4):
             raise Unsupported('s_load through s%d holding %s' % (base[1], p))
         # '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 None
+        if known is not None:

P1 Badge Require a control-flow-safe proof before folding SGPR offsets

When a branch can skip the offset's defining move, self.sym does 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 initializes s12 to 0, conditionally skips s_movk_i32 s12, 0x40, then loads through s12; this fold emits r0.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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688341231 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#discussion_r4688341231). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T00:05:23Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 991 ~~~~diff @@ -978,6 +987,14 @@ def op_s_load_dwordx4(self, ops, mods, count=4): raise Unsupported('s_load through s%d holding %s' % (base[1], p)) # '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 None + if known is not None: ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Require a control-flow-safe proof before folding SGPR offsets** When a branch can skip the offset's defining move, `self.sym` does 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 initializes `s12` to 0, conditionally skips `s_movk_i32 s12, 0x40`, then loads through `s12`; this fold emits `r0.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 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 01:02:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:05:23Z.

Code review location: tools/startup/gfx2hlsl.py; line 973

@@ -964,6 +964,15 @@ def smem_soffset(self, tok, record_use=True):
                 self.used_s = saved
         raise Unsupported('operand %r' % tok)
 
+    def const_soffset(self, tok):
+        """The constant held by an SMEM offset register s0..s105, or None (m0 and unknown values)."""
+        r = reg_range(tok)
+        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

P2 Badge Sign-extend MOVK constants before accepting them as offsets

For an encoded s_movk_i32 s12, 0x8000, the disassembler prints the raw 16-bit immediate and scalar() currently records ('const', 0x8000), so this new check accepts it as a positive offset. However, MOVK sign-extends its immediate, making the actual SGPR word 0xffff8000. A complete synthetic root-buffer pipeline now succeeds and emits r0.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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688341235 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#discussion_r4688341235). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T00:05:23Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 973 ~~~~diff @@ -964,6 +964,15 @@ def smem_soffset(self, tok, record_use=True): self.used_s = saved raise Unsupported('operand %r' % tok) + def const_soffset(self, tok): + """The constant held by an SMEM offset register s0..s105, or None (m0 and unknown values).""" + r = reg_range(tok) + 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 ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Sign-extend MOVK constants before accepting them as offsets** For an encoded `s_movk_i32 s12, 0x8000`, the disassembler prints the raw 16-bit immediate and `scalar()` currently records `('const', 0x8000)`, so this new check accepts it as a positive offset. However, MOVK sign-extends its immediate, making the actual SGPR word `0xffff8000`. A complete synthetic root-buffer pipeline now succeeds and emits `r0.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 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 01:02:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:05:23Z.

Code review location: CMakeLists.txt; line 2514

@@ -2509,6 +2509,9 @@ if(EXISTS "${INTAKE_PYTHON}")
     # Startup shader translator: the SMEM offset 'off' is the literal 0; m0 and other operands keep their handling (#1674).
     add_test(NAME startup_gfx2hlsl_smem_offset COMMAND "${INTAKE_PYTHON}" -B
         "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_smem_offset_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")

P1 Badge Document the newly supported constant-register SMEM offsets

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, and m0 forms as refused, which is now incorrect for constant SGPR offsets. AGENTS.md explicitly 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 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688341243 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#discussion_r4688341243). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T00:05:23Z. **Code review location:** `CMakeLists.txt`; line 2514 ~~~~diff @@ -2509,6 +2509,9 @@ if(EXISTS "${INTAKE_PYTHON}") # Startup shader translator: the SMEM offset 'off' is the literal 0; m0 and other operands keep their handling (#1674). add_test(NAME startup_gfx2hlsl_smem_offset COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_smem_offset_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") ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Document the newly supported constant-register SMEM offsets** 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`, and `m0` forms as refused, which is now incorrect for constant SGPR offsets. `AGENTS.md` explicitly 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](https://github.com/R0Y00/Xbox2Windows/blob/bb9383321c8da4a0bf8ab1969289f43ca5d8616d/AGENTS.md#L211-L212) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-25 01:02:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:01:22Z.

Code review location: tools/startup/gfx2hlsl.py; line 991

@@ -978,6 +987,14 @@ def op_s_load_dwordx4(self, ops, mods, count=4):
             raise Unsupported('s_load through s%d holding %s' % (base[1], p))
         # '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 None
+        if known is not None:

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688758199 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#discussion_r4688758199). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:22Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 991 ~~~~diff @@ -978,6 +987,14 @@ def op_s_load_dwordx4(self, ops, mods, count=4): raise Unsupported('s_load through s%d holding %s' % (base[1], p)) # '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 None + if known is not None: ~~~~ --- 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 commented 2026-11-25 01:02:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:01:24Z.

Code review location: tools/startup/gfx2hlsl.py; line 973

@@ -964,6 +964,15 @@ def smem_soffset(self, tok, record_use=True):
                 self.used_s = saved
         raise Unsupported('operand %r' % tok)
 
+    def const_soffset(self, tok):
+        """The constant held by an SMEM offset register s0..s105, or None (m0 and unknown values)."""
+        r = reg_range(tok)
+        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

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688758478 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#discussion_r4688758478). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:24Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 973 ~~~~diff @@ -964,6 +964,15 @@ def smem_soffset(self, tok, record_use=True): self.used_s = saved raise Unsupported('operand %r' % tok) + def const_soffset(self, tok): + """The constant held by an SMEM offset register s0..s105, or None (m0 and unknown values).""" + r = reg_range(tok) + 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 ~~~~ --- 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 commented 2026-11-25 01:02:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:01:26Z.

Code review location: CMakeLists.txt; line 2514

@@ -2509,6 +2509,9 @@ if(EXISTS "${INTAKE_PYTHON}")
     # Startup shader translator: the SMEM offset 'off' is the literal 0; m0 and other operands keep their handling (#1674).
     add_test(NAME startup_gfx2hlsl_smem_offset COMMAND "${INTAKE_PYTHON}" -B
         "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_smem_offset_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")

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688758738 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#discussion_r4688758738). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:26Z. **Code review location:** `CMakeLists.txt`; line 2514 ~~~~diff @@ -2509,6 +2509,9 @@ if(EXISTS "${INTAKE_PYTHON}") # Startup shader translator: the SMEM offset 'off' is the literal 0; m0 and other operands keep their handling (#1674). add_test(NAME startup_gfx2hlsl_smem_offset COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_smem_offset_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") ~~~~ --- 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 commented 2026-11-25 02:01:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:01:26Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049944300 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#pullrequestreview-6049944300). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:01:26Z. **Review:** COMMENTED --- _No description provided._
upstream-sync closed this pull request 2026-11-25 14:04:34 +00:00
tedin7 commented 2026-11-25 14:05:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:51:57Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7164403309 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#issuecomment-7164403309). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T13:51:57Z. --- 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 commented 2026-11-25 19:04:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-25T18:40:40Z.


@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 #2066 and #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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7171240515 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#issuecomment-7171240515). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-25T18:40:40Z. --- @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 #2066 and #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 commented 2026-11-25 20:04:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-25T19:15:35Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7172045166 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#issuecomment-7172045166). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-25T19:15:35Z. --- @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 commented 2026-11-25 20:04:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-25T19:26:00Z.


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 (8e0ef148), the default-sampler placeholder is no longer taken as an offset, and there are a few more edge checks.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7172289658 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2066#issuecomment-7172289658). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-25T19:26:00Z. --- 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 (8e0ef148), the default-sampler placeholder is no longer taken as an offset, and there are a few more edge checks. AI-assisted.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2059
No description provided.