startup: lower 1D image_load, image_load_mip, image_sample_lz and image_sample_l #1717

Closed
tedin7 wants to merge 2 commits from upstream-pr/1724 into main
tedin7 commented 2026-11-24 17:52:08 +00:00 (Migrated from github.com)

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


Part of the refusal triage in #870 (the image dimension SQ_RSRC_IMG_1D refusals, 2 of the 29 shaders in the GTX 1660 SUPER cache). No open pull request covers the remaining 1D forms: #1630 (merged) lowered only the implicit image_sample with one coordinate.

Change

A 1D image takes one address component, x. In image() of tools/startup/gfx2hlsl.py:

image_load        -> Texture1D.Load(int2(x, 0))
image_load_mip    -> Texture1D.Load(int2(x, mip))          address [x, mip]
image_sample_lz   -> Texture1D.SampleLevel(smp, x, 0)
image_sample_l    -> Texture1D.SampleLevel(smp, x, level)  address [x, level]

The mip and the level are the last address register, so an NSA list such as [v3, v1] reads x from v3. The 1D sample check now accepts glc, slc and dlc next to dim and dmask (they do not change the value); every other modifier, an empty dmask and a wrong address count are refused with unverified 1D image address or modifiers (the message no longer says "sample"). Compare, gather and offset forms on a 1D image are unchanged and refused. The axes count is now defined once for all dimensions.

I did not touch the runtime: tex1d binding and upload come from #1630.

Test

New tests/startup_image_1d_check.py (CTest startup_image_1d, also in the Windows pixel-binary job with llvm-mc-15): 14 source-built fixtures with words checked against llvm-mc-19. It requires the exact call for each form, the Texture1D<float4> declaration and the tex1d manifest line, and the refusals. tests/startup_image_sample_l_check.py no longer expects 1D to be refused.

python3 -B tests/startup_image_1d_check.py                       PASS
python3 -B tests/startup_image_1d_check.py binary llvm-mc-19     fixture words match llvm-mc

Four local mutations of the lowering each make the check fail, and the tree was restored after each: the mip read as 0, the level taken from the first register, unorm accepted on 1D, the texture bound as tex2d. Also run and passing: startup_image_sample_l_check, _sample_c_check, _3d_check, _2d_array_check, _load_mip_check, startup_translator_check, startup_gfx2hlsl_smem_offset_check, docs_links_check, bidi_controls_check and git diff --check. A merge against the heads of #1711, #1707 and #1699 has no conflicts (the docs note is placed so it does not touch the lines #1711 edits).

What this does not establish

  • No draw runs a 1D load, mip load or explicit-level sample, and I have no Windows, DXC or GPU here: the forms are checked on the generated HLSL text only, and the HLSL was not compiled with DXC or FXC.
  • The wrong-address-count refusal for load, image_sample and image_sample_lz cannot be reached from assembled code (llvm-mc rejects such addresses), so removing that clause is not caught; the same refusal is kept for the l and load_mip forms by their own checks.
  • Which opcodes the two refused shaders on #870 use is not stated there, so whether this clears them is unknown; their refusal text (image dimension SQ_RSRC_IMG_1D) is the pre-#1630 one and may come from a stale cache.

AI-assisted. Commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588026073 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1724). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:52:08Z. --- Part of the refusal triage in #870 (the `image dimension SQ_RSRC_IMG_1D` refusals, 2 of the 29 shaders in the GTX 1660 SUPER cache). No open pull request covers the remaining 1D forms: #1630 (merged) lowered only the implicit `image_sample` with one coordinate. ## Change A 1D image takes one address component, x. In `image()` of `tools/startup/gfx2hlsl.py`: ``` image_load -> Texture1D.Load(int2(x, 0)) image_load_mip -> Texture1D.Load(int2(x, mip)) address [x, mip] image_sample_lz -> Texture1D.SampleLevel(smp, x, 0) image_sample_l -> Texture1D.SampleLevel(smp, x, level) address [x, level] ``` The mip and the level are the last address register, so an NSA list such as `[v3, v1]` reads x from `v3`. The 1D sample check now accepts `glc`, `slc` and `dlc` next to `dim` and `dmask` (they do not change the value); every other modifier, an empty `dmask` and a wrong address count are refused with `unverified 1D image address or modifiers` (the message no longer says "sample"). Compare, gather and offset forms on a 1D image are unchanged and refused. The `axes` count is now defined once for all dimensions. I did not touch the runtime: `tex1d` binding and upload come from #1630. ## Test New `tests/startup_image_1d_check.py` (CTest `startup_image_1d`, also in the Windows pixel-binary job with `llvm-mc-15`): 14 source-built fixtures with words checked against `llvm-mc-19`. It requires the exact call for each form, the `Texture1D<float4>` declaration and the `tex1d` manifest line, and the refusals. `tests/startup_image_sample_l_check.py` no longer expects 1D to be refused. ``` python3 -B tests/startup_image_1d_check.py PASS python3 -B tests/startup_image_1d_check.py binary llvm-mc-19 fixture words match llvm-mc ``` Four local mutations of the lowering each make the check fail, and the tree was restored after each: the mip read as 0, the level taken from the first register, `unorm` accepted on 1D, the texture bound as `tex2d`. Also run and passing: `startup_image_sample_l_check`, `_sample_c_check`, `_3d_check`, `_2d_array_check`, `_load_mip_check`, `startup_translator_check`, `startup_gfx2hlsl_smem_offset_check`, `docs_links_check`, `bidi_controls_check` and `git diff --check`. A merge against the heads of #1711, #1707 and #1699 has no conflicts (the docs note is placed so it does not touch the lines #1711 edits). ## What this does not establish - No draw runs a 1D load, mip load or explicit-level sample, and I have no Windows, DXC or GPU here: the forms are checked on the generated HLSL text only, and the HLSL was not compiled with DXC or FXC. - The wrong-address-count refusal for `load`, `image_sample` and `image_sample_lz` cannot be reached from assembled code (`llvm-mc` rejects such addresses), so removing that clause is not caught; the same refusal is kept for the `l` and `load_mip` forms by their own checks. - Which opcodes the two refused shaders on #870 use is not stated there, so whether this clears them is unknown; their refusal text (`image dimension SQ_RSRC_IMG_1D`) is the pre-#1630 one and may come from a stale cache. AI-assisted. Commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 18:02:48 +00:00
tedin7 commented 2026-11-24 18:03:00 +00:00 (Migrated from github.com)

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


Closing this draft: #1722 already covers 1D image_sample_lz / image_sample_l from #1721. Will only revisit non-overlapping 1D image_load / image_load_mip after #1722 lands if still needed. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139879349 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1724#issuecomment-7139879349). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:54:34Z. --- Closing this draft: #1722 already covers 1D `image_sample_lz` / `image_sample_l` from #1721. Will only revisit non-overlapping 1D `image_load` / `image_load_mip` after #1722 lands if still needed. 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!1717
No description provided.