startup: lower level-zero D16 image_load in gfx2hlsl #2131

Merged
consolelogkyo merged 2 commits from upstream-pr/2139 into main 2026-11-25 04:44:38 +00:00
consolelogkyo commented 2026-11-25 01:29:26 +00:00 (Migrated from github.com)

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


Summary

Lowers level-zero MIMG image_load with d16 (opcode 0x00) in tools/startup/gfx2hlsl.py for 2D (including packed a16 coordinates and NSA coordinate lists), 3D, and 2D-array textures, validates the bound SRV's effective DXGI_FORMAT before drawing against the 14 independently GPU-verified exact formats, dispatches exact UNORM16 ratio-to-binary16 conversion per SRV so DXGI_FORMAT_R16*_UNORM avoids binary32 double-rounding, and guards hardware-undefined upper 16 bits on odd-dmask destination VGPRs.

Part of #2023 (item D).

Root Cause & Design

  • RDNA 2 image_load ... d16 narrowing and binary32 double-rounding:
    • Hardware narrows each enabled dmask component to IEEE-754 binary16 (round to nearest even) and packs the halves pairwise into ceil(popcount(dmask) / 2) consecutive VGPRs (low 16 bits first, high 16 bits second).
    • HLSL f32tof16 (DXBC ftof16) truncates toward zero on WARP, lowering 31,740 of the 65,536 DXGI_FORMAT_R16_UNORM values by 1 ULP relative to RDNA hardware.
    • Even with round-to-nearest-even on Texture*<float4>.Load, narrowing an intermediate IEEE binary32 value double-rounds R16_UNORM at two codes: 0xffaf (0x3bfe instead of 0x3bfd) and 0xffef (0x3c00 instead of 0x3bff).
    • gfx2hlsl.py therefore emits:
      1. pack16_rne(float): integer IEEE binary32-to-binary16 round-to-nearest-even (covering normals, subnormals, halfway ties to even, signed zero, overflow to infinity, and quiet NaNs preserving sign sign | 0x7e00u as measured on RDNA 2 hardware).
      2. pack16_unorm16(float): recovers the exact 16-bit integer u = uint(saturate(value) * 65535.0 + 0.5) and rounds u / 65535 directly to IEEE binary16 in 32-bit uint arithmetic (firstbithigh(u), u << (26u - msb), quotient + remainder > 32767u; odd 65535 has no exact halfway ties).
      3. pack16_d16(float, uint): selects pack16_unorm16 when the per-SRV entry constant udsrc <ud> d16unorm16 <index> is non-zero and pack16_rne otherwise (default .y/.z = 0.0 and .w = 1.0 channels on 1/2-channel R16*_UNORM also map to exact 0x0000 and 0x3c00).
  • GPU-verified exact SRV format allowlist (src/startup_stubs/d16_image_format.h, src/startup_stubs/d3d12_draw.inl):
    • Manifests publish d16srv <index> exact and udsrc <ud> d16unorm16 <index> for every SRV read by image_load ... d16.
    • Before drawing, d16_srvs_ready resolves the bound descriptor's effective DXGI_FORMAT (explicit SRV format, or underlying console/desktop resource format for default SRVs) and accepts only the 14 independently GPU-verified exact formats:
      • 11 D16SrvMode::float_exact (d16unorm16 = 0): R32G32B32A32_FLOAT, R32G32B32_FLOAT, R32G32_FLOAT, R32_FLOAT, R32_FLOAT_X8X24_TYPELESS, R8G8B8A8_UNORM, R8G8_UNORM, R8_UNORM, A8_UNORM, B8G8R8A8_UNORM, B8G8R8X8_UNORM.
      • 3 D16SrvMode::unorm16 (d16unorm16 = 1): R16G16B16A16_UNORM, R16G16_UNORM, R16_UNORM.
    • Integer (UINT/SINT), typeless, depth-stencil-only, R16*_FLOAT, SNORM16, R24_UNORM_X8_TYPELESS, SRGB, block-compressed (BCn), packed-target stand-ins (packed_stand_in_of), console extension, null-resource, and unwritten views are refused with d16 exact refused.
  • Odd-dmask upper-half safety:
    • When popcount(dmask) is odd (1 or 3), bits 31:16 of the final destination VGPR are hardware-undefined on RDNA 2. Stage tracks low16_only_v across straight-line expressions and basic blocks and refuses whole-word reads unless consumed through a low-16-bit operation (v_cvt_f32_f16, v_cvt_f32_ubyte0/1, SDWA BYTE_0/BYTE_1/WORD_0, v_and_b32 with constant mask <= 0xffff, v_cmp_class_f16/v_cmpx_class_f16, or v_fma_mix* half operands).
  • Explicit refusals preserved:
    • image_load_mip (0x01) with d16, sampler MIMG forms with d16, 1D and cube dimensions, 3D/2D-array a16, tfe, lwe, r128, set reserved MIMG bits, dmask:0x0, and mismatched register counts remain refused.

Verification

Verified on commit base 009153b7 (Windows 11 26H2 build 26300.9974, MSVC 19.44, DXC + FXC 10.0.26100.0, D3D12 debug layer enabled with debug_errors=0 debug_warnings=0):

  • Exhaustive GPU conversions (AMD Radeon RX 9070 XT 32.0.32029.2010 & WARP 10.0.26100.9818):
    • R16_UNORM: 65,536 / 65,536 exact code recoveries and 65,536 / 65,536 exact binary16 results (0 mismatches under both DXC and FXC, including 0xffaf -> 0x3bfd and 0xffef -> 0x3bff).
    • R8_UNORM: 256 / 256 exact binary16 results under pack16_rne (0 mismatches).
    • R32_FLOAT NaN sign preservation: 0x7fc00001 -> 0x7e00, 0xffc00123 -> 0xfe00.
  • Automated CTest suite (10/10 D16 + image_load_mip tests, 30/30 pr preset, 100/100 startup_* suite):
    • startup_image_load_d16_controls: transpiles and executes the live pack16_rne and pack16_unorm16 HLSL emitted by gfx2hlsl.py across 320 boundary floats, all 256 UNORM8 codes, and all 65,536 R16_UNORM codes on Linux/Windows (with self-tests killing tie-to-even and threshold mutations), plus all 15 non-zero dmasks, d16_image_format.h sync, 30 odd-dmask consumer paths, and refusal checks.
    • startup_image_load_d16_{warp,hardware}: DXC (ps_6_0) and FXC (ps_5_1) draws across 8x2 R16_UNORM (including 0xffaf and 0xffef) and 8x2 R32G32B32A32_FLOAT, 0xdead0000 upper-half poison invariance, and 8 negative HLSL mutation controls (rtz, double_round, unpacked_x, swap_halves, drop_shift, drop_a16, drop_nsa, unmasked_odd_hi).
    • startup_d16_image_format & startup_d16_image_format_accept_uint_control: all 256 DXGI_FORMAT enum values (11 float_exact + 3 unorm16 + 242 refused), manifest parser bounds, and negative mutation control.
    • startup_d16_srv_{warp,hardware}: end-to-end d3d12_xs.dll draw dispatching d16unorm16=1 (R16_UNORM 0xffef -> 0x3bff) and d16unorm16=0 (R32_FLOAT 0x3f7ff000 -> 0x3c00) on one PSO, R16_TYPELESS + R16_UNORM (0xaaaa -> 0x3955), refusing R16_UINT, R16_SNORM, null-resource and unwritten slots, and rejecting malformed d16srv manifests.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6595024809 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139). Originally posted by [consolelogkyo](https://github.com/consolelogkyo) on 2026-11-25T01:29:26Z. --- ### Summary Lowers level-zero MIMG `image_load` with `d16` (`opcode 0x00`) in `tools/startup/gfx2hlsl.py` for 2D (including packed `a16` coordinates and NSA coordinate lists), 3D, and 2D-array textures, validates the bound SRV's effective `DXGI_FORMAT` before drawing against the 14 independently GPU-verified exact formats, dispatches exact `UNORM16` ratio-to-binary16 conversion per SRV so `DXGI_FORMAT_R16*_UNORM` avoids binary32 double-rounding, and guards hardware-undefined upper 16 bits on odd-`dmask` destination VGPRs. Part of #2023 (item D). ### Root Cause & Design - **RDNA 2 `image_load ... d16` narrowing and binary32 double-rounding:** - Hardware narrows each enabled `dmask` component to IEEE-754 binary16 (round to nearest even) and packs the halves pairwise into `ceil(popcount(dmask) / 2)` consecutive VGPRs (low 16 bits first, high 16 bits second). - HLSL `f32tof16` (DXBC `ftof16`) truncates toward zero on WARP, lowering 31,740 of the 65,536 `DXGI_FORMAT_R16_UNORM` values by 1 ULP relative to RDNA hardware. - Even with round-to-nearest-even on `Texture*<float4>.Load`, narrowing an intermediate IEEE binary32 value double-rounds `R16_UNORM` at two codes: `0xffaf` (`0x3bfe` instead of `0x3bfd`) and `0xffef` (`0x3c00` instead of `0x3bff`). - `gfx2hlsl.py` therefore emits: 1. `pack16_rne(float)`: integer IEEE binary32-to-binary16 round-to-nearest-even (covering normals, subnormals, halfway ties to even, signed zero, overflow to infinity, and quiet NaNs preserving sign `sign | 0x7e00u` as measured on RDNA 2 hardware). 2. `pack16_unorm16(float)`: recovers the exact 16-bit integer `u = uint(saturate(value) * 65535.0 + 0.5)` and rounds `u / 65535` directly to IEEE binary16 in 32-bit `uint` arithmetic (`firstbithigh(u)`, `u << (26u - msb)`, quotient + remainder `> 32767u`; odd `65535` has no exact halfway ties). 3. `pack16_d16(float, uint)`: selects `pack16_unorm16` when the per-SRV entry constant `udsrc <ud> d16unorm16 <index>` is non-zero and `pack16_rne` otherwise (default `.y/.z = 0.0` and `.w = 1.0` channels on 1/2-channel `R16*_UNORM` also map to exact `0x0000` and `0x3c00`). - **GPU-verified exact SRV format allowlist (`src/startup_stubs/d16_image_format.h`, `src/startup_stubs/d3d12_draw.inl`):** - Manifests publish `d16srv <index> exact` and `udsrc <ud> d16unorm16 <index>` for every SRV read by `image_load ... d16`. - Before drawing, `d16_srvs_ready` resolves the bound descriptor's effective `DXGI_FORMAT` (explicit SRV format, or underlying console/desktop resource format for default SRVs) and accepts only the **14** independently GPU-verified exact formats: - `11` `D16SrvMode::float_exact` (`d16unorm16 = 0`): `R32G32B32A32_FLOAT`, `R32G32B32_FLOAT`, `R32G32_FLOAT`, `R32_FLOAT`, `R32_FLOAT_X8X24_TYPELESS`, `R8G8B8A8_UNORM`, `R8G8_UNORM`, `R8_UNORM`, `A8_UNORM`, `B8G8R8A8_UNORM`, `B8G8R8X8_UNORM`. - `3` `D16SrvMode::unorm16` (`d16unorm16 = 1`): `R16G16B16A16_UNORM`, `R16G16_UNORM`, `R16_UNORM`. - Integer (`UINT`/`SINT`), typeless, depth-stencil-only, `R16*_FLOAT`, `SNORM16`, `R24_UNORM_X8_TYPELESS`, `SRGB`, block-compressed (`BCn`), packed-target stand-ins (`packed_stand_in_of`), console extension, null-resource, and unwritten views are refused with `d16 exact refused`. - **Odd-`dmask` upper-half safety:** - When `popcount(dmask)` is odd (`1` or `3`), bits `31:16` of the final destination VGPR are hardware-undefined on RDNA 2. `Stage` tracks `low16_only_v` across straight-line expressions and basic blocks and refuses whole-word reads unless consumed through a low-16-bit operation (`v_cvt_f32_f16`, `v_cvt_f32_ubyte0`/`1`, `SDWA` `BYTE_0`/`BYTE_1`/`WORD_0`, `v_and_b32` with constant mask `<= 0xffff`, `v_cmp_class_f16`/`v_cmpx_class_f16`, or `v_fma_mix*` half operands). - **Explicit refusals preserved:** - `image_load_mip` (`0x01`) with `d16`, sampler MIMG forms with `d16`, 1D and cube dimensions, 3D/2D-array `a16`, `tfe`, `lwe`, `r128`, set reserved MIMG bits, `dmask:0x0`, and mismatched register counts remain refused. ### Verification Verified on commit base `009153b7` (Windows 11 26H2 build `26300.9974`, MSVC `19.44`, DXC + FXC `10.0.26100.0`, D3D12 debug layer enabled with `debug_errors=0 debug_warnings=0`): - **Exhaustive GPU conversions (AMD Radeon RX 9070 XT `32.0.32029.2010` & WARP `10.0.26100.9818`):** - `R16_UNORM`: `65,536 / 65,536` exact code recoveries and `65,536 / 65,536` exact binary16 results (`0` mismatches under both DXC and FXC, including `0xffaf -> 0x3bfd` and `0xffef -> 0x3bff`). - `R8_UNORM`: `256 / 256` exact binary16 results under `pack16_rne` (`0` mismatches). - `R32_FLOAT` NaN sign preservation: `0x7fc00001 -> 0x7e00`, `0xffc00123 -> 0xfe00`. - **Automated CTest suite (`10/10` D16 + `image_load_mip` tests, `30/30` `pr` preset, `100/100` `startup_*` suite):** - `startup_image_load_d16_controls`: transpiles and executes the live `pack16_rne` and `pack16_unorm16` HLSL emitted by `gfx2hlsl.py` across 320 boundary floats, all 256 `UNORM8` codes, and all 65,536 `R16_UNORM` codes on Linux/Windows (with self-tests killing tie-to-even and threshold mutations), plus all 15 non-zero `dmask`s, `d16_image_format.h` sync, 30 odd-`dmask` consumer paths, and refusal checks. - `startup_image_load_d16_{warp,hardware}`: DXC (`ps_6_0`) and FXC (`ps_5_1`) draws across `8x2` `R16_UNORM` (including `0xffaf` and `0xffef`) and `8x2` `R32G32B32A32_FLOAT`, `0xdead0000` upper-half poison invariance, and 8 negative HLSL mutation controls (`rtz`, `double_round`, `unpacked_x`, `swap_halves`, `drop_shift`, `drop_a16`, `drop_nsa`, `unmasked_odd_hi`). - `startup_d16_image_format` & `startup_d16_image_format_accept_uint_control`: all 256 `DXGI_FORMAT` enum values (`11` `float_exact` + `3` `unorm16` + `242` `refused`), manifest parser bounds, and negative mutation control. - `startup_d16_srv_{warp,hardware}`: end-to-end `d3d12_xs.dll` draw dispatching `d16unorm16=1` (`R16_UNORM` `0xffef -> 0x3bff`) and `d16unorm16=0` (`R32_FLOAT` `0x3f7ff000 -> 0x3c00`) on one PSO, `R16_TYPELESS + R16_UNORM` (`0xaaaa -> 0x3955`), refusing `R16_UINT`, `R16_SNORM`, null-resource and unwritten slots, and rejecting malformed `d16srv` manifests. AI-assisted.
tedin7 commented 2026-11-25 02:01:55 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head 89d21632268bd3928ad5238c7453e58c2f8f4e84 (comment only, no approval).

Result: no P1. 1 P2, 2 nits.

State: CI green on this head (Linux Python checks, gfx1013 fixtures, Windows build and test). mergeable was UNKNOWN at review time. Title is neutral, body starts with Part of #2023. The diff is 10 files, +838/-8, and touches only startup/gfx2hlsl, tests, CMake, CI and docs.

Logic read (tools/startup/gfx2hlsl.py)

  • expected_addr (about line 1283) keeps the old a16 (1 VGPR) and load_mip (axes+1) counts. It adds a plain-load count of axes, so plain 2D/3D/array loads now also check the address width. That is stricter than before, but correct.
  • expected_dst = (popcount(dmask)+1)//2 and the dst[2] > 255 bound match the packed-D16 VGPR layout. Odd trailing channel: no << 16 term, so [31:16] is cleared as the PR says.
  • pack16_rne, checked by hand:
    • 0x477ff000 is the exact tie at 65520, which correctly overflows to inf.
    • 0x38800000 is the normal/subnormal boundary.
    • 0x33000000 (2^-25) is a tie that rounds to even, which gives 0.
    • Subnormal shift stays in 14..24, so 1u << shift is safe.
  • The helper is emitted only when uses_pack16_rne is set, so other stages are unchanged.

Commands run locally (worktree at the PR head)

  • python3 tests/startup_image_load_mip_check.py: passed.
  • python3 tests/startup_image_load_d16_check.py: "Self-test passed".
  • python3 tests/docs_links_check.py: 18 files, 395 links OK.
  • python3 tests/bidi_controls_check.py: OK.
  • git diff --check origin/main...HEAD: clean.

Mutations (each reverted with git checkout -- .)

  • expected_dst = popcount(dmask) (no halving): killed, with Unsupported ... d16 destination v4 for dmask 0x3.
  • Drop the odd-tail guard in halves: killed (IndexError).
  • Remove the tie-to-even term ((shifted >> 13) & 1u) from the emitted HLSL: survived. startup_image_load_d16_check.py exited 0.

P2: the Linux test does not guard the emitted pack16_rne body

  • tests/startup_image_load_d16_check.py:270-295 (check_rounding_formula) re-implements the formula in Python and compares it to struct.pack('<e'). It never parses or executes the HLSL text that gfx2hlsl.py emits. A regression inside the emitted helper (gfx2hlsl.py, the pack16_rne block, about line 2183) is therefore invisible to the Linux job.
  • Only the WARP readback (--startup-image-load-d16) can catch it. I did not run that on Win2025: CI's Windows job is green on this head, and I did not confirm that the data covers the RNE tie cases.
  • Suggestion: assert the helper lines are byte-identical to a golden copy, or generate the Python reference from the same emitted lines. Otherwise state in the docs that this check is WARP-only.

Nits

  • NaN returns 0x7e00 and drops the sign and payload (gfx2hlsl.py, pack16_rne). Hardware may keep both. Say in a comment that this is intentional, or preserve the sign.
  • The mip check swaps the d16 refusal case for string asserts on v4/v5. That is fine, but the refusal for image_load_mip + d16 now lives only in the new test file.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050296914 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#pullrequestreview-6050296914). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:40:59Z. **Review:** COMMENTED --- Review of head `89d21632268bd3928ad5238c7453e58c2f8f4e84` (comment only, no approval). **Result: no P1. 1 P2, 2 nits.** State: CI green on this head (Linux Python checks, gfx1013 fixtures, Windows build and test). `mergeable` was UNKNOWN at review time. Title is neutral, body starts with `Part of #2023`. The diff is 10 files, +838/-8, and touches only startup/gfx2hlsl, tests, CMake, CI and docs. **Logic read (`tools/startup/gfx2hlsl.py`)** - `expected_addr` (about line 1283) keeps the old `a16` (1 VGPR) and `load_mip` (axes+1) counts. It adds a plain-load count of `axes`, so plain 2D/3D/array loads now also check the address width. That is stricter than before, but correct. - `expected_dst = (popcount(dmask)+1)//2` and the `dst[2] > 255` bound match the packed-D16 VGPR layout. Odd trailing channel: no `<< 16` term, so `[31:16]` is cleared as the PR says. - `pack16_rne`, checked by hand: - `0x477ff000` is the exact tie at 65520, which correctly overflows to inf. - `0x38800000` is the normal/subnormal boundary. - `0x33000000` (2^-25) is a tie that rounds to even, which gives 0. - Subnormal `shift` stays in 14..24, so `1u << shift` is safe. - The helper is emitted only when `uses_pack16_rne` is set, so other stages are unchanged. **Commands run locally (worktree at the PR head)** - `python3 tests/startup_image_load_mip_check.py`: passed. - `python3 tests/startup_image_load_d16_check.py`: "Self-test passed". - `python3 tests/docs_links_check.py`: 18 files, 395 links OK. - `python3 tests/bidi_controls_check.py`: OK. - `git diff --check origin/main...HEAD`: clean. **Mutations (each reverted with `git checkout -- .`)** - `expected_dst = popcount(dmask)` (no halving): killed, with `Unsupported ... d16 destination v4 for dmask 0x3`. - Drop the odd-tail guard in `halves`: killed (`IndexError`). - Remove the tie-to-even term `((shifted >> 13) & 1u)` from the emitted HLSL: **survived**. `startup_image_load_d16_check.py` exited 0. **P2: the Linux test does not guard the emitted `pack16_rne` body** - `tests/startup_image_load_d16_check.py:270-295` (`check_rounding_formula`) re-implements the formula in Python and compares it to `struct.pack('<e')`. It never parses or executes the HLSL text that `gfx2hlsl.py` emits. A regression inside the emitted helper (`gfx2hlsl.py`, the `pack16_rne` block, about line 2183) is therefore invisible to the Linux job. - Only the WARP readback (`--startup-image-load-d16`) can catch it. I did not run that on Win2025: CI's Windows job is green on this head, and I did not confirm that the data covers the RNE tie cases. - Suggestion: assert the helper lines are byte-identical to a golden copy, or generate the Python reference from the same emitted lines. Otherwise state in the docs that this check is WARP-only. **Nits** - NaN returns `0x7e00` and drops the sign and payload (`gfx2hlsl.py`, `pack16_rne`). Hardware may keep both. Say in a comment that this is intentional, or preserve the sign. - The mip check swaps the `d16` refusal case for string asserts on `v4`/`v5`. That is fine, but the refusal for `image_load_mip` + d16 now lives only in the new test file. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 02:01:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T01:50:58Z.

Review: CHANGES_REQUESTED


The RX 9070 XT exhaustive capture is useful: it separates two real R16_UNORM discrepancies at 0xffaf and 0xffef from the much larger WARP f32tof16 difference. The software helper fixes the latter, but still rounds an already-rounded binary32 texture load. Both known native mismatches should stay as double-rounding controls. Please either derive the half from the exact UNORM value with an independently verified conversion and rerun all 65,536 values, or limit the first slice to formats whose input is already a proven binary32 value. For a restricted slice, enforce the format before use and refuse unknown view formats. Please also compare the remaining scope against #2119 on #2023 so the same D16 implementation is reviewed once.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050402766 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#pullrequestreview-6050402766). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T01:50:58Z. **Review:** CHANGES_REQUESTED --- The RX 9070 XT exhaustive capture is useful: it separates two real R16_UNORM discrepancies at `0xffaf` and `0xffef` from the much larger WARP `f32tof16` difference. The software helper fixes the latter, but still rounds an already-rounded binary32 texture load. Both known native mismatches should stay as double-rounding controls. Please either derive the half from the exact UNORM value with an independently verified conversion and rerun all 65,536 values, or limit the first slice to formats whose input is already a proven binary32 value. For a restricted slice, enforce the format before use and refuse unknown view formats. Please also compare the remaining scope against #2119 on #2023 so the same D16 implementation is reviewed once.
tedin7 commented 2026-11-25 03:01:02 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head c805fba3791a7b493319f5a6ee0388f23f97f193 (comment only, no approval). Previous review covered 89d21632; this covers the new commit c805fba3 (D16 SRV format validation and odd-dmask consumer guards).

Result: no P1. 1 P2, 1 nit.

P2: the branch conflicts with main

  • gh pr view reports mergeable: CONFLICTING. git merge-tree origin/main HEAD shows a content conflict in tools/startup/gfx2hlsl.py (the other files auto-merge).
  • No CI checks are reported on startup/gfx2hlsl-image-load-d16 for this head, so the Windows build and the C++ tests added in c805fba3 (startup_d16_image_format_check.cpp, startup_address_srv.cpp, d3d12_draw.inl changes) have no green run yet. Please rebase and re-run CI before Ready.

Logic read (tools/startup/gfx2hlsl.py, src/startup_stubs/d16_image_format.h)

  • Odd-dmask tracking (low16_only_v, pinned_low16_v, whole_read_v): a VGPR whose upper half is undefined is only accepted by low-16-bit consumers (v_cvt_f32_f16, v_cvt_f32_ubyte0/1, v_and_b32 with a mask under 0x10000, SDWA byte/word selects, v_fma_mix half operands). Any other whole-word read, v_swap_b32, or a flag live across a block boundary is refused. The flags are never cleared under an unknown exec mask, so the tracking errs on the safe side.
  • d16_float_norm_srv_format refuses UINT/SINT/typeless/unbound views. This is the right split, because the lowering does Load on float4 and narrows with RNE.
  • Nit: u() uses getattr(self, 'low16_only_v', ()) and hasattr checks to support unit probes that build a Stage without __init__. A small helper or class-level defaults would read better.

Commands run locally (worktree at the PR head)

  • python3 tests/startup_image_load_d16_check.py: passed (47 float/norm formats match the header, 25 refused, 12 low-16 paths accepted, 18 leaks refused).
  • python3 tests/startup_image_load_mip_check.py: passed.
  • python3 tests/docs_links_check.py: 18 files, 395 links OK.
  • python3 tests/bidi_controls_check.py: OK.
  • git diff --check origin/main...HEAD: clean.
  • python3 tests/startup_d16_srv_check.py: not run standalone. It needs the built consumer/backend arguments (CTest passes them), so it was not exercised on Linux.

Mutations (each reverted with git checkout -- .)

  • Drop low16_only=odd_tail on the odd trailing set_v: killed (odd dmask 0x1 direct export: unexpectedly accepted).
  • Replace the SRV format check fmt not in D16_FLOAT_NORM_SRV_FORMATS with False: killed (exit 1).

Windows proof

  • I did not run x2w_pipe.py win2025. The branch conflicts with main, so the run would not test what will merge. Please rebase, then a real WARP readback run (--startup-image-load-d16) on Win2025 is the proof still needed for the lowering and the new d3d12_draw.inl checks.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050852232 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#pullrequestreview-6050852232). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:29:33Z. **Review:** COMMENTED --- Review of head `c805fba3791a7b493319f5a6ee0388f23f97f193` (comment only, no approval). Previous review covered `89d21632`; this covers the new commit `c805fba3` (D16 SRV format validation and odd-dmask consumer guards). **Result: no P1. 1 P2, 1 nit.** **P2: the branch conflicts with main** - `gh pr view` reports `mergeable: CONFLICTING`. `git merge-tree origin/main HEAD` shows a content conflict in `tools/startup/gfx2hlsl.py` (the other files auto-merge). - No CI checks are reported on `startup/gfx2hlsl-image-load-d16` for this head, so the Windows build and the C++ tests added in `c805fba3` (`startup_d16_image_format_check.cpp`, `startup_address_srv.cpp`, `d3d12_draw.inl` changes) have no green run yet. Please rebase and re-run CI before Ready. **Logic read (`tools/startup/gfx2hlsl.py`, `src/startup_stubs/d16_image_format.h`)** - Odd-dmask tracking (`low16_only_v`, `pinned_low16_v`, `whole_read_v`): a VGPR whose upper half is undefined is only accepted by low-16-bit consumers (`v_cvt_f32_f16`, `v_cvt_f32_ubyte0/1`, `v_and_b32` with a mask under 0x10000, SDWA byte/word selects, `v_fma_mix` half operands). Any other whole-word read, `v_swap_b32`, or a flag live across a block boundary is refused. The flags are never cleared under an unknown exec mask, so the tracking errs on the safe side. - `d16_float_norm_srv_format` refuses UINT/SINT/typeless/unbound views. This is the right split, because the lowering does `Load` on float4 and narrows with RNE. - Nit: `u()` uses `getattr(self, 'low16_only_v', ())` and `hasattr` checks to support unit probes that build a `Stage` without `__init__`. A small helper or class-level defaults would read better. **Commands run locally (worktree at the PR head)** - `python3 tests/startup_image_load_d16_check.py`: passed (47 float/norm formats match the header, 25 refused, 12 low-16 paths accepted, 18 leaks refused). - `python3 tests/startup_image_load_mip_check.py`: passed. - `python3 tests/docs_links_check.py`: 18 files, 395 links OK. - `python3 tests/bidi_controls_check.py`: OK. - `git diff --check origin/main...HEAD`: clean. - `python3 tests/startup_d16_srv_check.py`: not run standalone. It needs the built consumer/backend arguments (CTest passes them), so it was not exercised on Linux. **Mutations (each reverted with `git checkout -- .`)** - Drop `low16_only=odd_tail` on the odd trailing `set_v`: killed (`odd dmask 0x1 direct export: unexpectedly accepted`). - Replace the SRV format check `fmt not in D16_FLOAT_NORM_SRV_FORMATS` with `False`: killed (exit 1). **Windows proof** - I did not run `x2w_pipe.py win2025`. The branch conflicts with main, so the run would not test what will merge. Please rebase, then a real WARP readback run (`--startup-image-load-d16`) on Win2025 is the proof still needed for the lowering and the new `d3d12_draw.inl` checks. AI-assisted; commands listed were executed locally.
consolelogkyo commented 2026-11-25 03:01:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by consolelogkyo on 2026-11-25T02:26:38Z.


Pushed c805fba3 to address the bound-view format and odd-dmask consumer requirements noted in the Item D review on #2119:

  1. Bound SRV format validation (d16srv <index> float_norm): gfx2hlsl.py validates optional srv_formats and writes d16srv <index> float_norm to <key>.txt when lowering image_load ... d16; src/startup_stubs/d3d12_draw.inl (src/startup_stubs/d16_image_format.h) checks the bound view's effective DXGI_FORMAT before drawing and refuses integer (UINT/SINT), typeless, depth-stencil-only, console stand-in, null-resource and unbound views. Covered by startup_d16_image_format_check (plus --mutate accept-uint control) and end-to-end startup_d16_srv_{warp,hardware} through d3d12_xs.dll on WARP (10.0.26100.9818) and AMD Radeon RX 9070 XT (32.0.32029.2010).
  2. Odd-dmask upper-half consumer gating: gfx2hlsl.py tracks destination VGPRs with hardware-undefined bits 31:16 (popcount(dmask) in {1, 3}) across expressions and basic blocks (forward branches, predicated exec writes and backward loops), refusing whole-word reads while allowing verified low-half consumers (v_cvt_f32_f16, v_cvt_f32_ubyte0/1, SDWA BYTE_0/BYTE_1/WORD_0, v_and_b32 with constant mask <= 0xffff, v_cmp_class_f16/v_cmpx_class_f16, and v_fma_mix* half operands). Covered by 12 accepted / 18 refused consumer controls plus GPU upper-half 0xdead0000 poison and unmasked_odd_hi mutation checks in tests/startup_image_load_d16_check.py.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7150727898 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#issuecomment-7150727898). Originally posted by [consolelogkyo](https://github.com/consolelogkyo) on 2026-11-25T02:26:38Z. --- Pushed `c805fba3` to address the bound-view format and odd-`dmask` consumer requirements noted in the Item D review on #2119: 1. **Bound SRV format validation (`d16srv <index> float_norm`)**: `gfx2hlsl.py` validates optional `srv_formats` and writes `d16srv <index> float_norm` to `<key>.txt` when lowering `image_load ... d16`; `src/startup_stubs/d3d12_draw.inl` (`src/startup_stubs/d16_image_format.h`) checks the bound view's effective `DXGI_FORMAT` before drawing and refuses integer (`UINT`/`SINT`), typeless, depth-stencil-only, console stand-in, null-resource and unbound views. Covered by `startup_d16_image_format_check` (plus `--mutate accept-uint` control) and end-to-end `startup_d16_srv_{warp,hardware}` through `d3d12_xs.dll` on WARP (`10.0.26100.9818`) and AMD Radeon RX 9070 XT (`32.0.32029.2010`). 2. **Odd-`dmask` upper-half consumer gating**: `gfx2hlsl.py` tracks destination VGPRs with hardware-undefined bits `31:16` (`popcount(dmask)` in `{1, 3}`) across expressions and basic blocks (forward branches, predicated `exec` writes and backward loops), refusing whole-word reads while allowing verified low-half consumers (`v_cvt_f32_f16`, `v_cvt_f32_ubyte0`/`1`, `SDWA` `BYTE_0`/`BYTE_1`/`WORD_0`, `v_and_b32` with constant mask `<= 0xffff`, `v_cmp_class_f16`/`v_cmpx_class_f16`, and `v_fma_mix*` half operands). Covered by 12 accepted / 18 refused consumer controls plus GPU upper-half `0xdead0000` poison and `unmasked_odd_hi` mutation checks in `tests/startup_image_load_d16_check.py`. AI-assisted.
R0Y00 commented 2026-11-25 03:01:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T02:31:47Z.


The new bound-format and upper-half checks address separate gaps. The runtime allowlist still accepts R16_UNORM and its vector variants, so it still admits the two previously measured discrepancies. I reproduced the arithmetic on all 65,536 codes: a binary32 intermediate gives ffaf → 3bfe and ffef → 3c00, whereas direct ratio-to-half gives 3bfd and 3bff. A possible narrow fix for R16_UNORM is to recover the exact code first: round-to-integer on binary32(Load * 65535) recovered 65,536/65,536 in this CPU model. Then round the integer ratio directly to half and verify both GPU conversions against the existing native captures. The CPU result alone does not measure the D3D view. Otherwise keep the initial bound allowlist to the independently verified exact formats and retain these two UNORM cases for a follow-up.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7150840709 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#issuecomment-7150840709). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T02:31:47Z. --- The new bound-format and upper-half checks address separate gaps. The runtime allowlist still accepts R16_UNORM and its vector variants, so it still admits the two previously measured discrepancies. I reproduced the arithmetic on all 65,536 codes: a binary32 intermediate gives ffaf → 3bfe and ffef → 3c00, whereas direct ratio-to-half gives 3bfd and 3bff. A possible narrow fix for R16_UNORM is to recover the exact code first: round-to-integer on binary32(Load * 65535) recovered 65,536/65,536 in this CPU model. Then round the integer ratio directly to half and verify both GPU conversions against the existing native captures. The CPU result alone does not measure the D3D view. Otherwise keep the initial bound allowlist to the independently verified exact formats and retain these two UNORM cases for a follow-up.
tedin7 commented 2026-11-25 04:03:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:31:21Z.

Review: COMMENTED


Re-review of head 5f344474dba46f0c81f46c07446c90f7b4e9fb8c (new commits since the last review: 350b00fc, 5f344474).

Blocker: PR is CONFLICTING with main. git merge-tree --write-tree origin/main HEAD reports a content conflict in src/startup_stubs/d3d12_xs_device.cpp. Please rebase on current main and re-run CI. gh pr checks reports no checks on the branch, so there is no CI result for this head yet.

Commands executed locally (Linux):

  • git diff --stat origin/main...HEAD: 18 files, +1953/-28
  • python3 tests/docs_links_check.py: Self-test passed. Checked 18 Markdown files and 404 links.
  • python3 tests/bidi_controls_check.py: no bidirectional controls in 1469 files
  • git diff --check origin/main...HEAD: clean
  • python3 tests/startup_image_load_d16_check.py: passes (14 exact SRV formats match d16_image_format.h, 32 non-exact refused; 12 low-16-bit consumer paths accepted, 18 whole-word/control-flow leaks refused; unsupported layouts refused)
  • python3 tests/startup_image_load_mip_check.py: passes
  • tests/startup_d16_srv_check.py takes CTest arguments, so I did not run it standalone.

Mutations (both reverted with git checkout -- .):

  1. pack16_d16 odd tail low16_only=odd_tail -> False: killed ("odd dmask 0x1 direct export: unexpectedly accepted").
  2. v_and_b32 mask test (c1 & 0xffff0000) == 0 -> == 0xffff0000: killed ("whole-word read of v4 after odd d16 image_load").

Findings:

  • P1: none in the logic. The odd-dmask low-16 tracking, exact-UNORM16 mode and SRV format validation look correct and the tests kill both mutations.
  • P1 (process): rebase needed because of the conflict above. The Windows WARP/D3D12 gate should be run after the rebase, since the diff touches d3d12_draw.inl, d3d12_xs_device.cpp and the C++ tests. I did not queue it on the conflicted head.
  • Nit: getattr(pipe, ...) fallbacks in the image_load d16 branch of gfx2hlsl.py hide a missing pipe state; a plain attribute with a default would be clearer.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051448821 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#pullrequestreview-6051448821). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T03:31:21Z. **Review:** COMMENTED --- Re-review of head `5f344474dba46f0c81f46c07446c90f7b4e9fb8c` (new commits since the last review: `350b00fc`, `5f344474`). **Blocker: PR is CONFLICTING with main.** `git merge-tree --write-tree origin/main HEAD` reports a content conflict in `src/startup_stubs/d3d12_xs_device.cpp`. Please rebase on current main and re-run CI. `gh pr checks` reports no checks on the branch, so there is no CI result for this head yet. **Commands executed locally (Linux):** - `git diff --stat origin/main...HEAD`: 18 files, +1953/-28 - `python3 tests/docs_links_check.py`: Self-test passed. Checked 18 Markdown files and 404 links. - `python3 tests/bidi_controls_check.py`: no bidirectional controls in 1469 files - `git diff --check origin/main...HEAD`: clean - `python3 tests/startup_image_load_d16_check.py`: passes (14 exact SRV formats match `d16_image_format.h`, 32 non-exact refused; 12 low-16-bit consumer paths accepted, 18 whole-word/control-flow leaks refused; unsupported layouts refused) - `python3 tests/startup_image_load_mip_check.py`: passes - `tests/startup_d16_srv_check.py` takes CTest arguments, so I did not run it standalone. **Mutations (both reverted with `git checkout -- .`):** 1. `pack16_d16` odd tail `low16_only=odd_tail` -> `False`: killed ("odd dmask 0x1 direct export: unexpectedly accepted"). 2. `v_and_b32` mask test `(c1 & 0xffff0000) == 0` -> `== 0xffff0000`: killed ("whole-word read of v4 after odd d16 image_load"). **Findings:** - P1: none in the logic. The odd-dmask low-16 tracking, exact-UNORM16 mode and SRV format validation look correct and the tests kill both mutations. - P1 (process): rebase needed because of the conflict above. The Windows WARP/D3D12 gate should be run after the rebase, since the diff touches `d3d12_draw.inl`, `d3d12_xs_device.cpp` and the C++ tests. I did not queue it on the conflicted head. - Nit: `getattr(pipe, ...)` fallbacks in the `image_load` d16 branch of `gfx2hlsl.py` hide a missing pipe state; a plain attribute with a default would be clearer. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 04:03:56 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Re-review of head 8baceea3e6292a573316e7ebd6614da69d145c4f (after rebase).

Scope read: tools/startup/gfx2hlsl.py (low-16-bit tracking, v_and_b32 mask logic, SDWA selectors), src/startup_stubs/d16_image_format.h (SRV format whitelist, manifest parser), tests.

Commands run locally (Linux):

  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: pass (18 files, 405 links)
  • python3 tests/bidi_controls_check.py: pass
  • python3 tests/startup_image_load_d16_check.py: pass (14 exact formats, 32 refused; 12 low-16 paths accepted, 18 leaks refused)
  • python3 tests/startup_image_load_mip_check.py: pass
  • tests/startup_d16_srv_check.py needs C++ binary args, so it was not run on Linux (Windows-only).

CI: Linux Python and gfx1013 fixtures pass. "Build and test on Windows" was still pending when I looked. I did not run a Win2025 job. The D3D12 WARP readback tests are in the PR but are not exercised by my Linux run.

Mutations (reverted afterwards with git checkout -- .):

  1. Disabled the leak check (leak = set()): KILLED ("backward loop odd d16 leak: unexpectedly accepted").
  2. In the v_and_b32 lowering, replaced low16_only=c1 is not None and (c1 & 0xffff0000) == 0 with low16_only=True: SURVIVED. The suite still passes.

Findings

  • P1: none.
  • P2: tools/startup/gfx2hlsl.py (v_and_b32 branch of VEC_U): the mask-operand rule is untested for the non-constant and wide-mask cases. With the mutation above, v_and_b32 vD, v_odd, vMask or & 0xffffffff would read the undefined upper 16 bits and still be accepted. Please add refusal cases to startup_image_load_d16_check.py for (a) a VGPR mask, (b) a constant mask with upper bits set, and (c) the swapped operand order.
  • nit: Stage.exec_known, low16_only_v and the related attributes are class-level defaults. They are replaced with per-instance sets in the translate loop, so nothing is shared. A short comment saying so would help the next reader.

Clean-room/title: the title is neutral and the change is in-repo logic only. No clean-room concern seen. Mergeable: yes.

Verdict: logic looks sound; the P2 is a test gap and does not block.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051480913 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#pullrequestreview-6051480913). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T03:35:54Z. **Review:** COMMENTED --- Re-review of head `8baceea3e6292a573316e7ebd6614da69d145c4f` (after rebase). **Scope read:** `tools/startup/gfx2hlsl.py` (low-16-bit tracking, `v_and_b32` mask logic, SDWA selectors), `src/startup_stubs/d16_image_format.h` (SRV format whitelist, manifest parser), tests. **Commands run locally (Linux):** - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: pass (18 files, 405 links) - `python3 tests/bidi_controls_check.py`: pass - `python3 tests/startup_image_load_d16_check.py`: pass (14 exact formats, 32 refused; 12 low-16 paths accepted, 18 leaks refused) - `python3 tests/startup_image_load_mip_check.py`: pass - `tests/startup_d16_srv_check.py` needs C++ binary args, so it was not run on Linux (Windows-only). **CI:** Linux Python and gfx1013 fixtures pass. "Build and test on Windows" was still pending when I looked. I did not run a Win2025 job. The D3D12 WARP readback tests are in the PR but are not exercised by my Linux run. **Mutations (reverted afterwards with `git checkout -- .`):** 1. Disabled the leak check (`leak = set()`): KILLED ("backward loop odd d16 leak: unexpectedly accepted"). 2. In the `v_and_b32` lowering, replaced `low16_only=c1 is not None and (c1 & 0xffff0000) == 0` with `low16_only=True`: SURVIVED. The suite still passes. **Findings** - P1: none. - P2: `tools/startup/gfx2hlsl.py` (`v_and_b32` branch of `VEC_U`): the mask-operand rule is untested for the non-constant and wide-mask cases. With the mutation above, `v_and_b32 vD, v_odd, vMask` or `& 0xffffffff` would read the undefined upper 16 bits and still be accepted. Please add refusal cases to `startup_image_load_d16_check.py` for (a) a VGPR mask, (b) a constant mask with upper bits set, and (c) the swapped operand order. - nit: `Stage.exec_known`, `low16_only_v` and the related attributes are class-level defaults. They are replaced with per-instance sets in the translate loop, so nothing is shared. A short comment saying so would help the next reader. **Clean-room/title:** the title is neutral and the change is in-repo logic only. No clean-room concern seen. Mergeable: yes. Verdict: logic looks sound; the P2 is a test gap and does not block. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 04:03:56 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Re-review of head 536a626e46d217acdc7f9a9b67dd2667ae737cfe (previous review was on 8baceea3).

Delta read: git diff 8baceea3..536a626 (2 files: tools/startup/gfx2hlsl.py, tests/startup_image_load_d16_check.py). The getattr(pipe, ...) fallbacks in the d16 image_load path became direct self.pipe.resources[...] / self.pipe.srv_formats access, so the SRV format guard and the exact-UNORM16 mode argument can no longer be silently skipped. A comment now documents the class-level defaults. New refusal cases cover the v_and_b32 mask operand.

Commands run locally (Linux):

  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: pass (18 files, 405 links)
  • python3 tests/bidi_controls_check.py: pass (1483 files)
  • python3 tests/startup_image_load_d16_check.py: pass (14 exact formats, 32 refused; 12 low-16 paths accepted, 23 leaks refused)
  • python3 tests/startup_image_load_mip_check.py: pass

CI on this head: Linux Python checks, gfx1013 fixtures and "Build and test on Windows" all pass. I did not run a Win2025 job myself; the D3D12 WARP readback tests are covered by the PR's Windows CI job only.

Mutations (each reverted with git checkout -- .):

  1. v_and_b32 lowering forced to low16_only=True on both operands (the one that survived last time): now KILLED ("v4 vgpr mask lhs: unexpectedly accepted").
  2. SRV format guard disabled (if fmt not in D16_EXACT_SRV_FORMATS -> if False): KILLED ("srv_formats UNKNOWN: unexpectedly accepted").

Findings

  • P1: none.
  • P2: none. The earlier P2 (untested VGPR, wide-constant and swapped-operand mask cases) is fixed with the new lhs/rhs, imm, hex, -1 and SGPR refusal cases.
  • Previous nit (class-level defaults comment): addressed.

Clean-room/title: neutral title, in-repo logic only, no clean-room concern. Mergeable: yes.

Verdict: no blocking findings on this head.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051630110 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#pullrequestreview-6051630110). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T03:54:39Z. **Review:** COMMENTED --- Re-review of head `536a626e46d217acdc7f9a9b67dd2667ae737cfe` (previous review was on `8baceea3`). **Delta read:** `git diff 8baceea3..536a626` (2 files: `tools/startup/gfx2hlsl.py`, `tests/startup_image_load_d16_check.py`). The `getattr(pipe, ...)` fallbacks in the d16 `image_load` path became direct `self.pipe.resources[...]` / `self.pipe.srv_formats` access, so the SRV format guard and the exact-UNORM16 mode argument can no longer be silently skipped. A comment now documents the class-level defaults. New refusal cases cover the `v_and_b32` mask operand. **Commands run locally (Linux):** - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: pass (18 files, 405 links) - `python3 tests/bidi_controls_check.py`: pass (1483 files) - `python3 tests/startup_image_load_d16_check.py`: pass (14 exact formats, 32 refused; 12 low-16 paths accepted, 23 leaks refused) - `python3 tests/startup_image_load_mip_check.py`: pass **CI on this head:** Linux Python checks, gfx1013 fixtures and "Build and test on Windows" all pass. I did not run a Win2025 job myself; the D3D12 WARP readback tests are covered by the PR's Windows CI job only. **Mutations (each reverted with `git checkout -- .`):** 1. `v_and_b32` lowering forced to `low16_only=True` on both operands (the one that survived last time): now KILLED ("v4 vgpr mask lhs: unexpectedly accepted"). 2. SRV format guard disabled (`if fmt not in D16_EXACT_SRV_FORMATS` -> `if False`): KILLED ("srv_formats UNKNOWN: unexpectedly accepted"). **Findings** - P1: none. - P2: none. The earlier P2 (untested VGPR, wide-constant and swapped-operand mask cases) is fixed with the new lhs/rhs, imm, hex, `-1` and SGPR refusal cases. - Previous nit (class-level defaults comment): addressed. **Clean-room/title:** neutral title, in-repo logic only, no clean-room concern. Mergeable: yes. Verdict: no blocking findings on this head. AI-assisted; commands listed were executed locally.
consolelogkyo commented 2026-11-25 04:04:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by consolelogkyo on 2026-11-25T03:29:12Z.


Rebased onto origin/main (009153b7) and addressed all review points from @R0Y00 and @tedin7:

  1. Exact UNORM16 conversion & GPU verification across all 65,536 values (@R0Y00):

    • Added pack16_unorm16(float) alongside pack16_rne(float), selected per SRV via 'udsrc <ud> d16unorm16 <index>' (pack16_d16(t.c, udN)). pack16_unorm16 recovers uint u = uint(saturate(value) * 65535.0 + 0.5) from Load and rounds u / 65535 directly to IEEE binary16 in 32-bit uint arithmetic (firstbithigh(u), u << (26u - msb), quotient + remainder > 32767u; odd 65535 admits no exact halfway ties, and missing .y/.z = 0.0 / .w = 1.0 channels on 1/2-channel R16*_UNORM also map to exact 0x0000 / 0x3c00).
    • Verified both GPU conversions exhaustively across all 65,536 DXGI_FORMAT_R16_UNORM texels (0x0000..0xffff) on AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010) and WARP (10.0.26100.9818) under both DXC and FXC against native RDNA 2 image_load ... d16: 65,536 / 65,536 exact code recoveries (0 mismatches) and 65,536 / 65,536 exact binary16 outputs (0 mismatches, producing 0x3bfd at 0xffaf and 0x3bff at 0xffef).
    • Added both 0xffaf and 0xffef to kDepthTexels (startup_image_load_d16_{warp,hardware}) with a dedicated 'double_round' GPU negative mutation control, and updated startup_d16_srv_{warp,hardware} to test live d16unorm16=1 (R16_UNORM 0xffef -> 0x3bff) alongside d16unorm16=0 (R32_FLOAT 0x3f7ff000 -> 0x3c00) on the same PSO.
  2. Tightened d16srv allowlist to independently GPU-verified exact formats (@R0Y00):

    • Restricted src/startup_stubs/d16_image_format.h (d16_srv_mode / d16_exact_srv_format) and 'd16srv <index> exact' strictly to the 14 GPU-verified exact DXGI_FORMAT values:
      • 11 float_exact (d16unorm16 = 0): the five 32-bit float views (R32G32B32A32_FLOAT, R32G32B32_FLOAT, R32G32_FLOAT, R32_FLOAT, R32_FLOAT_X8X24_TYPELESS) and six 8-bit UNORM views (R8G8B8A8_UNORM, R8G8_UNORM, R8_UNORM, A8_UNORM, B8G8R8A8_UNORM, B8G8R8X8_UNORM, verified 256 / 256 exact on RX 9070 XT and WARP).
      • 3 unorm16 (d16unorm16 = 1): R16G16B16A16_UNORM, R16G16_UNORM, R16_UNORM (65,536 / 65,536 exact).
    • R16*_FLOAT (quiet-NaN payload differences when widened through binary32), SNORM16 (double-rounding at ±32759), R24_UNORM_X8_TYPELESS, SRGB, BCn, packed-target stand-ins (packed_stand_in_of), UINT/SINT, typeless, console extension, null-resource, and unwritten views are all refused.
  3. Rebase, standalone Linux HLSL helper coverage, NaN sign, and cleanups (@tedin7):

    • Rebased onto origin/main (009153b7), resolving the Pipeline.__init__ overlap with #2144, the tests/startup_address_srv.cpp overlap with #2157, and the header include overlap with #2169.
    • check_rounding_formula() in tests/startup_image_load_d16_check.py now checks PACK16_HELPERS_HLSL verbatim in the emitted HLSL and transpiles/executes the live pack16_rne and pack16_unorm16 HLSL bodies on Linux and Windows across 320 boundary floats, all 256 UNORM8 values, and all 65,536 R16_UNORM values, with self-tests proving that dropping + ((shifted >> 13) & 1u) (0x3f803000) or mutating > 32767u (0xffaf) fails without needing a GPU.
    • Updated pack16_rne to preserve NaN sign (sign | 0x7e00u), matching RDNA 2 hardware narrowing on binary32 NaNs (0x7fc00001 -> 0x7e00, 0xffc00123 -> 0xfe00).
    • Restored an explicit image_load_mip + d16 refusal check in tests/startup_image_load_mip_check.py.
    • Replaced scattered getattr(self, ...) checks on Stage and Pipeline with class-level defaults and Stage.note_whole_read().

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7151959520 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#issuecomment-7151959520). Originally posted by [consolelogkyo](https://github.com/consolelogkyo) on 2026-11-25T03:29:12Z. --- Rebased onto `origin/main` (`009153b7`) and addressed all review points from @R0Y00 and @tedin7: 1. **Exact `UNORM16` conversion & GPU verification across all 65,536 values (@R0Y00):** - Added `pack16_unorm16(float)` alongside `pack16_rne(float)`, selected per SRV via `'udsrc <ud> d16unorm16 <index>'` (`pack16_d16(t.c, udN)`). `pack16_unorm16` recovers `uint u = uint(saturate(value) * 65535.0 + 0.5)` from `Load` and rounds `u / 65535` directly to IEEE binary16 in 32-bit `uint` arithmetic (`firstbithigh(u)`, `u << (26u - msb)`, quotient + remainder `> 32767u`; odd `65535` admits no exact halfway ties, and missing `.y/.z = 0.0` / `.w = 1.0` channels on 1/2-channel `R16*_UNORM` also map to exact `0x0000` / `0x3c00`). - Verified both GPU conversions exhaustively across **all 65,536** `DXGI_FORMAT_R16_UNORM` texels (`0x0000..0xffff`) on AMD Radeon RX 9070 XT (`1002:7550`, driver `32.0.32029.2010`) and WARP (`10.0.26100.9818`) under both DXC and FXC against native RDNA 2 `image_load ... d16`: **65,536 / 65,536** exact code recoveries (`0` mismatches) and **65,536 / 65,536** exact binary16 outputs (`0` mismatches, producing `0x3bfd` at `0xffaf` and `0x3bff` at `0xffef`). - Added both `0xffaf` and `0xffef` to `kDepthTexels` (`startup_image_load_d16_{warp,hardware}`) with a dedicated `'double_round'` GPU negative mutation control, and updated `startup_d16_srv_{warp,hardware}` to test live `d16unorm16=1` (`R16_UNORM` `0xffef -> 0x3bff`) alongside `d16unorm16=0` (`R32_FLOAT` `0x3f7ff000 -> 0x3c00`) on the same PSO. 2. **Tightened `d16srv` allowlist to independently GPU-verified exact formats (@R0Y00):** - Restricted `src/startup_stubs/d16_image_format.h` (`d16_srv_mode` / `d16_exact_srv_format`) and `'d16srv <index> exact'` strictly to the **14** GPU-verified exact `DXGI_FORMAT` values: - `11` `float_exact` (`d16unorm16 = 0`): the five 32-bit float views (`R32G32B32A32_FLOAT`, `R32G32B32_FLOAT`, `R32G32_FLOAT`, `R32_FLOAT`, `R32_FLOAT_X8X24_TYPELESS`) and six 8-bit `UNORM` views (`R8G8B8A8_UNORM`, `R8G8_UNORM`, `R8_UNORM`, `A8_UNORM`, `B8G8R8A8_UNORM`, `B8G8R8X8_UNORM`, verified `256 / 256` exact on RX 9070 XT and WARP). - `3` `unorm16` (`d16unorm16 = 1`): `R16G16B16A16_UNORM`, `R16G16_UNORM`, `R16_UNORM` (`65,536 / 65,536` exact). - `R16*_FLOAT` (quiet-NaN payload differences when widened through binary32), `SNORM16` (double-rounding at `±32759`), `R24_UNORM_X8_TYPELESS`, `SRGB`, `BCn`, packed-target stand-ins (`packed_stand_in_of`), `UINT`/`SINT`, typeless, console extension, null-resource, and unwritten views are all refused. 3. **Rebase, standalone Linux HLSL helper coverage, NaN sign, and cleanups (@tedin7):** - Rebased onto `origin/main` (`009153b7`), resolving the `Pipeline.__init__` overlap with #2144, the `tests/startup_address_srv.cpp` overlap with #2157, and the header include overlap with #2169. - `check_rounding_formula()` in `tests/startup_image_load_d16_check.py` now checks `PACK16_HELPERS_HLSL` verbatim in the emitted HLSL and transpiles/executes the live `pack16_rne` and `pack16_unorm16` HLSL bodies on Linux and Windows across 320 boundary floats, all 256 `UNORM8` values, and all 65,536 `R16_UNORM` values, with self-tests proving that dropping `+ ((shifted >> 13) & 1u)` (`0x3f803000`) or mutating `> 32767u` (`0xffaf`) fails without needing a GPU. - Updated `pack16_rne` to preserve NaN sign (`sign | 0x7e00u`), matching RDNA 2 hardware narrowing on binary32 NaNs (`0x7fc00001 -> 0x7e00`, `0xffc00123 -> 0xfe00`). - Restored an explicit `image_load_mip` + `d16` refusal check in `tests/startup_image_load_mip_check.py`. - Replaced scattered `getattr(self, ...)` checks on `Stage` and `Pipeline` with class-level defaults and `Stage.note_whole_read()`. AI-assisted.
consolelogkyo commented 2026-11-25 04:04:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by consolelogkyo on 2026-11-25T03:49:50Z.


Thanks @tedin7! Pushed an update addressing those remaining items:

  • v_and_b32 mask-operand refusal coverage (tests/startup_image_load_d16_check.py): added refusal controls for VGPR masks (v_and_b32_e32 v5, v2, v4 and v5, v4, v2) and wide immediate/SGPR masks in both operand positions (0x1ffff, -1, and s25 in both src0 and src1, expanding the odd-dmask leak suite to 23 refused sequences).
  • Stage / Pipeline attribute cleanup (tools/startup/gfx2hlsl.py): documented that Stage's class-level defaults are immutable fallbacks replaced with fresh per-instance sets in __init__ / translate(), and removed the remaining getattr(self, 'pipe', ...) / getattr(pipe, ...) wrappers in Stage.image().

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7152280345 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#issuecomment-7152280345). Originally posted by [consolelogkyo](https://github.com/consolelogkyo) on 2026-11-25T03:49:50Z. --- Thanks @tedin7! Pushed an update addressing those remaining items: - **`v_and_b32` mask-operand refusal coverage (`tests/startup_image_load_d16_check.py`):** added refusal controls for VGPR masks (`v_and_b32_e32 v5, v2, v4` and `v5, v4, v2`) and wide immediate/SGPR masks in both operand positions (`0x1ffff`, `-1`, and `s25` in both `src0` and `src1`, expanding the odd-`dmask` leak suite to 23 refused sequences). - **`Stage` / `Pipeline` attribute cleanup (`tools/startup/gfx2hlsl.py`):** documented that `Stage`'s class-level defaults are immutable fallbacks replaced with fresh per-instance sets in `__init__` / `translate()`, and removed the remaining `getattr(self, 'pipe', ...)` / `getattr(pipe, ...)` wrappers in `Stage.image()`. AI-assisted.
thepatrickworld commented 2026-11-25 04:04:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-25T03:57:30Z.


Hardware run of the draw stage on the current head 536a626e — RX 9070 XT, driver 32.0.32029.2010, with fxc ps_5_1 in the loop:

fxc negative control (swap_halves):     rejected against reference and matched mutated model
fxc negative control (drop_shift):      rejected against reference and matched mutated model
fxc negative control (drop_a16):        rejected against reference and matched mutated model
fxc negative control (drop_nsa):        rejected against reference and matched mutated model
fxc negative control (unmasked_odd_hi): rejected against reference and matched mutated model

Both pixel fixtures (8x2 R16_UNORM including 0xffaf and 0xffef) read back as the reference on the card, and all five mutations are caught, which is what makes the match worth something.

Note: the head moved from 8baceea3 to 536a626e while I was running, so this is a second run on the new head; the earlier one had four controls, this one five.

Limits: AMD only, no NVIDIA here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7152397051 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#issuecomment-7152397051). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-25T03:57:30Z. --- Hardware run of the draw stage on the current head `536a626e` — RX 9070 XT, driver 32.0.32029.2010, with fxc `ps_5_1` in the loop: ``` fxc negative control (swap_halves): rejected against reference and matched mutated model fxc negative control (drop_shift): rejected against reference and matched mutated model fxc negative control (drop_a16): rejected against reference and matched mutated model fxc negative control (drop_nsa): rejected against reference and matched mutated model fxc negative control (unmasked_odd_hi): rejected against reference and matched mutated model ``` Both pixel fixtures (8x2 R16_UNORM including `0xffaf` and `0xffef`) read back as the reference on the card, and all five mutations are caught, which is what makes the match worth something. Note: the head moved from `8baceea3` to `536a626e` while I was running, so this is a second run on the new head; the earlier one had four controls, this one five. Limits: AMD only, no NVIDIA here. _AI-assisted._
upstream-sync closed this pull request 2026-11-25 05:04:41 +00:00
R0Y00 commented 2026-11-25 05:04:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T04:44:31Z.

Review: APPROVED


Re-reviewed 536a626e. The previous changes request is addressed. The runtime checks the bound SRV format, and the UNORM16 path recovers the integer code before rounding the exact ratio to binary16. The prior mismatch inputs now produce 0xffaf → 0x3bfd and 0xffef → 0x3bff. The upper-half guard rejects the new variable and wide-mask consumers. #2119 was closed in favor of this level-zero implementation.

Independent Windows Release run: ctest --preset release --no-tests=error -R "^startup_(image_load_(d16|mip)|d16_)" -V passed 10/10 with no skips on WARP and RTX 4060 Laptop (driver 32.0.16.1656). DXC and FXC both caught the deliberate double-rounding and upper-half mutations. The exhaustive GPU comparison across all 65,536 UNORM16 codes is the contributor’s RX 9070 XT/WARP result.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051978792 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#pullrequestreview-6051978792). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T04:44:31Z. **Review:** APPROVED --- Re-reviewed `536a626e`. The previous changes request is addressed. The runtime checks the bound SRV format, and the UNORM16 path recovers the integer code before rounding the exact ratio to binary16. The prior mismatch inputs now produce `0xffaf → 0x3bfd` and `0xffef → 0x3bff`. The upper-half guard rejects the new variable and wide-mask consumers. #2119 was closed in favor of this level-zero implementation. Independent Windows Release run: `ctest --preset release --no-tests=error -R "^startup_(image_load_(d16|mip)|d16_)" -V` passed 10/10 with no skips on WARP and RTX 4060 Laptop (driver 32.0.16.1656). DXC and FXC both caught the deliberate double-rounding and upper-half mutations. The exhaustive GPU comparison across all 65,536 UNORM16 codes is the contributor’s RX 9070 XT/WARP result.
thepatrickworld commented 2026-11-25 11:02:35 +00:00 (Migrated from github.com)

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


Correction to my comment above: there are eight negative controls, not five, and they run under both compilers.

draw2139b.log has sixteen negative control lines — rtz, double_round, unpacked_x, swap_halves, drop_shift, drop_a16, drop_nsa, unmasked_odd_hi, each one eight times under dxc and eight under fxc, all rejected against reference and matched mutated model.

I had read the last five lines of the log and written "all five mutations are caught". The match is worth more than I said, not less, but the count was wrong. The same applies to "the earlier one had four controls": that was also a tail read, not a count.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7160506484 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#issuecomment-7160506484). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-25T11:02:26Z. --- Correction to my comment above: there are **eight** negative controls, not five, and they run under both compilers. `draw2139b.log` has sixteen `negative control` lines — `rtz`, `double_round`, `unpacked_x`, `swap_halves`, `drop_shift`, `drop_a16`, `drop_nsa`, `unmasked_odd_hi`, each one eight times under `dxc` and eight under `fxc`, all `rejected against reference and matched mutated model`. I had read the last five lines of the log and written "all five mutations are caught". The match is worth more than I said, not less, but the count was wrong. The same applies to "the earlier one had four controls": that was also a tail read, not a count. _AI-assisted._
thepatrickworld commented 2026-11-25 12:01:53 +00:00 (Migrated from github.com)

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


One more correction, on the description of the fixtures rather than the count.

I wrote "Both pixel fixtures (8x2 R16_UNORM including 0xffaf and 0xffef)". What the log actually says, under each compiler, is:

dxc r16_unorm: fixtures A/B and odd-dmask upper-half poison check matched all words
fxc r16_unorm: fixtures A/B and odd-dmask upper-half poison check matched all words

No dimensions, and 0xffaf appears nowhere in this branch — I checked tests/ and tools/. 0xffef is in tests/pixel_aot_check.py, but not as part of this draw fixture. So the dimensions and one of the two values were me dressing the sentence up. The measurement itself (fixtures A/B and the odd-dmask poison check matched all words, 8 controls per compiler) is what the log supports.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7160824957 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2139#issuecomment-7160824957). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-25T11:16:19Z. --- One more correction, on the description of the fixtures rather than the count. I wrote "Both pixel fixtures (8x2 R16_UNORM including `0xffaf` and `0xffef`)". What the log actually says, under each compiler, is: ``` dxc r16_unorm: fixtures A/B and odd-dmask upper-half poison check matched all words fxc r16_unorm: fixtures A/B and odd-dmask upper-half poison check matched all words ``` No dimensions, and `0xffaf` appears nowhere in this branch — I checked `tests/` and `tools/`. `0xffef` is in `tests/pixel_aot_check.py`, but not as part of this draw fixture. So the dimensions and one of the two values were me dressing the sentence up. The measurement itself (fixtures A/B and the odd-dmask poison check matched all words, 8 controls per compiler) is what the log supports. _AI-assisted._
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!2131
No description provided.