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

Merged
JB2WIN merged 2 commits from upstream-pr/3526 into main 2026-11-30 08:59:30 +00:00
JB2WIN commented 2026-11-29 22:56:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T22:56:02Z.


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 #3224, #3023. Follows #3524. On my local #3023 prototype route, 299 compute requests use a comparison sampler with CLAMP_BORDER on U and V and, with #3524, 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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5556047935 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3526). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-29T22:56:02Z. --- ## 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 #3224, #3023. Follows #3524. On my local #3023 prototype route, 299 compute requests use a comparison sampler with CLAMP_BORDER on U and V and, with #3524, 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)
Leyukaka commented 2026-11-29 23:09:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T23:09:25Z.

Review: COMMENTED


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.

  • #3517 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.
  • #3517 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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6105290444 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3526#pullrequestreview-6105290444). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T23:09:25Z. **Review:** COMMENTED --- 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. - #3517 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. - #3517 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.
JB2WIN commented 2026-11-29 23:20:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T23:20:38Z.


@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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7264387832 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3526#issuecomment-7264387832). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-29T23:20:38Z. --- @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.
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!3526
No description provided.