shader: lower v_cubema/sc/tc/id_f32 and SQ_RSRC_IMG_CUBE in gfx2hlsl (Part of #1723) #2028

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

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


Part of #1723

What this unblocks: Run 20 census #6 (71/69 pairs): cube-map shaders no longer stop translation.

Lowers v_cubeid_f32, v_cubesc_f32, v_cubetc_f32 and v_cubema_f32 in tools/startup/gfx2hlsl.py through four helpers in the common preamble (major axis is z when |z| >= max(|x|,|y|), else y when |y| >= |x|, else x; face ids +x -x +y -y +z -z; ma is twice the major axis). Image ops with dim:SQ_RSRC_IMG_CUBE take (s, t, face) and declare a Texture2DArray<float4> (kind tex2da), the same path as SQ_RSRC_IMG_2D_ARRAY. Seamless filtering across face edges is not modelled.

Verification:

  • python3 -B tests/startup_gfx2hlsl_cube_check.py on the branch: gfx2hlsl cube: ok.
  • Same test against origin/main sources: fails with Unsupported on the first cube op.
  • Existing checks still pass: startup_gfx2hlsl_swap_check.py, _sdwa_check.py, _operand_count_check.py, _op_refusals_check.py, _cmp_class_check.py, _mad_check.py.
  • Test registered in CMakeLists.txt as startup_gfx2hlsl_cube.
  • Win2025 run: not executed here (Linux worker); the check is pure Python and compiles no HLSL.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593560001 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:31:57Z. --- Part of #1723 What this unblocks: Run 20 census #6 (71/69 pairs): cube-map shaders no longer stop translation. Lowers `v_cubeid_f32`, `v_cubesc_f32`, `v_cubetc_f32` and `v_cubema_f32` in `tools/startup/gfx2hlsl.py` through four helpers in the common preamble (major axis is z when |z| >= max(|x|,|y|), else y when |y| >= |x|, else x; face ids +x -x +y -y +z -z; `ma` is twice the major axis). Image ops with `dim:SQ_RSRC_IMG_CUBE` take (s, t, face) and declare a `Texture2DArray<float4>` (kind `tex2da`), the same path as `SQ_RSRC_IMG_2D_ARRAY`. Seamless filtering across face edges is not modelled. Verification: - `python3 -B tests/startup_gfx2hlsl_cube_check.py` on the branch: `gfx2hlsl cube: ok`. - Same test against `origin/main` sources: fails with `Unsupported` on the first cube op. - Existing checks still pass: `startup_gfx2hlsl_swap_check.py`, `_sdwa_check.py`, `_operand_count_check.py`, `_op_refusals_check.py`, `_cmp_class_check.py`, `_mad_check.py`. - Test registered in CMakeLists.txt as `startup_gfx2hlsl_cube`. - Win2025 run: not executed here (Linux worker); the check is pure Python and compiles no HLSL. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-25 00:05:03 +00:00 (Migrated from github.com)

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

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8dfaaeef7f

ℹ️ 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:6049178285 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#pullrequestreview-6049178285). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:39:00Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `8dfaaeef7f` <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:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:05Z.

Review: COMMENTED


No description provided.

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

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:07Z.

Review: COMMENTED


No description provided.

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

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:08Z.

Review: COMMENTED


No description provided.

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

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:10Z.

Review: COMMENTED


No description provided.

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

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:39: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-24T23:39:04.190072Z 8dfaaee 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:7147642341 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7147642341). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:39:05Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"8dfaaeef7f2c0a5bfe0e2fd87e11e45fb4693c19","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-24T23:39:04.190072Z">2026-11-24T23:39:04.190072Z</relative-time> | `8dfaaee` | 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>
denn0x commented 2026-11-25 01:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T00:55:05Z.


I checked the four helpers against the RDNA ISA pseudo-code for V_CUBEID/SC/TC/MA_F32. The major-axis order (z, then y, then x, with >=), the face ids, the sign rules for sc/tc and ma = 2 * major all match.

One small difference: the ISA compares |z| >= |x| && |z| >= |y| separately, while abs(z) >= max(abs(x), abs(y)) lets HLSL's max drop a NaN. A NaN in x can therefore pick a different face. Spelling out the two comparisons would match exactly.

The sample is the part I think is wrong. The compiler does not pass sc/tc straight to a CUBE sample. In a private executable's pixel programs (aggregate, decode only):

  • 417 programs sample dim:SQ_RSRC_IMG_CUBE;
  • in at least 250 of them, the coordinates come from v_rcp_f32 |ma|, then v_fmaak_f32 s, sc, rcp, 0x3fc00000 and the same for t, i.e. sc / |ma| + 1.5.

Since ma is twice the major axis, s and t lie in [1, 2], not [0, 1]. As a Texture2DArray sample:

  • with a clamp address mode, every texel read is the far edge of the face;
  • with wrap, the texel is right, but bilinear filtering wraps within the face instead of crossing to the neighbouring face;
  • the sampler's own address mode, which a cube sample ignores, starts to matter.

I have not run this on WARP. The failure follows from the coordinate range, and the test does not cover it because it only checks text.

Possible fixes, in order of effort:

  1. Subtract 1.0 from s and t when dim:SQ_RSRC_IMG_CUBE, and refuse a non-clamp, non-wrap sampler. This is still not seamless.
  2. Better: rebuild the direction from (s, t, face) and sample a TextureCube. This keeps seamless filtering and also needs the SRV to be created as a cube.

Either way, a value test that samples a small cube with distinct texels per face, through the exact 1.5 sequence, would pin it down. Comparing the helpers' values with the ISA pseudo-code on a set of directions (including ties and signed zeros) would also strengthen the test.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149021776 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7149021776). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T00:55:05Z. --- I checked the four helpers against the RDNA ISA pseudo-code for `V_CUBEID/SC/TC/MA_F32`. The major-axis order (z, then y, then x, with `>=`), the face ids, the sign rules for sc/tc and `ma = 2 * major` all match. One small difference: the ISA compares `|z| >= |x| && |z| >= |y|` separately, while `abs(z) >= max(abs(x), abs(y))` lets HLSL's `max` drop a NaN. A NaN in x can therefore pick a different face. Spelling out the two comparisons would match exactly. **The sample is the part I think is wrong.** The compiler does not pass sc/tc straight to a CUBE sample. In a private executable's pixel programs (aggregate, decode only): - 417 programs sample `dim:SQ_RSRC_IMG_CUBE`; - in at least 250 of them, the coordinates come from `v_rcp_f32 |ma|`, then `v_fmaak_f32 s, sc, rcp, 0x3fc00000` and the same for t, i.e. `sc / |ma| + 1.5`. Since `ma` is twice the major axis, `s` and `t` lie in [1, 2], not [0, 1]. As a `Texture2DArray` sample: - with a clamp address mode, every texel read is the far edge of the face; - with wrap, the texel is right, but bilinear filtering wraps within the face instead of crossing to the neighbouring face; - the sampler's own address mode, which a cube sample ignores, starts to matter. I have not run this on WARP. The failure follows from the coordinate range, and the test does not cover it because it only checks text. Possible fixes, in order of effort: 1. Subtract 1.0 from s and t when `dim:SQ_RSRC_IMG_CUBE`, and refuse a non-clamp, non-wrap sampler. This is still not seamless. 2. Better: rebuild the direction from (s, t, face) and sample a `TextureCube`. This keeps seamless filtering and also needs the SRV to be created as a cube. Either way, a value test that samples a small cube with distinct texels per face, through the exact `1.5` sequence, would pin it down. Comparing the helpers' values with the ISA pseudo-code on a set of directions (including ties and signed zeros) would also strengthen the test.
chatgpt-codex-connector[bot commented 2026-11-25 01:02:12 +00:00 (Migrated from github.com)

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

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

@@ -1104,13 +1104,15 @@ def image(self, ops, mods, how):
         dst = reg_range(ops[0])
         dim = [m for m in mods if m.startswith('dim:')][0][4:]
         dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0)
-        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'}
+        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da',
+                 'SQ_RSRC_IMG_CUBE': 'tex2da'}

P1 Badge Update the existing cube-refusal controls

Accepting this dimension breaks three existing pure-Python checks: tests/startup_image_sample_l_check.py:246 raises cube was accepted, tests/startup_image_3d_check.py:114 raises unverified image dimension accepted, and tests/startup_image_2d_array_check.py:249 raises image_load_mip on a cube accepted. All three pass against the parent translator and are still selected by .github/workflows/windows.yml:193-199; array draw mode also runs the failing controls before GPU work. Update these fixtures to verify the newly supported cube behavior alongside this mapping so the feature does not leave the existing test suite failing.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688073146 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#discussion_r4688073146). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:39:01Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1108 ~~~~diff @@ -1104,13 +1104,15 @@ def image(self, ops, mods, how): dst = reg_range(ops[0]) dim = [m for m in mods if m.startswith('dim:')][0][4:] dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0) - kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'} + kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da', + 'SQ_RSRC_IMG_CUBE': 'tex2da'} ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Update the existing cube-refusal controls** Accepting this dimension breaks three existing pure-Python checks: `tests/startup_image_sample_l_check.py:246` raises `cube was accepted`, `tests/startup_image_3d_check.py:114` raises `unverified image dimension accepted`, and `tests/startup_image_2d_array_check.py:249` raises `image_load_mip on a cube accepted`. All three pass against the parent translator and are still selected by `.github/workflows/windows.yml:193-199`; array draw mode also runs the failing controls before GPU work. Update these fixtures to verify the newly supported cube behavior alongside this mapping so the feature does not leave the existing test suite failing. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 01:02:12 +00:00 (Migrated from github.com)

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

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

@@ -1104,13 +1104,15 @@ def image(self, ops, mods, how):
         dst = reg_range(ops[0])
         dim = [m for m in mods if m.startswith('dim:')][0][4:]
         dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0)
-        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'}
+        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da',
+                 'SQ_RSRC_IMG_CUBE': 'tex2da'}
         if dim not in kinds:
             raise Unsupported('image dimension %s' % dim)
         # A 2D array takes the slice as its third address component, where a volume takes z. Sample and
         # Load on a Texture2DArray take it in the same place, so only the declared type differs.
         one = dim == 'SQ_RSRC_IMG_1D'
-        three = dim in ('SQ_RSRC_IMG_3D', 'SQ_RSRC_IMG_2D_ARRAY')
+        # A cube is addressed as six 2D slices: the cube instructions already produce s, t and the face id.
+        three = dim in ('SQ_RSRC_IMG_3D', 'SQ_RSRC_IMG_2D_ARRAY', 'SQ_RSRC_IMG_CUBE')

P1 Badge Remove the cube-coordinate bias before array sampling

For a cube shader using a clamped sampler, RDNA cube normalization produces s/t coordinates in [1,2] (SC / abs(MA) + 1.5), but this path feeds them unchanged into Texture2DArray, which expects normalized coordinates in [0,1]. A +X-face-center sample consequently becomes (1.5, 1.5, 0) and clamps to the face corner instead of sampling (0.5, 0.5, 0). This corrupts even interior samples, independently of the acknowledged seamless-filtering limitation. Subtract the cube-specific bias from s/t before Sample or SampleLevel, leaving the face and LOD unchanged.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688073153 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#discussion_r4688073153). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:39:01Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1115 ~~~~diff @@ -1104,13 +1104,15 @@ def image(self, ops, mods, how): dst = reg_range(ops[0]) dim = [m for m in mods if m.startswith('dim:')][0][4:] dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0) - kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'} + kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da', + 'SQ_RSRC_IMG_CUBE': 'tex2da'} if dim not in kinds: raise Unsupported('image dimension %s' % dim) # A 2D array takes the slice as its third address component, where a volume takes z. Sample and # Load on a Texture2DArray take it in the same place, so only the declared type differs. one = dim == 'SQ_RSRC_IMG_1D' - three = dim in ('SQ_RSRC_IMG_3D', 'SQ_RSRC_IMG_2D_ARRAY') + # A cube is addressed as six 2D slices: the cube instructions already produce s, t and the face id. + three = dim in ('SQ_RSRC_IMG_3D', 'SQ_RSRC_IMG_2D_ARRAY', 'SQ_RSRC_IMG_CUBE') ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Remove the cube-coordinate bias before array sampling** For a cube shader using a clamped sampler, RDNA cube normalization produces s/t coordinates in [1,2] (`SC / abs(MA) + 1.5`), but this path feeds them unchanged into `Texture2DArray`, which expects normalized coordinates in [0,1]. A +X-face-center sample consequently becomes `(1.5, 1.5, 0)` and clamps to the face corner instead of sampling `(0.5, 0.5, 0)`. This corrupts even interior samples, independently of the acknowledged seamless-filtering limitation. Subtract the cube-specific bias from s/t before `Sample` or `SampleLevel`, leaving the face and LOD unchanged. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 01:02:12 +00:00 (Migrated from github.com)

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

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

@@ -1104,13 +1104,15 @@ def image(self, ops, mods, how):
         dst = reg_range(ops[0])
         dim = [m for m in mods if m.startswith('dim:')][0][4:]
         dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0)
-        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'}
+        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da',
+                 'SQ_RSRC_IMG_CUBE': 'tex2da'}

P1 Badge Reinterpret cube SRVs before binding them as arrays

When the bound view is a normal D3D12_SRV_DIMENSION_TEXTURECUBE or TEXTURECUBEARRAY SRV, emitting tex2da makes the runtime bind a null resource. In src/startup_stubs/d3d12_draw.inl, lines 956-958 require TEXTURE2DARRAY for this kind, lines 976-978 copy the recorded cube descriptor unchanged, and lines 1009-1018 reject its differing dimension and clear the texture. Thus these newly accepted shaders cannot sample their actual cube resources. Add a cube-aware binding kind or convert the recorded cube view into an equivalent array view with the correct face and mip ranges.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688073162 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#discussion_r4688073162). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:39:01Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1108 ~~~~diff @@ -1104,13 +1104,15 @@ def image(self, ops, mods, how): dst = reg_range(ops[0]) dim = [m for m in mods if m.startswith('dim:')][0][4:] dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0) - kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'} + kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da', + 'SQ_RSRC_IMG_CUBE': 'tex2da'} ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Reinterpret cube SRVs before binding them as arrays** When the bound view is a normal `D3D12_SRV_DIMENSION_TEXTURECUBE` or `TEXTURECUBEARRAY` SRV, emitting `tex2da` makes the runtime bind a null resource. In `src/startup_stubs/d3d12_draw.inl`, lines 956-958 require `TEXTURE2DARRAY` for this kind, lines 976-978 copy the recorded cube descriptor unchanged, and lines 1009-1018 reject its differing dimension and clear the texture. Thus these newly accepted shaders cannot sample their actual cube resources. Add a cube-aware binding kind or convert the recorded cube view into an equivalent array view with the correct face and mip ranges. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 01:02:12 +00:00 (Migrated from github.com)

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

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

@@ -1700,6 +1702,8 @@ def declarations(self):
     'v_exp_f32': (1, 'exp2({0})'), 'v_log_f32': (1, 'log2({0})'), 'v_floor_f32': (1, 'floor({0})'), 'v_ceil_f32': (1, 'ceil({0})'),
     'v_trunc_f32': (1, 'trunc({0})'), 'v_fract_f32': (1, 'frac({0})'), 'v_rndne_f32': (1, 'round({0})'),
     'v_sin_f32': (1, 'sin({0} * 6.283185307)'), 'v_cos_f32': (1, 'cos({0} * 6.283185307)'),
+    'v_cubeid_f32': (3, 'cubeid({0}, {1}, {2})'), 'v_cubesc_f32': (3, 'cubesc({0}, {1}, {2})'),
+    'v_cubetc_f32': (3, 'cubetc({0}, {1}, {2})'), 'v_cubema_f32': (3, 'cubema({0}, {1}, {2})'),

P1 Badge Update the published cube-support documentation

This adds public startup-translator capabilities without the documentation update required by AGENTS.md. docs/experiments.md:11412 still explicitly lists cube image_sample_l among forms refused with Unsupported, and docs/startup-runtime.md:875-876 still says cube images are refused. Update the relevant README or experiments documentation with the accepted forms, reproduction command, and non-seamless filtering limitation so contributors can determine the actual supported scope.

AGENTS.md reference: AGENTS.md:L210-L211

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688073169 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#discussion_r4688073169). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:39:01Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1706 ~~~~diff @@ -1700,6 +1702,8 @@ def declarations(self): 'v_exp_f32': (1, 'exp2({0})'), 'v_log_f32': (1, 'log2({0})'), 'v_floor_f32': (1, 'floor({0})'), 'v_ceil_f32': (1, 'ceil({0})'), 'v_trunc_f32': (1, 'trunc({0})'), 'v_fract_f32': (1, 'frac({0})'), 'v_rndne_f32': (1, 'round({0})'), 'v_sin_f32': (1, 'sin({0} * 6.283185307)'), 'v_cos_f32': (1, 'cos({0} * 6.283185307)'), + 'v_cubeid_f32': (3, 'cubeid({0}, {1}, {2})'), 'v_cubesc_f32': (3, 'cubesc({0}, {1}, {2})'), + 'v_cubetc_f32': (3, 'cubetc({0}, {1}, {2})'), 'v_cubema_f32': (3, 'cubema({0}, {1}, {2})'), ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Update the published cube-support documentation** This adds public startup-translator capabilities without the documentation update required by `AGENTS.md`. `docs/experiments.md:11412` still explicitly lists cube `image_sample_l` among forms refused with `Unsupported`, and `docs/startup-runtime.md:875-876` still says cube images are refused. Update the relevant README or experiments documentation with the accepted forms, reproduction command, and non-seamless filtering limitation so contributors can determine the actual supported scope. AGENTS.md reference: [AGENTS.md:L210-L211](https://github.com/R0Y00/Xbox2Windows/blob/8dfaaeef7f2c0a5bfe0e2fd87e11e45fb4693c19/AGENTS.md#L210-L211) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-25 01:02:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:05Z.

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

@@ -1104,13 +1104,15 @@ def image(self, ops, mods, how):
         dst = reg_range(ops[0])
         dim = [m for m in mods if m.startswith('dim:')][0][4:]
         dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0)
-        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'}
+        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da',
+                 'SQ_RSRC_IMG_CUBE': 'tex2da'}

The three older refusal checks were already updated in 79c8ac9c (rebased); they pass locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688721186 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#discussion_r4688721186). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:56:05Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1108 ~~~~diff @@ -1104,13 +1104,15 @@ def image(self, ops, mods, how): dst = reg_range(ops[0]) dim = [m for m in mods if m.startswith('dim:')][0][4:] dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0) - kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'} + kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da', + 'SQ_RSRC_IMG_CUBE': 'tex2da'} ~~~~ --- The three older refusal checks were already updated in 79c8ac9c (rebased); they pass locally.
tedin7 commented 2026-11-25 01:02:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:07Z.

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

@@ -1104,13 +1104,15 @@ def image(self, ops, mods, how):
         dst = reg_range(ops[0])
         dim = [m for m in mods if m.startswith('dim:')][0][4:]
         dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0)
-        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'}
+        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da',
+                 'SQ_RSRC_IMG_CUBE': 'tex2da'}
         if dim not in kinds:
             raise Unsupported('image dimension %s' % dim)
         # A 2D array takes the slice as its third address component, where a volume takes z. Sample and
         # Load on a Texture2DArray take it in the same place, so only the declared type differs.
         one = dim == 'SQ_RSRC_IMG_1D'
-        three = dim in ('SQ_RSRC_IMG_3D', 'SQ_RSRC_IMG_2D_ARRAY')
+        # A cube is addressed as six 2D slices: the cube instructions already produce s, t and the face id.
+        three = dim in ('SQ_RSRC_IMG_3D', 'SQ_RSRC_IMG_2D_ARRAY', 'SQ_RSRC_IMG_CUBE')

Fixed in a678bc3c: cube s/t now lower as float3(s - 1.0, t - 1.0, face); check updated.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688721387 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#discussion_r4688721387). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:56:07Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1115 ~~~~diff @@ -1104,13 +1104,15 @@ def image(self, ops, mods, how): dst = reg_range(ops[0]) dim = [m for m in mods if m.startswith('dim:')][0][4:] dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0) - kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'} + kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da', + 'SQ_RSRC_IMG_CUBE': 'tex2da'} if dim not in kinds: raise Unsupported('image dimension %s' % dim) # A 2D array takes the slice as its third address component, where a volume takes z. Sample and # Load on a Texture2DArray take it in the same place, so only the declared type differs. one = dim == 'SQ_RSRC_IMG_1D' - three = dim in ('SQ_RSRC_IMG_3D', 'SQ_RSRC_IMG_2D_ARRAY') + # A cube is addressed as six 2D slices: the cube instructions already produce s, t and the face id. + three = dim in ('SQ_RSRC_IMG_3D', 'SQ_RSRC_IMG_2D_ARRAY', 'SQ_RSRC_IMG_CUBE') ~~~~ --- Fixed in a678bc3c: cube s/t now lower as float3(s - 1.0, t - 1.0, face); check updated.
tedin7 commented 2026-11-25 01:02:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:08Z.

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

@@ -1104,13 +1104,15 @@ def image(self, ops, mods, how):
         dst = reg_range(ops[0])
         dim = [m for m in mods if m.startswith('dim:')][0][4:]
         dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0)
-        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'}
+        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da',
+                 'SQ_RSRC_IMG_CUBE': 'tex2da'}

Fixed in a678bc3c: d3d12_draw.inl rebinds TEXTURECUBE and TEXTURECUBEARRAY views as TEXTURE2DARRAY (6 slices per cube). Needs a Windows build to run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688721612 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#discussion_r4688721612). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:56:08Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1108 ~~~~diff @@ -1104,13 +1104,15 @@ def image(self, ops, mods, how): dst = reg_range(ops[0]) dim = [m for m in mods if m.startswith('dim:')][0][4:] dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0) - kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'} + kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da', + 'SQ_RSRC_IMG_CUBE': 'tex2da'} ~~~~ --- Fixed in a678bc3c: d3d12_draw.inl rebinds TEXTURECUBE and TEXTURECUBEARRAY views as TEXTURE2DARRAY (6 slices per cube). Needs a Windows build to run.
tedin7 commented 2026-11-25 01:02:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:10Z.

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

@@ -1700,6 +1702,8 @@ def declarations(self):
     'v_exp_f32': (1, 'exp2({0})'), 'v_log_f32': (1, 'log2({0})'), 'v_floor_f32': (1, 'floor({0})'), 'v_ceil_f32': (1, 'ceil({0})'),
     'v_trunc_f32': (1, 'trunc({0})'), 'v_fract_f32': (1, 'frac({0})'), 'v_rndne_f32': (1, 'round({0})'),
     'v_sin_f32': (1, 'sin({0} * 6.283185307)'), 'v_cos_f32': (1, 'cos({0} * 6.283185307)'),
+    'v_cubeid_f32': (3, 'cubeid({0}, {1}, {2})'), 'v_cubesc_f32': (3, 'cubesc({0}, {1}, {2})'),
+    'v_cubetc_f32': (3, 'cubetc({0}, {1}, {2})'), 'v_cubema_f32': (3, 'cubema({0}, {1}, {2})'),

Fixed in a678bc3c: docs/startup-runtime.md and docs/experiments.md now list the accepted cube forms, the repro commands and the non-seamless limitation.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688721770 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#discussion_r4688721770). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:56:10Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1706 ~~~~diff @@ -1700,6 +1702,8 @@ def declarations(self): 'v_exp_f32': (1, 'exp2({0})'), 'v_log_f32': (1, 'log2({0})'), 'v_floor_f32': (1, 'floor({0})'), 'v_ceil_f32': (1, 'ceil({0})'), 'v_trunc_f32': (1, 'trunc({0})'), 'v_fract_f32': (1, 'frac({0})'), 'v_rndne_f32': (1, 'round({0})'), 'v_sin_f32': (1, 'sin({0} * 6.283185307)'), 'v_cos_f32': (1, 'cos({0} * 6.283185307)'), + 'v_cubeid_f32': (3, 'cubeid({0}, {1}, {2})'), 'v_cubesc_f32': (3, 'cubesc({0}, {1}, {2})'), + 'v_cubetc_f32': (3, 'cubetc({0}, {1}, {2})'), 'v_cubema_f32': (3, 'cubema({0}, {1}, {2})'), ~~~~ --- Fixed in a678bc3c: docs/startup-runtime.md and docs/experiments.md now list the accepted cube forms, the repro commands and the non-seamless limitation.
denn0x commented 2026-11-25 02:02:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T01:37:05Z.


Thanks, a678bc3c fixes the [1, 2] range and the binding. One case is still off: cube arrays.

In the same private executable's pixel programs (decode only, aggregate counts), a few of the CUBE samples are arrays. The third address component is built as
v_fmamk_f32 vZ, vLayer, 0x41000000, vFace, i.e. layer * 8 + face.

As I understand it, that is how ACO addresses a cube array: each layer takes 8 face slots, of which 6 are used. The image descriptor is set up to match.

With TEXTURECUBEARRAY rebound as a 2D array of 6 slices per cube, the sampled slice 8 * layer + face is wrong for every layer >= 1. For example, layer 1, face 0 reads slice 8 (layer 1, face 2) instead of slice 6.

Options:

  • remap in the translation, slice = floor(z / 8) * 6 + (z mod 8) on the rounded component, when the bound view is a cube array; or
  • refuse dim:SQ_RSRC_IMG_CUBE over a cube-array view until that remap has a test. A 2-layer cube array with a distinct colour per (layer, face), sampled at layer 1, would catch it.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149756217 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7149756217). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T01:37:05Z. --- Thanks, a678bc3c fixes the [1, 2] range and the binding. One case is still off: **cube arrays**. In the same private executable's pixel programs (decode only, aggregate counts), a few of the CUBE samples are arrays. The third address component is built as `v_fmamk_f32 vZ, vLayer, 0x41000000, vFace`, i.e. `layer * 8 + face`. As I understand it, that is how ACO addresses a cube array: each layer takes 8 face slots, of which 6 are used. The image descriptor is set up to match. With TEXTURECUBEARRAY rebound as a 2D array of 6 slices per cube, the sampled slice `8 * layer + face` is wrong for every layer >= 1. For example, layer 1, face 0 reads slice 8 (layer 1, face 2) instead of slice 6. Options: - remap in the translation, `slice = floor(z / 8) * 6 + (z mod 8)` on the rounded component, when the bound view is a cube array; or - refuse `dim:SQ_RSRC_IMG_CUBE` over a cube-array view until that remap has a test. A 2-layer cube array with a distinct colour per (layer, face), sampled at layer 1, would catch it.
tedin7 commented 2026-11-25 02:02:09 +00:00 (Migrated from github.com)

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


Thanks, both points were right. Pushed 9b540eb6.

  • Cube arrays: the third component is now passed through cubeslice(), slice = floor(r / 8) * 6 + (r mod 8) on r = max(round(z), 0). Layer 0 (plain cube) is unchanged. The SRV rebind already maps a cube array to a 2D array of 6 slices per cube.
  • NaN: cubeaxis now spells out |z| >= |x| && |z| >= |y|.

Verification (Linux, executed locally):

  • python3 -B tests/startup_gfx2hlsl_cube_check.py -> ok (checks the cubeslice(F(v2)) sample text, the helper in the preamble and the separate comparisons)
  • startup_gfx2hlsl_cube_alu_check.py (translation controls), startup_image_2d_array_check.py, startup_image_3d_check.py, startup_image_sample_l_check.py, startup_gfx2hlsl_refusals_check.py, startup_gfx2hlsl_f32_nan_check.py -> pass

Not done yet: the Win2025 WARP run, and a value test that draws a 2-layer cube array with a distinct colour per (layer, face) sampled at layer 1. The remap is only text-checked for now, so the PR stays open for that fixture before it is trusted.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149995399 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7149995399). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:49:18Z. --- Thanks, both points were right. Pushed 9b540eb6. - Cube arrays: the third component is now passed through `cubeslice()`, `slice = floor(r / 8) * 6 + (r mod 8)` on `r = max(round(z), 0)`. Layer 0 (plain cube) is unchanged. The SRV rebind already maps a cube array to a 2D array of 6 slices per cube. - NaN: `cubeaxis` now spells out `|z| >= |x| && |z| >= |y|`. Verification (Linux, executed locally): - `python3 -B tests/startup_gfx2hlsl_cube_check.py` -> ok (checks the `cubeslice(F(v2))` sample text, the helper in the preamble and the separate comparisons) - `startup_gfx2hlsl_cube_alu_check.py` (translation controls), `startup_image_2d_array_check.py`, `startup_image_3d_check.py`, `startup_image_sample_l_check.py`, `startup_gfx2hlsl_refusals_check.py`, `startup_gfx2hlsl_f32_nan_check.py` -> pass Not done yet: the Win2025 WARP run, and a value test that draws a 2-layer cube array with a distinct colour per (layer, face) sampled at layer 1. The remap is only text-checked for now, so the PR stays open for that fixture before it is trusted. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 03:01:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:36:30Z.


Follow-up on the cube-array slice fix (9b540eb6): f5e61316 adds a real D3D12 draw check for the layer * 8 + face to layer * 6 + face mapping.

  • The draw harness gets a twelve-slice mode (two cubes of 2x2 texels, texel value names its slice).
  • New tests/startup_image_cube_array_check.py draws image_sample dim:SQ_RSRC_IMG_CUBE for addresses 0, 5, 8, 9, 13 and reads back slices 0, 5, 6, 7, 11. A mutant that leaves the address as layer * 8 + face must read slice 9 for address 9 and fail.
  • Registered as startup_image_cube_array_{controls,warp,hardware}.

Verification:

  • Linux: python3 -B tests/startup_image_cube_array_check.py, tests/startup_gfx2hlsl_cube_check.py, tests/startup_image_2d_array_check.py, tests/startup_image_3d_check.py all pass.
  • Win2025: python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 2035 --force --targets offscreen_check --regex 'startup_(image_cube_array|image_2d_array|image_3d|gfx2hlsl_cube)' --py-checks tests/startup_gfx2hlsl_cube_check.py,tests/startup_image_cube_array_check.py at f5e61316.
  • Result: ctest dev 13/13 passed, ctest release 13/13 passed (includes startup_image_cube_array_warp and startup_image_cube_array_controls, 0 failed, 0 skipped). Both Python checks ok on Windows.
  • Note: the node only has WARP, so the _hardware variants ran on that same adapter. A first attempt on the other slot failed with a missing file in that slot's checkout; the rerun above is the passing one.
  • Not covered: the runtime's TEXTURECUBEARRAY to TEXTURE2DARRAY view rewrite in d3d12_draw.inl (the draw binds the array view directly).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7150943910 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7150943910). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:36:30Z. --- Follow-up on the cube-array slice fix (9b540eb6): f5e61316 adds a real D3D12 draw check for the `layer * 8 + face` to `layer * 6 + face` mapping. - The draw harness gets a twelve-slice mode (two cubes of 2x2 texels, texel value names its slice). - New `tests/startup_image_cube_array_check.py` draws `image_sample dim:SQ_RSRC_IMG_CUBE` for addresses 0, 5, 8, 9, 13 and reads back slices 0, 5, 6, 7, 11. A mutant that leaves the address as `layer * 8 + face` must read slice 9 for address 9 and fail. - Registered as `startup_image_cube_array_{controls,warp,hardware}`. Verification: - Linux: `python3 -B tests/startup_image_cube_array_check.py`, `tests/startup_gfx2hlsl_cube_check.py`, `tests/startup_image_2d_array_check.py`, `tests/startup_image_3d_check.py` all pass. - Win2025: `python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 2035 --force --targets offscreen_check --regex 'startup_(image_cube_array|image_2d_array|image_3d|gfx2hlsl_cube)' --py-checks tests/startup_gfx2hlsl_cube_check.py,tests/startup_image_cube_array_check.py` at f5e61316. - Result: ctest dev 13/13 passed, ctest release 13/13 passed (includes `startup_image_cube_array_warp` and `startup_image_cube_array_controls`, 0 failed, 0 skipped). Both Python checks ok on Windows. - Note: the node only has WARP, so the `_hardware` variants ran on that same adapter. A first attempt on the other slot failed with a missing file in that slot's checkout; the rerun above is the passing one. - Not covered: the runtime's `TEXTURECUBEARRAY` to `TEXTURE2DARRAY` view rewrite in `d3d12_draw.inl` (the draw binds the array view directly). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 11:02:05 +00:00 (Migrated from github.com)

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

Review: COMMENTED


No description provided.

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

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

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

@@ -1104,13 +1104,15 @@ def image(self, ops, mods, how):
         dst = reg_range(ops[0])
         dim = [m for m in mods if m.startswith('dim:')][0][4:]
         dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0)
-        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'}
+        kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da',
+                 'SQ_RSRC_IMG_CUBE': 'tex2da'}

Re-checked on current head 2e7a81e3: the cube refusal controls are updated in this head (tests/startup_gfx2hlsl_cube_check.py). Resolving. AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4693919141 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#discussion_r4693919141). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T11:01:34Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1108 ~~~~diff @@ -1104,13 +1104,15 @@ def image(self, ops, mods, how): dst = reg_range(ops[0]) dim = [m for m in mods if m.startswith('dim:')][0][4:] dmask = int([m for m in mods if m.startswith('dmask:')][0][6:], 0) - kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da'} + kinds = {'SQ_RSRC_IMG_1D': 'tex1d', 'SQ_RSRC_IMG_2D': 'tex2d', 'SQ_RSRC_IMG_3D': 'tex3d', 'SQ_RSRC_IMG_2D_ARRAY': 'tex2da', + 'SQ_RSRC_IMG_CUBE': 'tex2da'} ~~~~ --- Re-checked on current head 2e7a81e3: the cube refusal controls are updated in this head (tests/startup_gfx2hlsl_cube_check.py). Resolving. AI-assisted; commands listed were executed locally.
thepatrickworld commented 2026-11-25 12:01:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-25T11:54:33Z.


Three fixtures, three runs, all on the AMD adapter (adapter=AMD Radeon RX 9070 XT vendor=1002 device=7550, driver=32.0.32029.2010), backend hardware, both compilers.

Cube ALU — startup_gfx2hlsl_cube_alu_check.py draw <dxc> <check> hardware <fxc>:

hardware: 16 draws matched, 8 mutated draws read their mutated words

Cube image addressing — startup_image_cube_array_check.py draw ..., five addresses per compiler:

dxc cube address=8 reads slice 6
dxc cube address=9 reads slice 7
dxc cube address=13 reads slice 11
dxc slice left as layer * 8 + face: fails as expected, reads slice 9

Addresses 0, 5, 8, 9 and 13 give slices 0, 5, 6, 7 and 11 under dxc, the same under fxc, and the mutation that leaves the layer * 8 + face indexing in place is caught. Why 8 has to become 6 is stated by the fixture itself (tests/startup_image_cube_array_check.py:9-11) and by the helper in gfx2hlsl.py:3181 — the ISA indexes with eight face slots per layer, the bound array view has six — that is their explanation, not something the log prints; the log only shows the pairs.

2D array — startup_image_2d_array_check.py draw ...: 24 readbacks and 20 mutation runs per compiler, all matching, all mutations failing.

Limits of my run. The cube-array fixture reads s = 1.75 and t = 1.25 (per its docstring), so in my run the bias removal is exercised on those two coordinates and I did not try others. The cube-ALU fixture carries no such coordinates. And out of the five addresses above, the only one that leaves the six-slice mapping is the mutation, which is expected to fail.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7161665152 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7161665152). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-25T11:54:33Z. --- Three fixtures, three runs, all on the AMD adapter (`adapter=AMD Radeon RX 9070 XT vendor=1002 device=7550`, `driver=32.0.32029.2010`), backend `hardware`, both compilers. **Cube ALU** — `startup_gfx2hlsl_cube_alu_check.py draw <dxc> <check> hardware <fxc>`: ``` hardware: 16 draws matched, 8 mutated draws read their mutated words ``` **Cube image addressing** — `startup_image_cube_array_check.py draw ...`, five addresses per compiler: ``` dxc cube address=8 reads slice 6 dxc cube address=9 reads slice 7 dxc cube address=13 reads slice 11 dxc slice left as layer * 8 + face: fails as expected, reads slice 9 ``` Addresses 0, 5, 8, 9 and 13 give slices 0, 5, 6, 7 and 11 under `dxc`, the same under `fxc`, and the mutation that leaves the `layer * 8 + face` indexing in place is caught. Why 8 has to become 6 is stated by the fixture itself (`tests/startup_image_cube_array_check.py:9-11`) and by the helper in `gfx2hlsl.py:3181` — the ISA indexes with eight face slots per layer, the bound array view has six — that is their explanation, not something the log prints; the log only shows the pairs. **2D array** — `startup_image_2d_array_check.py draw ...`: 24 readbacks and 20 mutation runs per compiler, all matching, all mutations failing. **Limits of my run.** The cube-array fixture reads `s = 1.75` and `t = 1.25` (per its docstring), so in my run the bias removal is exercised on those two coordinates and I did not try others. The cube-ALU fixture carries no such coordinates. And out of the five addresses above, the only one that leaves the six-slice mapping is the mutation, which is expected to fail. _AI-assisted._
tedin7 commented 2026-11-25 12:01:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:54:50Z.


Stage-2 verification at head 2e7a81e3a333a88a686c7cdaf13613a3c8588867 (Windows Server 2025 build 26100, MSVC 14.44, D3D12 WARP, 3-slot pool):

  • x2w_pipe.py win2025 2035 --force --targets offscreen_check --regex 'cube|startup_image_(2d_array|3d|sample_l)|gfx2hlsl' plus the three cube Python checks: dev 105/105 and release 105/105 passed.
  • New tests all ran and passed (not skipped): startup_gfx2hlsl_cube, startup_gfx2hlsl_cube_alu_{controls,warp}, startup_image_cube_array_{controls,warp}.
  • Python checks startup_gfx2hlsl_cube_check.py, startup_gfx2hlsl_cube_alu_check.py, startup_image_cube_array_check.py: ok.
  • GitHub CI: Linux Python checks, gfx1013 fixtures and Windows build all pass.
  • Diff scan: no AI model names, no Co-Authored-By, no local-probe mentions.

Note for the author: the PR body is stale. It still says "Win2025 run: not executed" and does not mention cubeslice() (layer8+face to layer6+face), the two WARP draw checks, or the D3D12 SRV rebind. Please refresh it before Ready.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7161671616 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7161671616). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T11:54:50Z. --- Stage-2 verification at head `2e7a81e3a333a88a686c7cdaf13613a3c8588867` (Windows Server 2025 build 26100, MSVC 14.44, D3D12 WARP, 3-slot pool): - `x2w_pipe.py win2025 2035 --force --targets offscreen_check --regex 'cube|startup_image_(2d_array|3d|sample_l)|gfx2hlsl'` plus the three cube Python checks: dev 105/105 and release 105/105 passed. - New tests all ran and passed (not skipped): `startup_gfx2hlsl_cube`, `startup_gfx2hlsl_cube_alu_{controls,warp}`, `startup_image_cube_array_{controls,warp}`. - Python checks `startup_gfx2hlsl_cube_check.py`, `startup_gfx2hlsl_cube_alu_check.py`, `startup_image_cube_array_check.py`: ok. - GitHub CI: Linux Python checks, gfx1013 fixtures and Windows build all pass. - Diff scan: no AI model names, no `Co-Authored-By`, no local-probe mentions. Note for the author: the PR body is stale. It still says "Win2025 run: not executed" and does not mention `cubeslice()` (layer*8+face to layer*6+face), the two WARP draw checks, or the D3D12 SRV rebind. Please refresh it before Ready. AI-assisted; commands listed were executed locally.
legacy-code-archaeologist commented 2026-11-25 12:01:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T11:59:05Z.


Ran head 2e7a81e3 on three adapters. All pass. Windows 11 build 26100, debug layer unavailable, FXC and DXC from SDK 10.0.26100.0. The adapter for each hardware run came from XBOX2WINDOWS_ADAPTER and was confirmed by the adapter= line.

Test WARP 10.0.26100.8972 NVIDIA Quadro M1000M (32.0.15.7371) Intel HD Graphics 530 (31.0.101.2111)
startup_gfx2hlsl_cube, startup_gfx2hlsl_cube_alu_controls, startup_image_cube_array_controls pass n/a n/a
startup_gfx2hlsl_cube_alu_{warp,hardware} pass: 14 ok lines, 8 mutations fail as expected same same
startup_image_cube_array_{warp,hardware} pass: both controls fail as expected same same

For context: in a local census of start-up shader requests (aggregate counts only, one input, not checked in CI), v_cubema/sc/tc_f32 each appear in 221 pixel code pairs, v_cubeid_f32 in 220 and image dimension SQ_RSRC_IMG_CUBE in 220, so this PR covers a large block of pixel refusals there. The head currently conflicts with main.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7161765037 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7161765037). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-25T11:59:05Z. --- Ran head `2e7a81e3` on three adapters. All pass. Windows 11 build 26100, debug layer unavailable, FXC and DXC from SDK 10.0.26100.0. The adapter for each hardware run came from `XBOX2WINDOWS_ADAPTER` and was confirmed by the `adapter=` line. | Test | WARP 10.0.26100.8972 | NVIDIA Quadro M1000M (32.0.15.7371) | Intel HD Graphics 530 (31.0.101.2111) | |---|---|---|---| | `startup_gfx2hlsl_cube`, `startup_gfx2hlsl_cube_alu_controls`, `startup_image_cube_array_controls` | pass | n/a | n/a | | `startup_gfx2hlsl_cube_alu_{warp,hardware}` | pass: 14 ok lines, 8 mutations fail as expected | same | same | | `startup_image_cube_array_{warp,hardware}` | pass: both controls fail as expected | same | same | For context: in a local census of start-up shader requests (aggregate counts only, one input, not checked in CI), `v_cubema/sc/tc_f32` each appear in 221 pixel code pairs, `v_cubeid_f32` in 220 and `image dimension SQ_RSRC_IMG_CUBE` in 220, so this PR covers a large block of pixel refusals there. The head currently conflicts with `main`. _AI-assisted._
tedin7 commented 2026-11-25 13:01:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:58:20Z.


Thank you for running this on three adapters (WARP, Quadro M1000M, HD Graphics 530) and for the census numbers. Both are useful.

Your pass is on 2e7a81e3. The head has since moved to db59df52, which is a merge of main into the branch. That merge also clears the conflict you noted.

After the merge, the Linux Python check tests/startup_image_sample_b_check.py failed. It still expected image_sample_b on a cube to be refused, and this PR now accepts cube addressing. The lowering in tools/startup/gfx2hlsl.py is unchanged. Only the test control changed: the refusal case now uses SQ_RSRC_IMG_1D_ARRAY, the same swap startup_image_sample_l_check.py already got in this PR.

Fix is commit 52020e6c (test file only, tests/startup_image_sample_b_check.py). Your hardware results should still hold, since no shader code or WARP/hardware test changed after 2e7a81e3.

Commands run locally:

  • python3 -I tests/startup_image_sample_b_check.py: ok (failed with "cube was accepted" before the change)
  • python3 -I tests/startup_image_*_check.py and tests/startup_gfx2hlsl*_check.py: all ok

One open point: image_sample_b on a cube is now accepted through the shared path, but no WARP readback covers the bias case yet.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7163109523 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7163109523). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:58:20Z. --- Thank you for running this on three adapters (WARP, Quadro M1000M, HD Graphics 530) and for the census numbers. Both are useful. Your pass is on `2e7a81e3`. The head has since moved to `db59df52`, which is a merge of `main` into the branch. That merge also clears the conflict you noted. After the merge, the Linux Python check `tests/startup_image_sample_b_check.py` failed. It still expected `image_sample_b` on a cube to be refused, and this PR now accepts cube addressing. The lowering in `tools/startup/gfx2hlsl.py` is unchanged. Only the test control changed: the refusal case now uses `SQ_RSRC_IMG_1D_ARRAY`, the same swap `startup_image_sample_l_check.py` already got in this PR. Fix is commit `52020e6c` (test file only, `tests/startup_image_sample_b_check.py`). Your hardware results should still hold, since no shader code or WARP/hardware test changed after `2e7a81e3`. Commands run locally: - `python3 -I tests/startup_image_sample_b_check.py`: ok (failed with "cube was accepted" before the change) - `python3 -I tests/startup_image_*_check.py` and `tests/startup_gfx2hlsl*_check.py`: all ok One open point: `image_sample_b` on a cube is now accepted through the shared path, but no WARP readback covers the bias case yet. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 14:04:29 +00:00
tedin7 commented 2026-11-25 14:05:12 +00:00 (Migrated from github.com)

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


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:7164373057 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2035#issuecomment-7164373057). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T13:50:42Z. --- 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.

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!2028
No description provided.