native: accept CLAMP_BORDER on level-zero comparison samplers #3528

Manually merged
github merged 2 commits from github-bot/gh-3526 into gh-pr/3526/base 2026-11-30 09:03:29 +00:00 AGit
Owner

@⁠JB2WIN on GitHub · 2026-11-29 22:56 UTC · original
JB2WIN:native/comparison-border → main · +122 −34 · 3 files · 2 commits · merged 2026-11-30 08:59 UTC

Change

A literal comparison sampler in native compute (sampler_index, src/gfx1013_compute_native.cpp) was accepted only with CLAMP_LAST_TEXEL on both U and V ((address & 63) == 0x12). decode_sampler already binds the address mode per axis and the static border colour. So a level-zero comparison sample (image_sample_c_lz) now also accepts CLAMP_BORDER (6) on U, on V, or on both. These are the rules of pixel_aot.comparison_sampler_state(..., allow_border=True), which the Python path already uses.

With a BORDER axis there are two refusals, each with its own reason. Border colour type 3 (REGISTER, indexed by BORDER_COLOR_PTR) has no static border colour. Comparison gathers (gather4_c_lz) and implicit-LOD comparison samples have no border model (check_gather_sampler allows only CLAMP_LAST_TEXEL). MIRROR_ONCE_BORDER (7), half-border, wrap and mirror stay refused.

Refs #3226, #3023. Follows #3526. On my local #3023 prototype route, 299 compute requests use a comparison sampler with CLAMP_BORDER on U and V and, with #3526, the constant word 3 0x80000000 (OPAQUE_WHITE). On main they stop earlier, at the resource heap, so this moves no request there by itself.

Verification

Build cmake --preset release / cmake --build --preset release on 2ff74a6a, Windows 11, NVIDIA GeForce RTX 3080, hardware adapter.

  • startup_compute_dispatch_native_check.py step 5, new border variant on hardware: the comparison sampler gets CLAMP_BORDER on U and OPAQUE_WHITE, and the reference base becomes 0.1875. Only thread x = 2 (u = 1.2, outside, 0.75 < 1.0) passes, which separates a white border from a black one (0) and from a clamped texel (about -0.5). All 6144 volume words match the CPU model, and the debug layer reports no error. The original step 5 runs unchanged before it.
  • native_direct_container_check.py: BORDER on U, on V and on both compiles, and so does OPAQUE_WHITE. V = 7 refuses with unsupported comparison sampler fields. Border type 3 refuses with comparison sampler border colour from the border colour register. gather4_c_lz and the pixel-stage image_sample_c with BORDER refuse with comparison gather or implicit-LOD sample with a CLAMP_BORDER axis.
  • ctest -R 'native_direct_container|startup_compute_dispatch_native|native_gather_compare|native_sampler_heap|inline_sampler': 9/9 pass. native_sampler_heap_warp and startup_compute_dispatch_native_warp skip (wave32), as on main.
  • With src/ reverted (stash, rebuild): native_direct_container fails with unsupported comparison sampler fields, and the hardware border variant is not translated.
  • Not covered: CLAMP_Z stays unchecked, as before this change. decode_sampler sets AddressW from it, which has no effect on a 2D or 2D-array view.

Evidence and follow-up

All fixtures are source-built and use the existing comparison_program() and step 5 programs. No game data.

Next on the prototype route: gather through the sampler heap is not translated, then the runtime sampler-heap binding (#3076 stage 2a, in progress).

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (no doc lists the native comparison profile)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

🤖 Generated with Claude Code

**@⁠JB2WIN** on GitHub · 2026-11-29 22:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3526) `JB2WIN:native/comparison-border` → `main` · +122 −34 · 3 files · 2 commits · merged 2026-11-30 08:59 UTC ## Change A literal comparison sampler in native compute (`sampler_index`, `src/gfx1013_compute_native.cpp`) was accepted only with CLAMP_LAST_TEXEL on both U and V (`(address & 63) == 0x12`). `decode_sampler` already binds the address mode per axis and the static border colour. So a level-zero comparison sample (`image_sample_c_lz`) now also accepts CLAMP_BORDER (6) on U, on V, or on both. These are the rules of `pixel_aot.comparison_sampler_state(..., allow_border=True)`, which the Python path already uses. With a BORDER axis there are two refusals, each with its own reason. Border colour type 3 (REGISTER, indexed by BORDER_COLOR_PTR) has no static border colour. Comparison gathers (`gather4_c_lz`) and implicit-LOD comparison samples have no border model (`check_gather_sampler` allows only CLAMP_LAST_TEXEL). MIRROR_ONCE_BORDER (7), half-border, wrap and mirror stay refused. Refs #3226, #3023. Follows #3526. On my local #3023 prototype route, 299 compute requests use a comparison sampler with CLAMP_BORDER on U and V and, with #3526, the constant word 3 0x80000000 (OPAQUE_WHITE). On `main` they stop earlier, at the resource heap, so this moves no request there by itself. ## Verification Build `cmake --preset release` / `cmake --build --preset release` on `2ff74a6a`, Windows 11, NVIDIA GeForce RTX 3080, hardware adapter. - `startup_compute_dispatch_native_check.py` step 5, new border variant on hardware: the comparison sampler gets CLAMP_BORDER on U and OPAQUE_WHITE, and the reference base becomes 0.1875. Only thread x = 2 (u = 1.2, outside, 0.75 < 1.0) passes, which separates a white border from a black one (0) and from a clamped texel (about -0.5). All 6144 volume words match the CPU model, and the debug layer reports no error. The original step 5 runs unchanged before it. - `native_direct_container_check.py`: BORDER on U, on V and on both compiles, and so does OPAQUE_WHITE. V = 7 refuses with `unsupported comparison sampler fields`. Border type 3 refuses with `comparison sampler border colour from the border colour register`. `gather4_c_lz` and the pixel-stage `image_sample_c` with BORDER refuse with `comparison gather or implicit-LOD sample with a CLAMP_BORDER axis`. - `ctest -R 'native_direct_container|startup_compute_dispatch_native|native_gather_compare|native_sampler_heap|inline_sampler'`: 9/9 pass. `native_sampler_heap_warp` and `startup_compute_dispatch_native_warp` skip (wave32), as on main. - With `src/` reverted (stash, rebuild): `native_direct_container` fails with `unsupported comparison sampler fields`, and the hardware border variant is not translated. - Not covered: CLAMP_Z stays unchecked, as before this change. `decode_sampler` sets AddressW from it, which has no effect on a 2D or 2D-array view. ## Evidence and follow-up All fixtures are source-built and use the existing `comparison_program()` and step 5 programs. No game data. Next on the prototype route: `gather through the sampler heap is not translated`, then the runtime sampler-heap binding (#3076 stage 2a, in progress). ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. (no doc lists the native comparison profile) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A literal comparison sampler was accepted only with CLAMP_LAST_TEXEL on
both U and V. decode_sampler already binds the address mode per axis and
the static border colour, so a level-zero comparison sample (c_lz) now
also accepts CLAMP_BORDER (6) on either axis, like
pixel_aot.comparison_sampler_state with allow_border. With a BORDER
axis, border colour type 3 (REGISTER) has no static border colour and
is refused, and so are comparison gathers and implicit-LOD comparison
samples, which have no border model. MIRROR_ONCE_BORDER (7) stays
refused.

Step 5 of startup_compute_dispatch_native_check.py runs a border variant
on hardware: CLAMP_BORDER on U, OPAQUE_WHITE, a positive reference.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 22:57:10 +00:00
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 23:09 UTC · original · reviewed

Diff-only review at 343979bd (not built here). The logic matches pixel_aot.comparison_sampler_state(allow_border=True): X and Y each 2 or 6, REGISTER (type 3) refused only when an axis is BORDER, CLAMP_Z not read; decode_sampler has no colour for type 3, so that refusal is needed. With gather (79) and implicit (40) refused, only c_lz (47) reaches BORDER.

  • #3519 point 1 is moot now that word 3 is the literal word, but no native test sets word 3 bits 29:12, so (border & 0x3ffff000) at gfx1013_compute_native.cpp:1180 is unpinned. A case with word 3 = 0x80001000 expecting "unsupported comparison sampler fields" would pin it.
  • #3519 point 2: the CLAMP_Z = 7 case is not in the test. 0x0800103a is V = 7, which pins == 6 against >= 6. Z is not read on 2D, so a Z = 7 case (0x080011d2) should be an accepted one.
  • Every refusal case (register, gather, implicit) uses U = 6 (0x08001016), so changing u == 6 || v == 6 at :1182 to u == 6 would pass the tests. A refusal case with a V-only border (0x08001032, word 3 = 0xc0000000) would catch it.
  • Minor, already there before this PR: no native test refuses wrap/mirror (0/1) on X or Y for a comparison sampler.
**@⁠Leyukaka** on GitHub · 2026-11-29 23:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3526#pullrequestreview-6105290444) · **reviewed** Diff-only review at 343979bd (not built here). The logic matches `pixel_aot.comparison_sampler_state(allow_border=True)`: X and Y each 2 or 6, REGISTER (type 3) refused only when an axis is BORDER, CLAMP_Z not read; `decode_sampler` has no colour for type 3, so that refusal is needed. With gather (79) and implicit (40) refused, only `c_lz` (47) reaches BORDER. - #3519 point 1 is moot now that word 3 is the literal word, but no native test sets word 3 bits 29:12, so `(border & 0x3ffff000)` at `gfx1013_compute_native.cpp:1180` is unpinned. A case with word 3 = `0x80001000` expecting "unsupported comparison sampler fields" would pin it. - #3519 point 2: the CLAMP_Z = 7 case is not in the test. `0x0800103a` is V = 7, which pins `== 6` against `>= 6`. Z is not read on 2D, so a Z = 7 case (`0x080011d2`) should be an accepted one. - Every refusal case (register, gather, implicit) uses U = 6 (`0x08001016`), so changing `u == 6 || v == 6` at `:1182` to `u == 6` would pass the tests. A refusal case with a V-only border (`0x08001032`, word 3 = `0xc0000000`) would catch it. - Minor, already there before this PR: no native test refuses wrap/mirror (0/1) on X or Y for a comparison sampler.
Author
Owner

@⁠JB2WIN on GitHub · 2026-11-29 23:20 UTC · original

@⁠Leyukaka all four are in b06f0e06 (native_direct_container_check.py):

  • Word 3 0x80001000 with U = 6 refuses with unsupported comparison sampler fields.
  • 0x080011d2 (Z = 7) compiles.
  • A V-only border (0x08001032) refuses with word 3 0xc0000000 (register reason) and on gather4_c_lz, which pins u == 6 || v == 6.
  • Wrap (0x08001010) and mirror (0x08001011) on U refuse.

ctest -R native_direct_container passes.

AI-assisted.

**@⁠JB2WIN** on GitHub · 2026-11-29 23:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3526#issuecomment-7264387832) @⁠Leyukaka all four are in b06f0e06 (`native_direct_container_check.py`): - Word 3 `0x80001000` with U = 6 refuses with `unsupported comparison sampler fields`. - `0x080011d2` (Z = 7) compiles. - A V-only border (`0x08001032`) refuses with word 3 `0xc0000000` (register reason) and on `gather4_c_lz`, which pins `u == 6 || v == 6`. - Wrap (`0x08001010`) and mirror (`0x08001011`) on U refuse. `ctest -R native_direct_container` passes. AI-assisted.
V-only CLAMP_BORDER reaches the REGISTER and gather refusals, word 3 bits
29:12 stay refused with a BORDER axis, CLAMP_Z = 7 compiles on a 2D view,
and wrap or mirror on U is refused.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot changed target branch from main to gh-pr/3526/base 2026-11-30 09:03:28 +00:00
github manually merged commit b06f0e0697 into gh-pr/3526/base 2026-11-30 09:03:29 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.