compute: lower the MIMG sample CL variants #3616

Open
github-bot wants to merge 6 commits from github-bot/gh-3614 into main AGit
Owner

@⁠lambirou on GitHub · 2026-11-30 14:27 UTC · original
lambirou:compute/sample-cl → main · +1391 −40 · 6 files · 6 commits · open

Stacked on #3606 (compute/gather4-variants): the slice extends the gather4 variant table and its coverage pin, so the diff includes that commit until #3606 lands. Rebase after it merges.

Part of the MIMG slice (P6). This adds the eight non-depth sample_cl forms: image_sample_cl, image_sample_cl_o, image_sample_b_cl, image_sample_b_cl_o, image_sample_c_cl, image_sample_c_cl_o, image_sample_c_b_cl and image_sample_c_b_cl_o. The cl suffix applies the LOD clamp (the same minimum-LOD interpretation as the pixel _cl path), o adds the texel offset, b the bias and c/c_b the depth comparison with its reference.

Refusals: dynamic coordinates, offsets, biases, references or clamps; out-of-range bias/clamp/reference values; the DMASK one-hot/full rules; a missing or moving sampler; and the descriptor guards of the neighbouring sample forms. The depth _d_cl/_cd_cl/_g16 families and the BVH forms stay out of this slice.

Tests

  • compute_store_aot_gfx1013_sample_cl_warp and _hardware pass: 16 cases and 4 mutants, 0 mismatch on WARP and the AMD Radeon RX 9060 XT (driver 32.0.32029.2010).
  • compute_store_aot_gfx1013_gather4_l and _variants still pass on both adapters; pixel_aot_sample_clamp 4/4; form_coverage_check.py and docs_links_check.py pass.
  • The record contains exactly the eight names; expected delta: +8 forms on gfx1013 and +8 on gfx1030. On top of #3606's expected 1,632/1,586 the pair reaches 1,640/1,594.

Limits

The desktop model loads the selected texel at an explicit mip; it does not prove the console's native derived LOD. The _CL meaning remains the minimum-LOD interpretation (LLVM/Mesa) rather than the ISA table's upper bound. No llvm-mc round-trip or console measurement was run.

AI-assisted.

**@⁠lambirou** on GitHub · 2026-11-30 14:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3614) `lambirou:compute/sample-cl` → `main` · +1391 −40 · 6 files · 6 commits · open **Stacked on #3606** (`compute/gather4-variants`): the slice extends the gather4 variant table and its coverage pin, so the diff includes that commit until #3606 lands. Rebase after it merges. Part of the MIMG slice (P6). This adds the eight non-depth `sample_cl` forms: `image_sample_cl`, `image_sample_cl_o`, `image_sample_b_cl`, `image_sample_b_cl_o`, `image_sample_c_cl`, `image_sample_c_cl_o`, `image_sample_c_b_cl` and `image_sample_c_b_cl_o`. The `cl` suffix applies the LOD clamp (the same minimum-LOD interpretation as the pixel `_cl` path), `o` adds the texel offset, `b` the bias and `c`/`c_b` the depth comparison with its reference. Refusals: dynamic coordinates, offsets, biases, references or clamps; out-of-range bias/clamp/reference values; the DMASK one-hot/full rules; a missing or moving sampler; and the descriptor guards of the neighbouring sample forms. The depth `_d_cl`/`_cd_cl`/`_g16` families and the BVH forms stay out of this slice. ## Tests - `compute_store_aot_gfx1013_sample_cl_warp` and `_hardware` pass: 16 cases and 4 mutants, 0 mismatch on WARP and the AMD Radeon RX 9060 XT (driver 32.0.32029.2010). - `compute_store_aot_gfx1013_gather4_l` and `_variants` still pass on both adapters; `pixel_aot_sample_clamp` 4/4; `form_coverage_check.py` and `docs_links_check.py` pass. - The record contains exactly the eight names; expected delta: **+8 forms on gfx1013 and +8 on gfx1030**. On top of #3606's expected 1,632/1,586 the pair reaches **1,640/1,594**. ## Limits The desktop model loads the selected texel at an explicit mip; it does not prove the console's native derived LOD. The `_CL` meaning remains the minimum-LOD interpretation (LLVM/Mesa) rather than the ISA table's upper bound. No `llvm-mc` round-trip or console measurement was run. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 14:32:02 +00:00
github-bot force-pushed github-bot/gh-3614 from 71d4146d5d to ac19d70d24 2026-11-30 14:37:53 +00:00 Compare
Author
Owner

@⁠lambirou on GitHub · 2026-12-01 03:11 UTC · original · reviewed

Reviewed ac19d70d against #3606 (46d53f76), focusing on the sample-CL delta; not built or run.

Verdict: changes requested. The _cl model applies the bias before the clamp as lod = max(bias, clamp), but the compute path has zero derivatives. With zero derivatives the implicit LOD is log2(0) = -inf; a finite bias leaves it at -inf, the sampler's MIN_LOD (0) clamps it to 0, and only the _cl minimum can raise it. A bias must not raise the selected mip.

  • MUST tools/compute_store_aot.py, sample-CL branch (lod = max(bias if bias is not None else 0.0, clamp)): use the clamped implicit LOD instead, e.g. max(clamp, 0.0) when a clamp is present and 0.0 otherwise. The current rows b_cl_lod1 (bias 1, clamp 0), b_cl_bias_rounds (1.5, 0) and b_cl_bias_above_clamp (2, 1) expect mips 1, 2 and 2; under the corrected rule they read 0, 0 and 1. The comparison rows c_b_cl_less, c_b_cl_equal and c_b_cl_o_lod1 have the same problem. Update sample_cl_level, sample_cl_case and the expected words.
  • SHOULD The fixture's sample_cl_level repeats the translator's formula, so the draw cannot catch this error. After the fix, use an independent expected mip for at least the bias-above-clamp row (desktop sampler or hand-computed).
  • SHOULD The comparison reference check in the sample-CL branch accepts any is_word(reference) and validates the [0, 1] range only when the value is a literal int. The docs claim a reference in [0, 1]; either refuse a non-literal reference or emit the same range check.
  • Note: the same max(bias, clamp) expression is inherited in the gather4 variant branch from #3606 and is already covered by the review there. Fixing #3606 will also update this stacked diff.

Checked, no finding: operand order (offset, bias, reference, U, V, clamp), the one-hot DMASK and red-channel comparison rules, the descriptor/sampler validation, and the _o edge clamp. The stack order remains #3606 → this PR → #3619.

**@⁠lambirou** on GitHub · 2026-12-01 03:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3614#pullrequestreview-6124501786) · **reviewed** Reviewed `ac19d70d` against #3606 (`46d53f76`), focusing on the sample-CL delta; not built or run. **Verdict: changes requested.** The `_cl` model applies the bias before the clamp as `lod = max(bias, clamp)`, but the compute path has zero derivatives. With zero derivatives the implicit LOD is `log2(0) = -inf`; a finite bias leaves it at `-inf`, the sampler's MIN_LOD (0) clamps it to 0, and only the `_cl` minimum can raise it. A bias must not raise the selected mip. - **MUST** `tools/compute_store_aot.py`, sample-CL branch (`lod = max(bias if bias is not None else 0.0, clamp)`): use the clamped implicit LOD instead, e.g. `max(clamp, 0.0)` when a clamp is present and `0.0` otherwise. The current rows `b_cl_lod1` (bias 1, clamp 0), `b_cl_bias_rounds` (1.5, 0) and `b_cl_bias_above_clamp` (2, 1) expect mips 1, 2 and 2; under the corrected rule they read 0, 0 and 1. The comparison rows `c_b_cl_less`, `c_b_cl_equal` and `c_b_cl_o_lod1` have the same problem. Update `sample_cl_level`, `sample_cl_case` and the expected words. - **SHOULD** The fixture's `sample_cl_level` repeats the translator's formula, so the draw cannot catch this error. After the fix, use an independent expected mip for at least the bias-above-clamp row (desktop sampler or hand-computed). - **SHOULD** The comparison reference check in the sample-CL branch accepts any `is_word(reference)` and validates the `[0, 1]` range only when the value is a literal `int`. The docs claim a reference in `[0, 1]`; either refuse a non-literal reference or emit the same range check. - Note: the same `max(bias, clamp)` expression is inherited in the gather4 variant branch from #3606 and is already covered by the review there. Fixing #3606 will also update this stacked diff. Checked, no finding: operand order (offset, bias, reference, U, V, clamp), the one-hot DMASK and red-channel comparison rules, the descriptor/sampler validation, and the `_o` edge clamp. The stack order remains #3606 → this PR → #3619.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 06:53 UTC · original

The #3606 stack now has a reproduced offset/clamp edge failure in its inherited gather4 helpers. The review on #3606 has the synthetic cases and exact WARP/RTX readbacks. Please carry that fix into the base first, then rebase #3616 and #3619 and rerun their sample tests alongside the gather4 edge cases.

**@⁠R0Y00** on GitHub · 2026-12-03 06:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3614#issuecomment-7370345799) The #3606 stack now has a reproduced offset/clamp edge failure in its inherited gather4 helpers. The [review on #3606](https://git.gtahub.st/github/R0Y00--Xbox2Windows/pulls/3606) has the synthetic cases and exact WARP/RTX readbacks. Please carry that fix into the base first, then rebase #3616 and #3619 and rerun their sample tests alongside the gather4 edge cases.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 11:41 UTC · original

At cbc9fb4a the offset correction matches #3606 and both draw-mimg-gather4 and draw-mimg-sample-cl passed on WARP and RTX 4060 Laptop, including their mutation controls, with the D3D12 debug layer enabled. The branch still carries the #3606 bias forms and remains stacked behind its open bias/zero-derivative review. Once the base lands, please make the PR diff show just the sample CL behavior and rerun checks.

**@⁠R0Y00** on GitHub · 2026-12-03 11:41 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3614#issuecomment-7377059756) At cbc9fb4a the offset correction matches #3606 and both draw-mimg-gather4 and draw-mimg-sample-cl passed on WARP and RTX 4060 Laptop, including their mutation controls, with the D3D12 debug layer enabled. The branch still carries the #3606 bias forms and remains stacked behind its open bias/zero-derivative review. Once the base lands, please make the PR diff show just the sample CL behavior and rerun checks.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3616/head:github-bot/gh-3614'
git switch 'github-bot/gh-3614'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3614'
git switch 'github-bot/gh-3614'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3614'
git switch 'github-bot/gh-3614'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3614'
git switch 'main'
git merge --squash 'github-bot/gh-3614'
git switch 'main'
git merge --ff-only 'github-bot/gh-3614'
git switch 'main'
git merge 'github-bot/gh-3614'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.