shader: lower four gfx1030 pixel sample offset forms #1444

Merged
stan495 merged 1 commit from upstream-pr/1451 into main 2026-11-24 12:29:43 +00:00
stan495 commented 2026-11-24 11:46:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T11:46:28Z.


Summary

Lower image_sample_o, image_sample_b_o, image_sample_l_o and image_sample_lz_o on a single 2D RGBA texture. These forms take a statically known packed XY DWORD before the existing address operands. The lowerer sign-extends both six-bit components and checks the DXIL immediate range [-8, 7]. The profile uses matching texture and sampler state, integer mip levels for offset sampling, contiguous FP32 addresses and dmask:0xf.

The pixel container entry point accepts --cpu gfx1030 and uses wave64 for decoding, including the internal two-exit control-flow check. The default gfx1013 path is unchanged.

Verification

Tested clean head 772ac100a416a4c7c5280ce64364960d34d0c971.

. .\tools\dev.ps1
cmake --preset dev -DINTAKE_PYTHON=<python.exe>
cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^pixel_aot_(sample_offset|sample_lod|dmask)_(warp|hardware)$' -V --output-junit out/sample-offset-results.xml
python -B tools/form_coverage.py out/sample-offset-results.xml --records out/build/dev/form_coverage --json out/sample-offset-coverage.json
python -B tests/form_coverage_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py

CTest reported 6 passed, 0 failed, 0 skipped. The WARP and physical runs compared translated DXIL against the CPU UV ramp across all exported channels and checked mip selection with a separate two-mip texture. All four new forms appear in each passing offset fixture's form record. The zero-offset mutant first differs at pixel (0,0), channel 0, for all four forms (3d808000 expected, 00000000 actual). Further mutations change level or bias to zero and replace explicit LOD zero with implicit sampling. Invalid masks, modifier bits, nonconstant offsets, out-of-range offsets and wrong sampler bindings are rejected.

Windows 11 build 26300.9974, WARP Microsoft Basic Render Driver 10.0.26100.9818, and Intel Arc B390 32.0.101.8509. The debug layer was unavailable on both backends.

python3 -B tests/pixel_sample_offset_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1

LLVM 15 assembles and disassembles each gfx1030 source fixture. The pixel container CLI gives identical HLSL to the direct translator. The patch passed git diff --check and git merge-tree --write-tree origin/main HEAD against e84829ded9ca2dff3710b879d37d28986b717cb6.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6581039690 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1451). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T11:46:28Z. --- ## Summary Lower `image_sample_o`, `image_sample_b_o`, `image_sample_l_o` and `image_sample_lz_o` on a single 2D RGBA texture. These forms take a statically known packed XY DWORD before the existing address operands. The lowerer sign-extends both six-bit components and checks the DXIL immediate range `[-8, 7]`. The profile uses matching texture and sampler state, integer mip levels for offset sampling, contiguous FP32 addresses and `dmask:0xf`. The pixel container entry point accepts `--cpu gfx1030` and uses wave64 for decoding, including the internal two-exit control-flow check. The default gfx1013 path is unchanged. ## Verification Tested clean head `772ac100a416a4c7c5280ce64364960d34d0c971`. ```powershell . .\tools\dev.ps1 cmake --preset dev -DINTAKE_PYTHON=<python.exe> cmake --build --preset dev --target offscreen_check ctest --preset dev --no-tests=error -R '^pixel_aot_(sample_offset|sample_lod|dmask)_(warp|hardware)$' -V --output-junit out/sample-offset-results.xml python -B tools/form_coverage.py out/sample-offset-results.xml --records out/build/dev/form_coverage --json out/sample-offset-coverage.json python -B tests/form_coverage_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` CTest reported 6 passed, 0 failed, 0 skipped. The WARP and physical runs compared translated DXIL against the CPU UV ramp across all exported channels and checked mip selection with a separate two-mip texture. All four new forms appear in each passing offset fixture's form record. The zero-offset mutant first differs at pixel `(0,0)`, channel 0, for all four forms (`3d808000` expected, `00000000` actual). Further mutations change level or bias to zero and replace explicit LOD zero with implicit sampling. Invalid masks, modifier bits, nonconstant offsets, out-of-range offsets and wrong sampler bindings are rejected. Windows 11 build `26300.9974`, WARP Microsoft Basic Render Driver `10.0.26100.9818`, and Intel Arc B390 `32.0.101.8509`. The debug layer was unavailable on both backends. ```sh python3 -B tests/pixel_sample_offset_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` LLVM 15 assembles and disassembles each gfx1030 source fixture. The pixel container CLI gives identical HLSL to the direct translator. The patch passed `git diff --check` and `git merge-tree --write-tree origin/main HEAD` against `e84829ded9ca2dff3710b879d37d28986b717cb6`.
upstream-sync closed this pull request 2026-11-24 13:00:30 +00:00
tedin7 commented 2026-11-24 13:00:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:06:51Z.

Review: COMMENTED


Dual-platform peer review at commit 772ac100a416a4c7c5280ce64364960d34d0c971.

Audit

  • tools/pixel_aot.py & tests/pixel_sample_offset_check.py:
    • Lowers image_sample_o, image_sample_b_o, image_sample_l_o, and image_sample_lz_o on single 2D RGBA textures (dmask:0xf), popping the leading packed offset VGPR, checking sample_dest (vmcnt hazard), requiring a known canonical 2D word (packed & ~0x3f3f == 0), sign-extending the 6-bit X ([5:0]) and Y ([13:8]) fields, and enforcing the DXIL immediate range [-8, 7].
    • --cpu gfx1030 selects +wavefrontsize64,-wavefrontsize32 for both native_program and disassemble, leaving the default gfx1013 path unchanged.
    • Negative controls cover out-of-range offsets (0x8, 0x3700), non-canonical packed words (0x10000, 0x40), undefined/runtime offsets, vmcnt overlap, dmask != 0xf, SQ_RSRC_IMG_3D, a16/d16, and wrong sampler bindings.
  • Hygiene & Docs:
    • git diff --check origin/main..HEAD: clean.
    • python3 tests/docs_links_check.py: passed (16 Markdown files, 325 links).
    • python3 tests/bidi_controls_check.py: passed (1188 files).
    • Title-neutrality: clean.

Linux Checks

  • python3 -B tests/pixel_sample_offset_check.py: passed (Four 2D sample offset forms checked).
  • python3 -B tests/pixel_sample_offset_check.py binary llvm-mc-19 llvm-objcopy-19 /lib/x86_64-linux-gnu/libLLVM.so.19.1: passed.

Verification on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check -- -j 6): 28.47s
    • Test (ctest --preset dev -R '^pixel_aot_(sample_offset|sample_lod|dmask)_(warp|hardware)$' --parallel 4 --no-tests=error --output-on-failure): 6/6 passed (pixel_aot_dmask_warp 3.86s, pixel_aot_dmask_hardware 3.90s, pixel_aot_sample_lod_hardware 4.11s, pixel_aot_sample_offset_hardware 4.36s, pixel_aot_sample_lod_warp 3.57s, pixel_aot_sample_offset_warp 3.93s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check -- -j 6): 40.87s
    • Test (ctest --preset release -R '^pixel_aot_(sample_offset|sample_lod|dmask)_(warp|hardware)$' --parallel 4 --no-tests=error --output-on-failure): 6/6 passed (pixel_aot_dmask_hardware 3.87s, pixel_aot_dmask_warp 3.92s, pixel_aot_sample_lod_hardware 4.09s, pixel_aot_sample_offset_hardware 4.53s, pixel_aot_sample_lod_warp 3.70s, pixel_aot_sample_offset_warp 4.01s)
  • Windows Python checks: tests/form_coverage_check.py ok (41.5s).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6038893239 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1451#pullrequestreview-6038893239). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T12:06:51Z. **Review:** COMMENTED --- Dual-platform peer review at commit `772ac100a416a4c7c5280ce64364960d34d0c971`. ### Audit - **`tools/pixel_aot.py` & `tests/pixel_sample_offset_check.py`**: - Lowers `image_sample_o`, `image_sample_b_o`, `image_sample_l_o`, and `image_sample_lz_o` on single 2D RGBA textures (`dmask:0xf`), popping the leading packed offset VGPR, checking `sample_dest` (`vmcnt` hazard), requiring a known canonical 2D word (`packed & ~0x3f3f == 0`), sign-extending the 6-bit X (`[5:0]`) and Y (`[13:8]`) fields, and enforcing the DXIL immediate range `[-8, 7]`. - `--cpu gfx1030` selects `+wavefrontsize64,-wavefrontsize32` for both `native_program` and `disassemble`, leaving the default `gfx1013` path unchanged. - Negative controls cover out-of-range offsets (`0x8`, `0x3700`), non-canonical packed words (`0x10000`, `0x40`), undefined/runtime offsets, `vmcnt` overlap, `dmask != 0xf`, `SQ_RSRC_IMG_3D`, `a16`/`d16`, and wrong sampler bindings. - **Hygiene & Docs**: - `git diff --check origin/main..HEAD`: clean. - `python3 tests/docs_links_check.py`: passed (16 Markdown files, 325 links). - `python3 tests/bidi_controls_check.py`: passed (1188 files). - Title-neutrality: clean. ### Linux Checks - `python3 -B tests/pixel_sample_offset_check.py`: passed (`Four 2D sample offset forms checked`). - `python3 -B tests/pixel_sample_offset_check.py binary llvm-mc-19 llvm-objcopy-19 /lib/x86_64-linux-gnu/libLLVM.so.19.1`: passed. ### Verification on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target offscreen_check -- -j 6`): `28.47s` - Test (`ctest --preset dev -R '^pixel_aot_(sample_offset|sample_lod|dmask)_(warp|hardware)$' --parallel 4 --no-tests=error --output-on-failure`): **6/6 passed** (`pixel_aot_dmask_warp` `3.86s`, `pixel_aot_dmask_hardware` `3.90s`, `pixel_aot_sample_lod_hardware` `4.11s`, `pixel_aot_sample_offset_hardware` `4.36s`, `pixel_aot_sample_lod_warp` `3.57s`, `pixel_aot_sample_offset_warp` `3.93s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target offscreen_check -- -j 6`): `40.87s` - Test (`ctest --preset release -R '^pixel_aot_(sample_offset|sample_lod|dmask)_(warp|hardware)$' --parallel 4 --no-tests=error --output-on-failure`): **6/6 passed** (`pixel_aot_dmask_hardware` `3.87s`, `pixel_aot_dmask_warp` `3.92s`, `pixel_aot_sample_lod_hardware` `4.09s`, `pixel_aot_sample_offset_hardware` `4.53s`, `pixel_aot_sample_lod_warp` `3.70s`, `pixel_aot_sample_offset_warp` `4.01s`) - **Windows Python checks**: `tests/form_coverage_check.py` ok (`41.5s`).
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!1444
No description provided.