startup: lower image_sample_c and image_sample_c_lz on a 2D array #1704

Merged
tedin7 merged 3 commits from upstream-pr/1711 into main 2026-11-24 19:13:12 +00:00
tedin7 commented 2026-11-24 17:35:46 +00:00 (Migrated from github.com)

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


Part of the refusal triage in #870. No open issue or pull request covers this form.

Change

image_sample_c and image_sample_c_lz on dim:SQ_RSRC_IMG_2D_ARRAY (the shadow-cascade form) were refused with image_sample_c[_lz] on SQ_RSRC_IMG_2D_ARRAY. The address dwords are the reference, u, v and the slice. The lowering binds a Texture2DArray<float4> (manifest kind tex2da) and emits:

tex.SampleCmpLevelZero(smp, float3(u, v, slice), reference)

It uses the same constant comparison sampler as the 2D form. Unchanged: the sampler profile, dmask:0x1, the modifier refusals, MAX_LOD 0 for the implicit image_sample_c, and image_sample_c_l (refused, shader model 6.7). The slice is converted the way image_sample converts it on the same type. Only tools/startup/gfx2hlsl.py image_compare changes (+12/-7); other open PRs on that file edit other hunks.

Verification

tests/startup_image_sample_c_check.py gains eight source-built fixtures (array, array_nsa, array_c, array_c_full, array_c_l, array_dmask3, array_offset, array_unorm) with words checked against llvm-mc-19. It requires the exact call (reference v0 at (v1, v2), slice v3; NSA [v3, v0, v1, v2] reference v3, slice v2), the Texture2DArray declaration and the tex2da manifest line.

Linux (1715ef09):

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

Seven edited array lowerings must fail the exact call check (slice dropped, slice from the reference register, slice from the wrong register, slice exchanged with v, reference swapped with u, plain Texture2D, SampleCmp); all seven fail. Local mutations of tools/startup/gfx2hlsl.py ('tex2da' -> 'tex2d' and slice register cs[3] -> cs[2]) each make tests/startup_image_sample_c_check.py fail; the tree was restored after each. Also run and passing on Linux: startup_image_2d_array_check.py, startup_image_sample_l_check.py, startup_image_3d_check.py, startup_gfx2hlsl_smem_offset_check.py, startup_translator_check.py, docs_links_check.py, bidi_controls_check.py, git diff --check origin/main...HEAD.

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 1715ef09:

  • Debug (--preset dev):
    • cmake --build --preset dev --target startup_sampler_comparison_check offscreen_check -- -j 6 (3.36s)
    • ctest --preset dev -R '^(startup_image_sample_c|startup_sampler_comparison|startup_image_2d_array_controls|startup_image_2d_array_warp|startup_image_sample_l|startup_image_3d_controls|startup_image_3d_warp|startup_image_load_mip_warp|startup_gfx2hlsl_smem_offset|startup_translator)$' --parallel 4 --no-tests=error --output-on-failure: 10/10 passed (3.20s)
  • Release /O2 (--preset release):
    • cmake --build --preset release --target startup_sampler_comparison_check offscreen_check -- -j 6 (1.11s)
    • ctest --preset release -R '^(startup_image_sample_c|startup_sampler_comparison|startup_image_2d_array_controls|startup_image_2d_array_warp|startup_image_sample_l|startup_image_3d_controls|startup_image_3d_warp|startup_image_load_mip_warp|startup_gfx2hlsl_smem_offset|startup_translator)$' --parallel 4 --no-tests=error --output-on-failure: 10/10 passed (3.20s)

What this does not establish

  • No draw runs a translated 2D-array depth comparison yet: the compare result of this form on WARP or hardware is not measured, and the generated 2D-array comparison HLSL was not compiled with DXC or FXC.
  • Whether any shader in the loading-screen cache uses this form is unknown: the refusal breakdown on #870 does not list it. It is a refusal that remains on main, not one of the 29 counted there.
  • A single-slice view bound to an array declaration is not covered.
  • A 3-register array address cannot be built (llvm-mc rejects it), so that refusal path is untested.

Also checked

The SQ_RSRC_IMG_1D refusals counted on #870 (2 of 29) use the text image dimension SQ_RSRC_IMG_1D, which main no longer produces since #1630 lowers a one-coordinate image_sample. A stale cache or an older build would still show it. 1D image_sample_lz, image_sample_l and image_load are still refused with unverified 1D image sample address or modifiers; which opcode the two shaders use is not stated on #870.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6587743219 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1711). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:35:46Z. --- Part of the refusal triage in #870. No open issue or pull request covers this form. ## Change `image_sample_c` and `image_sample_c_lz` on `dim:SQ_RSRC_IMG_2D_ARRAY` (the shadow-cascade form) were refused with `image_sample_c[_lz] on SQ_RSRC_IMG_2D_ARRAY`. The address dwords are the reference, u, v and the slice. The lowering binds a `Texture2DArray<float4>` (manifest kind `tex2da`) and emits: ``` tex.SampleCmpLevelZero(smp, float3(u, v, slice), reference) ``` It uses the same constant comparison sampler as the 2D form. Unchanged: the sampler profile, `dmask:0x1`, the modifier refusals, MAX_LOD 0 for the implicit `image_sample_c`, and `image_sample_c_l` (refused, shader model 6.7). The slice is converted the way `image_sample` converts it on the same type. Only `tools/startup/gfx2hlsl.py` `image_compare` changes (+12/-7); other open PRs on that file edit other hunks. ## Verification `tests/startup_image_sample_c_check.py` gains eight source-built fixtures (`array`, `array_nsa`, `array_c`, `array_c_full`, `array_c_l`, `array_dmask3`, `array_offset`, `array_unorm`) with words checked against `llvm-mc-19`. It requires the exact call (reference v0 at (v1, v2), slice v3; NSA `[v3, v0, v1, v2]` reference v3, slice v2), the `Texture2DArray` declaration and the `tex2da` manifest line. Linux (`1715ef09`): ``` python3 -B tests/startup_image_sample_c_check.py PASS python3 -B tests/startup_image_sample_c_check.py binary llvm-mc-19 fixture words match llvm-mc ``` Seven edited array lowerings must fail the exact call check (slice dropped, slice from the reference register, slice from the wrong register, slice exchanged with v, reference swapped with u, plain `Texture2D`, `SampleCmp`); all seven fail. Local mutations of `tools/startup/gfx2hlsl.py` (`'tex2da' -> 'tex2d'` and slice register `cs[3] -> cs[2]`) each make `tests/startup_image_sample_c_check.py` fail; the tree was restored after each. Also run and passing on Linux: `startup_image_2d_array_check.py`, `startup_image_sample_l_check.py`, `startup_image_3d_check.py`, `startup_gfx2hlsl_smem_offset_check.py`, `startup_translator_check.py`, `docs_links_check.py`, `bidi_controls_check.py`, `git diff --check origin/main...HEAD`. Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `1715ef09`: - **Debug (`--preset dev`)**: - `cmake --build --preset dev --target startup_sampler_comparison_check offscreen_check -- -j 6` (`3.36s`) - `ctest --preset dev -R '^(startup_image_sample_c|startup_sampler_comparison|startup_image_2d_array_controls|startup_image_2d_array_warp|startup_image_sample_l|startup_image_3d_controls|startup_image_3d_warp|startup_image_load_mip_warp|startup_gfx2hlsl_smem_offset|startup_translator)$' --parallel 4 --no-tests=error --output-on-failure`: **10/10 passed** (`3.20s`) - **Release `/O2` (`--preset release`)**: - `cmake --build --preset release --target startup_sampler_comparison_check offscreen_check -- -j 6` (`1.11s`) - `ctest --preset release -R '^(startup_image_sample_c|startup_sampler_comparison|startup_image_2d_array_controls|startup_image_2d_array_warp|startup_image_sample_l|startup_image_3d_controls|startup_image_3d_warp|startup_image_load_mip_warp|startup_gfx2hlsl_smem_offset|startup_translator)$' --parallel 4 --no-tests=error --output-on-failure`: **10/10 passed** (`3.20s`) ## What this does not establish - No draw runs a translated 2D-array depth comparison yet: the compare result of this form on WARP or hardware is not measured, and the generated 2D-array comparison HLSL was not compiled with DXC or FXC. - Whether any shader in the loading-screen cache uses this form is unknown: the refusal breakdown on #870 does not list it. It is a refusal that remains on main, not one of the 29 counted there. - A single-slice view bound to an array declaration is not covered. - A 3-register array address cannot be built (`llvm-mc` rejects it), so that refusal path is untested. ## Also checked The `SQ_RSRC_IMG_1D` refusals counted on #870 (2 of 29) use the text `image dimension SQ_RSRC_IMG_1D`, which main no longer produces since #1630 lowers a one-coordinate `image_sample`. A stale cache or an older build would still show it. 1D `image_sample_lz`, `image_sample_l` and `image_load` are still refused with `unverified 1D image sample address or modifiers`; which opcode the two shaders use is not stated on #870. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 18:02:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:45:51Z.


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-24T17:47:46.556464Z 1715ef0 Draft marked ready
ℹ️ 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:7139669554 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1711#issuecomment-7139669554). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T17:45:51Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"1715ef09440ce2cf8c8eb3f0e51c5f1e8e6c533a","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-24T17:47:46.556464Z">2026-11-24T17:47:46.556464Z</relative-time> | `1715ef0` | Draft marked ready | <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>
R0Y00 commented 2026-11-24 19:01:42 +00:00 (Migrated from github.com)

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


The synthetic encodings and generated slice/address checks pass. Please extend the existing 2D-array fixture with two slices with different depths and a single reference between them. Run the translated comparison on WARP and one physical adapter, and require an always-slice-zero or swapped-slice control to differ. That will also verify the tex2da/comparison-sampler binding through execution.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7141160652 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1711#issuecomment-7141160652). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T18:47:40Z. --- The synthetic encodings and generated slice/address checks pass. Please extend the existing 2D-array fixture with two slices with different depths and a single reference between them. Run the translated comparison on WARP and one physical adapter, and require an always-slice-zero or swapped-slice control to differ. That will also verify the tex2da/comparison-sampler binding through execution.
upstream-sync closed this pull request 2026-11-24 20:00:25 +00:00
tedin7 commented 2026-11-24 20:01:16 +00:00 (Migrated from github.com)

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


@R0Y00 Extended the existing 2D-array fixture in 439333acd2dcbbdd4f9f99bb0aaba500a75ae681 to draw and read back translated 2D-array depth comparisons through tex2da + smpc bindings:

  • Fixture (tests/startup_image_3d.cpp, tests/startup_image_2d_array_check.py):

    • When --startup-image-2d-array receives a comparison sampler manifest line (smpc), check_startup_image_3d binds a 2x2 two-slice DXGI_FORMAT_R32_FLOAT Texture2DArray holding the fixture's red channel as depth: at (u=0.75, v=0.25) (texel (1, 0)), slice 0 = 0.25 and slice 1 = 0.75.
    • Added source-built gfx1013 pixel stages for both image_sample_c_lz and image_sample_c (MAX_LOD 0) with a single reference 0.5 between the two slice depths and manifest sampler smpc 0 0x8001012 0x0 0x0 0x0 (point clamp, LESS, TRUNC_COORD=1).
    • Through D3D12 (offscreen_check --startup-image-2d-array with DXC ps_6_0 and FXC ps_5_1), slices 0 / 0.25 read back 0.0 (00000000,00000000,00000000,00000000) and slices 1 / 0.75 read back 1.0 (3f800000,3f800000,3f800000,3f800000), checking debug_errors=0 debug_warnings=0 when the debug layer is enabled.
    • Negative controls (required to fail with the opposite comparison result for both image_sample_c_lz and image_sample_c, DXC and FXC):
      • always slice 0 (float3(F(v1), F(v2), 0.0)): drawn at z=1 expecting 1.0, fails reading actual=00000000,00000000,00000000,00000000.
      • swapped slice 0->1 / swapped slice 1->0 (float3(F(v1), F(v2), 1.0 - F(v3))): drawn at z=0 expecting 0.0 fails reading actual=3f800000,3f800000,3f800000,3f800000; drawn at z=1 expecting 1.0 fails reading actual=00000000,00000000,00000000,00000000.
  • Verified locally:

    • Linux (llvm-mc-19):
      • python3 -B tests/startup_image_2d_array_check.py — PASS (image_sample_c[_lz]: Texture2DArray r0, r0.SampleCmpLevelZero(q0, float3(F(v1), F(v2), F(v3)), F(v0)) with v3 = ud1; manifest srv 0 tex2da, smpc 0 0x8001012 0x0 0x0 0x0)
      • python3 -B tests/startup_image_2d_array_check.py binary llvm-mc-19 — PASS (fixture words match llvm-mc)
      • python3 -B tests/startup_image_sample_c_check.py & binary llvm-mc-19 — PASS
      • python3 -B tests/docs_links_check.py, python3 -B tests/bidi_controls_check.py, git diff --check — PASS
    • Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at 439333acd2dcbbdd4f9f99bb0aaba500a75ae681:
      • Debug (--preset dev): cmake --build --preset dev --target offscreen_check startup_sampler_comparison_check -- -j 8 (4.91s), ctest --preset dev -R '^(startup_image_2d_array_|startup_image_3d_|startup_inline_sampler_|startup_image_sample_c$|startup_sampler_comparison$)' --parallel 6 --no-tests=error --output-on-failure — 11/11 passed (5.84s; startup_image_2d_array_warp 5.76s).
      • Release /O2 (--preset release): cmake --build --preset release --target offscreen_check startup_sampler_comparison_check -- -j 8 (2.67s), ctest --preset release -R '^(startup_image_2d_array_|startup_image_3d_|startup_inline_sampler_|startup_image_sample_c$|startup_sampler_comparison$)' --parallel 6 --no-tests=error --output-on-failure — 11/11 passed (5.77s; startup_image_2d_array_warp 5.68s).
    • GitHub Actions CI: 3/3 checks green (Assemble and translate gfx1013 fixtures with llvm-mc-15, Run platform-independent Python checks on Linux, Build and test on Windows).
    • Physical adapter note: our Windows test VM only has WARP / a virtual display-only controller (no physical GPU adapter), so only WARP was executed here. startup_image_2d_array_hardware is registered in CTest and ready to confirm on a physical adapter (ctest --preset release --no-tests=error -R '^startup_image_2d_array_hardware$' -V).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7141734849 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1711#issuecomment-7141734849). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:11:34Z. --- @R0Y00 Extended the existing 2D-array fixture in `439333acd2dcbbdd4f9f99bb0aaba500a75ae681` to draw and read back translated 2D-array depth comparisons through `tex2da` + `smpc` bindings: - **Fixture (`tests/startup_image_3d.cpp`, `tests/startup_image_2d_array_check.py`)**: - When `--startup-image-2d-array` receives a comparison sampler manifest line (`smpc`), `check_startup_image_3d` binds a 2x2 two-slice `DXGI_FORMAT_R32_FLOAT` `Texture2DArray` holding the fixture's red channel as depth: at `(u=0.75, v=0.25)` (texel `(1, 0)`), **slice 0 = `0.25`** and **slice 1 = `0.75`**. - Added source-built gfx1013 pixel stages for both `image_sample_c_lz` and `image_sample_c` (`MAX_LOD 0`) with a single reference **`0.5`** between the two slice depths and manifest sampler `smpc 0 0x8001012 0x0 0x0 0x0` (point clamp, `LESS`, `TRUNC_COORD=1`). - Through D3D12 (`offscreen_check --startup-image-2d-array` with DXC `ps_6_0` and FXC `ps_5_1`), slices `0` / `0.25` read back `0.0` (`00000000,00000000,00000000,00000000`) and slices `1` / `0.75` read back `1.0` (`3f800000,3f800000,3f800000,3f800000`), checking `debug_errors=0 debug_warnings=0` when the debug layer is enabled. - **Negative controls (required to fail with the opposite comparison result for both `image_sample_c_lz` and `image_sample_c`, DXC and FXC)**: - `always slice 0` (`float3(F(v1), F(v2), 0.0)`): drawn at `z=1` expecting `1.0`, fails reading `actual=00000000,00000000,00000000,00000000`. - `swapped slice 0->1` / `swapped slice 1->0` (`float3(F(v1), F(v2), 1.0 - F(v3))`): drawn at `z=0` expecting `0.0` fails reading `actual=3f800000,3f800000,3f800000,3f800000`; drawn at `z=1` expecting `1.0` fails reading `actual=00000000,00000000,00000000,00000000`. - **Verified locally**: - Linux (`llvm-mc-19`): - `python3 -B tests/startup_image_2d_array_check.py` — PASS (`image_sample_c[_lz]: Texture2DArray r0, r0.SampleCmpLevelZero(q0, float3(F(v1), F(v2), F(v3)), F(v0)) with v3 = ud1; manifest srv 0 tex2da, smpc 0 0x8001012 0x0 0x0 0x0`) - `python3 -B tests/startup_image_2d_array_check.py binary llvm-mc-19` — PASS (`fixture words match llvm-mc`) - `python3 -B tests/startup_image_sample_c_check.py` & `binary llvm-mc-19` — PASS - `python3 -B tests/docs_links_check.py`, `python3 -B tests/bidi_controls_check.py`, `git diff --check` — PASS - Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at `439333acd2dcbbdd4f9f99bb0aaba500a75ae681`: - Debug (`--preset dev`): `cmake --build --preset dev --target offscreen_check startup_sampler_comparison_check -- -j 8` (`4.91s`), `ctest --preset dev -R '^(startup_image_2d_array_|startup_image_3d_|startup_inline_sampler_|startup_image_sample_c$|startup_sampler_comparison$)' --parallel 6 --no-tests=error --output-on-failure` — **11/11 passed** (`5.84s`; `startup_image_2d_array_warp` `5.76s`). - Release `/O2` (`--preset release`): `cmake --build --preset release --target offscreen_check startup_sampler_comparison_check -- -j 8` (`2.67s`), `ctest --preset release -R '^(startup_image_2d_array_|startup_image_3d_|startup_inline_sampler_|startup_image_sample_c$|startup_sampler_comparison$)' --parallel 6 --no-tests=error --output-on-failure` — **11/11 passed** (`5.77s`; `startup_image_2d_array_warp` `5.68s`). - GitHub Actions CI: 3/3 checks green (`Assemble and translate gfx1013 fixtures` with `llvm-mc-15`, `Run platform-independent Python checks on Linux`, `Build and test on Windows`). - **Physical adapter note**: our Windows test VM only has WARP / a virtual display-only controller (no physical GPU adapter), so only WARP was executed here. `startup_image_2d_array_hardware` is registered in CTest and ready to confirm on a physical adapter (`ctest --preset release --no-tests=error -R '^startup_image_2d_array_hardware$' -V`). AI-assisted; commands listed were executed locally.
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!1704
No description provided.