startup: lower explicit-LOD image_sample_l to SampleLevel in gfx2hlsl #1251

Merged
tedin7 merged 5 commits from upstream-pr/1258 into main 2026-11-24 06:09:38 +00:00
tedin7 commented 2026-11-24 05:44:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:44:47Z.


Change

Lowers the gfx1013 image_sample_l form (explicit level of detail) in tools/startup/gfx2hlsl.py to tex.SampleLevel(smp, uv, level) for 2D and 3D textures. The level is the last address register (third for contiguous 2D, fourth for 3D, last element of an NSA list). Offset (_o), compare, gather, cube and unorm forms are refused with an Unsupported message. Previously the translator refused every image_sample_l. No related open issue or PR found (checked sample/gfx2hlsl in open PRs).

AI-assisted.

Verification

  • python3 -B tests/startup_image_sample_l_check.py: passes with the change; on origin/main it fails (Unsupported: image_sample_l).
  • python3 -B tests/startup_image_sample_l_check.py binary llvm-mc-19: fixture words match (CI runs it with llvm-mc-15).
  • Negative controls, each fails the check: level replaced by 0; implicit Sample instead of SampleLevel; level taken from the third register in every form (fails on the NSA and 3D fixtures).
  • python3 -B tests/startup_sampler_heap_check.py, tests/startup_uniform_lane_check.py, tests/docs_links_check.py: pass.
  • Not run: any Windows, WARP or hardware run.

PR fuori preset pr: ctest -R "^startup_image_sample_l$" on the Windows node (pure Python translation check, no GPU).

Evidence and follow-up

  • Fixtures are source-built gfx1013 assembly, original to this repo; words are checked against llvm-mc.
  • The level selection is verified on the generated HLSL text only. Open: a WARP readback that samples an explicit mip level different from the implicit one (needs a new offscreen_check mode with a coloured-mip texture).
  • Docs: docs/experiments.md, docs/startup-runtime.md.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6575498063 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:44:47Z. --- ## Change Lowers the gfx1013 `image_sample_l` form (explicit level of detail) in `tools/startup/gfx2hlsl.py` to `tex.SampleLevel(smp, uv, level)` for 2D and 3D textures. The level is the last address register (third for contiguous 2D, fourth for 3D, last element of an NSA list). Offset (`_o`), compare, gather, cube and `unorm` forms are refused with an `Unsupported` message. Previously the translator refused every `image_sample_l`. No related open issue or PR found (checked `sample`/`gfx2hlsl` in open PRs). AI-assisted. ## Verification - `python3 -B tests/startup_image_sample_l_check.py`: passes with the change; on origin/main it fails (`Unsupported: image_sample_l`). - `python3 -B tests/startup_image_sample_l_check.py binary llvm-mc-19`: fixture words match (CI runs it with llvm-mc-15). - Negative controls, each fails the check: level replaced by 0; implicit `Sample` instead of `SampleLevel`; level taken from the third register in every form (fails on the NSA and 3D fixtures). - `python3 -B tests/startup_sampler_heap_check.py`, `tests/startup_uniform_lane_check.py`, `tests/docs_links_check.py`: pass. - Not run: any Windows, WARP or hardware run. PR fuori preset pr: `ctest -R "^startup_image_sample_l$"` on the Windows node (pure Python translation check, no GPU). ## Evidence and follow-up - Fixtures are source-built gfx1013 assembly, original to this repo; words are checked against llvm-mc. - The level selection is verified on the generated HLSL text only. Open: a WARP readback that samples an explicit mip level different from the implicit one (needs a new `offscreen_check` mode with a coloured-mip texture). - Docs: `docs/experiments.md`, `docs/startup-runtime.md`. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:47:22 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:52:27Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5275bb337e

ℹ️ 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:6034348567 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#pullrequestreview-6034348567). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:52:27Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `5275bb337e` <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-24 06:47:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:54:12Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034361953 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#pullrequestreview-6034361953). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:54:12Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-24 06:47:23 +00:00 (Migrated from github.com)

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

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 544a0cb6f6

ℹ️ 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:6034403674 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#pullrequestreview-6034403674). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:58:31Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `544a0cb6f6` <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-24 06:47:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:59:47Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034413120 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#pullrequestreview-6034413120). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:59:47Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 06:47:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:03:15Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034443618 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#pullrequestreview-6034443618). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T06:03:15Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 06:50:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:54:15Z.


Fixed in 544a0cb6: the MIMG decoder now prints a16 (word 1 bit 30), and image_sample_l refuses it. New fixture check fails on the old decoder, passes now. @codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123383648 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#issuecomment-7123383648). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:54:15Z. --- Fixed in 544a0cb6: the MIMG decoder now prints a16 (word 1 bit 30), and image_sample_l refuses it. New fixture check fails on the old decoder, passes now. @codex review
tedin7 commented 2026-11-24 06:50:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:54:21Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44) at commit 5275bb337ea25e177c0548133e4b3703d7a5603c:

  • cmake --preset dev + ctest --preset dev -R "^startup_image_sample_l$": 1/1 passed (0.16s)
  • cmake --preset release + ctest --preset release -R "^startup_image_sample_l$": 1/1 passed (0.15s)
  • python -B tests/startup_image_sample_l_check.py: exit 0
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123385307 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#issuecomment-7123385307). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:54:21Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44) at commit `5275bb337ea25e177c0548133e4b3703d7a5603c`: - `cmake --preset dev` + `ctest --preset dev -R "^startup_image_sample_l$"`: 1/1 passed (0.16s) - `cmake --preset release` + `ctest --preset release -R "^startup_image_sample_l$"`: 1/1 passed (0.15s) - `python -B tests/startup_image_sample_l_check.py`: exit 0
tedin7 commented 2026-11-24 06:50:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:59:49Z.


Fixed in 30fa57b4: the MIMG decoder now prints tfe (word 0 bit 16) and image_sample_l refuses it; new fixture fails on the old decoder. @codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123471429 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#issuecomment-7123471429). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:59:49Z. --- Fixed in 30fa57b4: the MIMG decoder now prints tfe (word 0 bit 16) and image_sample_l refuses it; new fixture fails on the old decoder. @codex review
tedin7 commented 2026-11-24 06:50:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:03:17Z.


AI-assisted update (7fb2c893): image_sample_l now refuses every MIMG bit and form the lowering does not model, and the disassembler decodes lwe from its real bit 17. Merged current main (SDWA and image-3d entries kept). Local checks: startup_image_sample_l_check.py (controls and llvm-mc-19 fixture words) and startup_gfx2hlsl_sdwa_check.py pass; the new negative fixtures fail on the previous code. @codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123531798 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#issuecomment-7123531798). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T06:03:17Z. --- AI-assisted update (7fb2c893): image_sample_l now refuses every MIMG bit and form the lowering does not model, and the disassembler decodes lwe from its real bit 17. Merged current main (SDWA and image-3d entries kept). Local checks: startup_image_sample_l_check.py (controls and llvm-mc-19 fixture words) and startup_gfx2hlsl_sdwa_check.py pass; the new negative fixtures fail on the previous code. @codex review
chatgpt-codex-connector[bot commented 2026-11-24 06:50:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:07:57Z.


Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 7fb2c8938b

ℹ️ 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:comment:7123616586 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#issuecomment-7123616586). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T06:07:57Z. --- <!-- codex-review-receipt:v1 --> Codex Review: Didn't find any major issues. :rocket: **Reviewed commit:** `7fb2c8938b` <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>
chatgpt-codex-connector[bot commented 2026-11-24 06:50:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:47:10Z.


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-24T06:07:59.120253Z 7fb2c89 Manual request
ℹ️ 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:7123272098 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#issuecomment-7123272098). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:47:10Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"7fb2c8938b2b1991a04c8fb317f3a1ea1114e64a","has_any_findings":false,"has_unresolved_findings":false,"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-24T06:07:59.120253Z">2026-11-24T06:07:59.120253Z</relative-time> | `7fb2c89` | Manual request | <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>
tedin7 commented 2026-11-24 06:50:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:08:33Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at 7fb2c893:

  • cmake --preset dev + ctest --preset dev -R "^(startup_image_sample_l|startup_gfx2hlsl_sdwa)$" — 2/2 PASS (startup_image_sample_l 0.16s, startup_gfx2hlsl_sdwa 0.39s)
  • cmake --preset release (/O2) + ctest --preset release -R "^(startup_image_sample_l|startup_gfx2hlsl_sdwa)$" — 2/2 PASS (startup_image_sample_l 0.17s, startup_gfx2hlsl_sdwa 0.41s)
  • python -B tests/startup_image_sample_l_check.py — exit 0
  • python -B tests/startup_gfx2hlsl_sdwa_check.py — exit 0 (PASS)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123626383 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#issuecomment-7123626383). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T06:08:33Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at `7fb2c893`: - `cmake --preset dev` + `ctest --preset dev -R "^(startup_image_sample_l|startup_gfx2hlsl_sdwa)$"` — **2/2 PASS** (`startup_image_sample_l` `0.16s`, `startup_gfx2hlsl_sdwa` `0.39s`) - `cmake --preset release` (`/O2`) + `ctest --preset release -R "^(startup_image_sample_l|startup_gfx2hlsl_sdwa)$"` — **2/2 PASS** (`startup_image_sample_l` `0.17s`, `startup_gfx2hlsl_sdwa` `0.41s`) - `python -B tests/startup_image_sample_l_check.py` — **exit 0** - `python -B tests/startup_gfx2hlsl_sdwa_check.py` — **exit 0** (`PASS`)
chatgpt-codex-connector[bot commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:52:28Z.

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

@@ -610,6 +610,16 @@ def image(self, ops, mods, how):
         else:
             r = reg_range(coords)
             cs = ['v%d' % n for n in range(r[1], r[2] + 1)]
+        lod = None
+        if how == 'l':
+            # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives
+            # would add dwords or modifiers this lowering does not read, so they are refused.
+            for m in mods:
+                if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')):
+                    raise Unsupported('image_sample_l modifier %s' % m)

P2 Badge Reject packed A16 addresses before lowering

For a valid gfx1013 image_sample_l ... a16 instruction, the MIMG decoder in tools/disasm_rdna2.py currently omits the a16 modifier and reports a full-float address range, so this guard accepts the unsupported encoding. I reproduced a source address of v[0:1] ... a16 producing SampleLevel(q0, float2(F(v0), F(v1)), F(v2)): the packed FP16 coordinates are interpreted as FP32, and an unrelated register supplies the LOD. The parent commit rejects this instruction, whereas the new handler silently generates incorrect sampling code. Expose and reject the A16 modifier, or check its encoding bit before accepting this lowering, until packed addresses are implemented.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676051509 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#discussion_r4676051509). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:52:28Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 619 ~~~~diff @@ -610,6 +610,16 @@ def image(self, ops, mods, how): else: r = reg_range(coords) cs = ['v%d' % n for n in range(r[1], r[2] + 1)] + lod = None + if how == 'l': + # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives + # would add dwords or modifiers this lowering does not read, so they are refused. + for m in mods: + if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')): + raise Unsupported('image_sample_l modifier %s' % m) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Reject packed A16 addresses before lowering** For a valid gfx1013 `image_sample_l ... a16` instruction, the MIMG decoder in `tools/disasm_rdna2.py` currently omits the `a16` modifier and reports a full-float address range, so this guard accepts the unsupported encoding. I reproduced a source address of `v[0:1] ... a16` producing `SampleLevel(q0, float2(F(v0), F(v1)), F(v2))`: the packed FP16 coordinates are interpreted as FP32, and an unrelated register supplies the LOD. The parent commit rejects this instruction, whereas the new handler silently generates incorrect sampling code. Expose and reject the A16 modifier, or check its encoding bit before accepting this lowering, until packed addresses are implemented. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:54:12Z.

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

@@ -610,6 +610,16 @@ def image(self, ops, mods, how):
         else:
             r = reg_range(coords)
             cs = ['v%d' % n for n in range(r[1], r[2] + 1)]
+        lod = None
+        if how == 'l':
+            # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives
+            # would add dwords or modifiers this lowering does not read, so they are refused.
+            for m in mods:
+                if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')):
+                    raise Unsupported('image_sample_l modifier %s' % m)

Fixed in 544a0cb6

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676062810 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#discussion_r4676062810). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:54:12Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 619 ~~~~diff @@ -610,6 +610,16 @@ def image(self, ops, mods, how): else: r = reg_range(coords) cs = ['v%d' % n for n in range(r[1], r[2] + 1)] + lod = None + if how == 'l': + # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives + # would add dwords or modifiers this lowering does not read, so they are refused. + for m in mods: + if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')): + raise Unsupported('image_sample_l modifier %s' % m) ~~~~ --- Fixed in 544a0cb6
chatgpt-codex-connector[bot commented 2026-11-24 06:50:45 +00:00 (Migrated from github.com)

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

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

@@ -610,6 +610,16 @@ def image(self, ops, mods, how):
         else:
             r = reg_range(coords)
             cs = ['v%d' % n for n in range(r[1], r[2] + 1)]
+        lod = None
+        if how == 'l':
+            # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives
+            # would add dwords or modifiers this lowering does not read, so they are refused.
+            for m in mods:
+                if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')):
+                    raise Unsupported('image_sample_l modifier %s' % m)

P2 Badge Reject TFE encodings before lowering explicit-LOD samples

For a valid image_sample_l ... dmask:0x1 ... tfe, the decoder still omits TFE (word 0 bit 16), so this modifier whitelist accepts an encoding whose extra status result is not modeled. A source-built gfx1013 sample with destination v[4:5] translates to an assignment to v4 only; a subsequent check of the status in v5 therefore reads its previous value instead of the sample status. The parent rejected this instruction. Expose and reject tfe, or inspect its encoding bit, until the extra result is lowered.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676097633 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#discussion_r4676097633). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:58:31Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 619 ~~~~diff @@ -610,6 +610,16 @@ def image(self, ops, mods, how): else: r = reg_range(coords) cs = ['v%d' % n for n in range(r[1], r[2] + 1)] + lod = None + if how == 'l': + # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives + # would add dwords or modifiers this lowering does not read, so they are refused. + for m in mods: + if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')): + raise Unsupported('image_sample_l modifier %s' % m) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Reject TFE encodings before lowering explicit-LOD samples** For a valid `image_sample_l ... dmask:0x1 ... tfe`, the decoder still omits TFE (word 0 bit 16), so this modifier whitelist accepts an encoding whose extra status result is not modeled. A source-built gfx1013 sample with destination `v[4:5]` translates to an assignment to `v4` only; a subsequent check of the status in `v5` therefore reads its previous value instead of the sample status. The parent rejected this instruction. Expose and reject `tfe`, or inspect its encoding bit, until the extra result is lowered. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 06:50:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:59:46Z.

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

@@ -610,6 +610,16 @@ def image(self, ops, mods, how):
         else:
             r = reg_range(coords)
             cs = ['v%d' % n for n in range(r[1], r[2] + 1)]
+        lod = None
+        if how == 'l':
+            # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives
+            # would add dwords or modifiers this lowering does not read, so they are refused.
+            for m in mods:
+                if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')):
+                    raise Unsupported('image_sample_l modifier %s' % m)

Fixed in 30fa57b4

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676105318 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#discussion_r4676105318). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:59:46Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 619 ~~~~diff @@ -610,6 +610,16 @@ def image(self, ops, mods, how): else: r = reg_range(coords) cs = ['v%d' % n for n in range(r[1], r[2] + 1)] + lod = None + if how == 'l': + # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives + # would add dwords or modifiers this lowering does not read, so they are refused. + for m in mods: + if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')): + raise Unsupported('image_sample_l modifier %s' % m) ~~~~ --- Fixed in 30fa57b4
tedin7 commented 2026-11-24 06:50:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:03:15Z.

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

@@ -610,6 +610,16 @@ def image(self, ops, mods, how):
         else:
             r = reg_range(coords)
             cs = ['v%d' % n for n in range(r[1], r[2] + 1)]
+        lod = None
+        if how == 'l':
+            # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives
+            # would add dwords or modifiers this lowering does not read, so they are refused.
+            for m in mods:
+                if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')):
+                    raise Unsupported('image_sample_l modifier %s' % m)

Fixed in 7fb2c893 (tfe plus every other unmodelled MIMG bit: lwe, d16, r128, unorm, reserved bits, non-2D/3D dims; one llvm-mc-built negative fixture each).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676128496 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1258#discussion_r4676128496). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T06:03:15Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 619 ~~~~diff @@ -610,6 +610,16 @@ def image(self, ops, mods, how): else: r = reg_range(coords) cs = ['v%d' % n for n in range(r[1], r[2] + 1)] + lod = None + if how == 'l': + # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives + # would add dwords or modifiers this lowering does not read, so they are refused. + for m in mods: + if not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc')): + raise Unsupported('image_sample_l modifier %s' % m) ~~~~ --- Fixed in 7fb2c893 (tfe plus every other unmodelled MIMG bit: lwe, d16, r128, unorm, reserved bits, non-2D/3D dims; one llvm-mc-built negative fixture each).
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!1251
No description provided.