startup: lower image_sample_b in gfx2hlsl #2044

Merged
JB2WIN merged 3 commits from upstream-pr/2051 into main 2026-11-25 07:03:30 +00:00
JB2WIN commented 2026-11-24 23:39:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-24T23:39:17Z.


Refs #1996 (item D)

Change

tools/startup/gfx2hlsl.py now lowers image_sample_b in the pixel stage as SampleBias.

  • Address layout: the AMD RDNA 2 ISA (30 November 2020, section 8.2.4, table 43) defines _B as "LOD BIAS … Add this BIAS to the LOD computed". Section 8.2.5 orders the address {offset} {bias} {z-compare} {derivative} {body}, with the bias as one float dword. So the bias is the first address VGPR, before the coordinates. LLVM 15 agrees: IntrinsicsAMDGPU.td AMDGPUSample_b has a bias extra argument, and MIMGInstructions.td has IMAGE_SAMPLE_B with opcode 0x25.

  • Forms: the same dimensions as the existing image_sample_l path (2D, 2D-array, 3D), including the NSA spelling. 1D, cube and MSAA stay refused.

  • Refused:

    • image_sample_b_cl, image_sample_c_b*, _b_o and image_gather4_b;
    • non-pixel stages, which have no implicit LOD;
    • a changed exec, or code after a branch, where the neighbouring path would fall back to level 0 and lose the bias;
    • unorm, r128, tfe, lwe, a16, d16, an empty dmask and reserved bits;
    • a constant sampler with its own LOD-bias fields (word 2, bits 19:0) set, because the static sampler does not carry them.

    glc/slc/dlc are accepted, as for image_sample_l.

Test

New check tests/startup_image_sample_b_check.py, registered as startup_image_sample_b_controls, _warp and _hardware. It also has an LLVM 15 binary mode (30 fixture words) and is listed in the pure-Python job and AGENTS.md. Short notes are added to docs/experiments.md and docs/startup-runtime.md.

  • Draw: reuses the existing 4×4, 2-slice, 3-mip 2D-array texture and the existing renderer option; no C++ changes. Constant coordinates have no derivatives and would hide the bias. The draw therefore replaces only the u initialiser of the translated HLSL with a screen-dependent value, giving an implicit LOD of 1, and leaves the SampleBias call untouched. The check and the docs say so.
  • Result: bias -1, 0 and +1 read mips 0, 1 and 2 with both DXC and FXC.
  • Negative controls: plain image_sample reads mip 1 in every case, so the expectations for bias -1 and +1 fail. Replacing the bias with 0, negating it, swapping it with u, or calling Sample instead each read a different cell.
  • Mutations: in gfx2hlsl.py, ignoring the bias and swapping it with the first coordinate both make the controls fail. Against main's gfx2hlsl.py the check fails with Unsupported: image_sample_b.

On commit 79a74816 (rebased on 06cdc47d), with an NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), WARP 10.0.26100.9818 and Windows 11 build 26200:

ctest --preset dev --no-tests=error -R '^startup_(image_|gfx2hlsl)'   # 63/63 passed, including startup_image_sample_b_{controls,warp,hardware}

Not covered: heap samplers' own LOD bias and LOD limits (accepted, as for image_sample), bias values outside -16..15.99, fractional bias with a linear mip filter, and a plain-2D or 3D draw (the renderer only has mips for the 2D-array texture; those forms are checked at the text level).

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593661863 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-24T23:39:17Z. --- Refs #1996 (item D) ## Change `tools/startup/gfx2hlsl.py` now lowers `image_sample_b` in the pixel stage as `SampleBias`. - **Address layout:** the AMD RDNA 2 ISA (30 November 2020, section 8.2.4, table 43) defines `_B` as "LOD BIAS … Add this BIAS to the LOD computed". Section 8.2.5 orders the address `{offset} {bias} {z-compare} {derivative} {body}`, with the bias as one float dword. So the bias is the first address VGPR, before the coordinates. LLVM 15 agrees: `IntrinsicsAMDGPU.td` `AMDGPUSample_b` has a `bias` extra argument, and `MIMGInstructions.td` has `IMAGE_SAMPLE_B` with opcode 0x25. - **Forms:** the same dimensions as the existing `image_sample_l` path (2D, 2D-array, 3D), including the NSA spelling. 1D, cube and MSAA stay refused. - **Refused:** - `image_sample_b_cl`, `image_sample_c_b*`, `_b_o` and `image_gather4_b`; - non-pixel stages, which have no implicit LOD; - a changed `exec`, or code after a branch, where the neighbouring path would fall back to level 0 and lose the bias; - `unorm`, `r128`, `tfe`, `lwe`, `a16`, `d16`, an empty `dmask` and reserved bits; - a constant sampler with its own LOD-bias fields (word 2, bits 19:0) set, because the static sampler does not carry them. `glc`/`slc`/`dlc` are accepted, as for `image_sample_l`. ## Test New check `tests/startup_image_sample_b_check.py`, registered as `startup_image_sample_b_controls`, `_warp` and `_hardware`. It also has an LLVM 15 `binary` mode (30 fixture words) and is listed in the pure-Python job and `AGENTS.md`. Short notes are added to `docs/experiments.md` and `docs/startup-runtime.md`. - **Draw:** reuses the existing 4×4, 2-slice, 3-mip 2D-array texture and the existing renderer option; no C++ changes. Constant coordinates have no derivatives and would hide the bias. The draw therefore replaces only the `u` initialiser of the translated HLSL with a screen-dependent value, giving an implicit LOD of 1, and leaves the `SampleBias` call untouched. The check and the docs say so. - **Result:** bias -1, 0 and +1 read mips 0, 1 and 2 with both DXC and FXC. - **Negative controls:** plain `image_sample` reads mip 1 in every case, so the expectations for bias -1 and +1 fail. Replacing the bias with 0, negating it, swapping it with `u`, or calling `Sample` instead each read a different cell. - **Mutations:** in `gfx2hlsl.py`, ignoring the bias and swapping it with the first coordinate both make the controls fail. Against `main`'s `gfx2hlsl.py` the check fails with `Unsupported: image_sample_b`. On commit `79a74816` (rebased on `06cdc47d`), with an NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), WARP 10.0.26100.9818 and Windows 11 build 26200: ```powershell ctest --preset dev --no-tests=error -R '^startup_(image_|gfx2hlsl)' # 63/63 passed, including startup_image_sample_b_{controls,warp,hardware} ``` Not covered: heap samplers' own LOD bias and LOD limits (accepted, as for `image_sample`), bias values outside -16..15.99, fractional bias with a linear mip filter, and a plain-2D or 3D draw (the renderer only has mips for the 2D-array texture; those forms are checked at the text level). AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
R0Y00 commented 2026-11-25 01:01:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T00:54:51Z.

Review: CHANGES_REQUESTED


The translated fixture passes on WARP and RTX 4060 Laptop with both FXC and DXC, including the unbiased controls. It sets guest MAX_LOD to 2 and uses a texture whose last mip is already 2, so it cannot detect dropped sampler limits. The translated sampler currently leaves MinLOD at zero and MaxLOD unbounded, and the heap path bypasses even the constant-bias check. Please preserve the relevant guest clamp/bias or refuse descriptors for which it cannot be proven irrelevant, including dynamic samplers in this slice. Use a texture with a visible next mip and a guest MAX_LOD below it as the discriminator.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049890234 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#pullrequestreview-6049890234). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T00:54:51Z. **Review:** CHANGES_REQUESTED --- The translated fixture passes on WARP and RTX 4060 Laptop with both FXC and DXC, including the unbiased controls. It sets guest MAX_LOD to 2 and uses a texture whose last mip is already 2, so it cannot detect dropped sampler limits. The translated sampler currently leaves MinLOD at zero and MaxLOD unbounded, and the heap path bypasses even the constant-bias check. Please preserve the relevant guest clamp/bias or refuse descriptors for which it cannot be proven irrelevant, including dynamic samplers in this slice. Use a texture with a visible next mip and a guest MAX_LOD below it as the discriminator.
ChazY11 commented 2026-11-25 01:01:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:52:35Z.


Ran it, broke it five ways — all caught, including each clause of the three-part guard

out/pe-env/Scripts/python.exe -B tests/startup_image_sample_b_check.py
refused: b_cl, c_b, offset, gather4_b, cube, MSAA, 1D, a16, d16, tfe, lwe, unorm, r128, dmask 0, reserved bits, sampler LOD bias
glc, slc, dlc and a partial dmask are accepted
draw model: 6 distinct (mip, slice) cells      exit 0
mutation result
the bias is taken from the end of the address (cs[-1], the _L convention) caught
the pixel-stage clause of the guard is dropped caught
the no-branches clause is dropped caught
the entry-mask (exec_known) clause is dropped caught
the _L and _B address splits are swapped caught

The part I would defend hardest, and it is covered

sample_b needs the coordinate derivatives, which only exist in a pixel stage that still runs under its entry mask with no control flow:

if self.kind != 'ps' or not self.exec_known or len(self.blocks) > 0:
    raise Unsupported('image_sample_b needs implicit derivatives: pixel stage, entry mask, no branches')

Three separate reasons, and each one is independently mutation-caught. That matters more than usual here, because the fallback the code
deliberately refuses is worse than a refusal: lowering a biased sample to SampleLevel(…, 0) would return a valid-looking colour at the wrong mip,
and no downstream check would see it as anything but pixels.

The address layout is the other half — { offset } { bias } { z-compare } { derivative } { body } puts the bias before the coordinates, opposite to
_L's trailing LOD — and taking it from the wrong end is mutation one.

What the fixture pins beyond the lowering

The refusal list is long and specific (b_cl, c_b, offset, gather4_b, cube, MSAA, 1D, a16, d16, tfe, lwe, unorm, r128, dmask 0, reserved bits,
sampler LOD bias), which is the right shape for this translator: each of those would change how many dwords the address block consumes or how the
result is filtered, and silently reading the wrong dword is indistinguishable from a working shader until the image looks wrong.

draw model: 6 distinct (mip, slice) cells is the line I trust most in that output — it means the check does not stop at the emitted text but
propagates into what cell each thread samples.

One thing worth stating in the description

The PR says the bias is "the first address VGPR, before the coordinates" and cites section 8.2.5. That is the whole risk of this patch in one
sentence, and it is currently only in a source comment. If a reviewer has the PDF, quoting the ordering table in the description would let the next
contributor check image_sample_b_cl and the other combinations without re-deriving it.

What I did not check

No shader compiled or run: SampleBias semantics (bias added to the derivative-derived LOD, clamped by the sampler's min/max) are asserted by the
draw model, not by me. And the "static sampler carries neither the descriptor's LOD bias nor…" reasoning is about the stand-in's model, which I read
but cannot measure without a build.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147892348 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#issuecomment-7147892348). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T23:52:35Z. --- ## Ran it, broke it five ways — all caught, including each clause of the three-part guard ```powershell out/pe-env/Scripts/python.exe -B tests/startup_image_sample_b_check.py refused: b_cl, c_b, offset, gather4_b, cube, MSAA, 1D, a16, d16, tfe, lwe, unorm, r128, dmask 0, reserved bits, sampler LOD bias glc, slc, dlc and a partial dmask are accepted draw model: 6 distinct (mip, slice) cells exit 0 ``` | mutation | result | |---|---| | the bias is taken from the end of the address (`cs[-1]`, the `_L` convention) | **caught** | | the pixel-stage clause of the guard is dropped | **caught** | | the no-branches clause is dropped | **caught** | | the entry-mask (`exec_known`) clause is dropped | **caught** | | the `_L` and `_B` address splits are swapped | **caught** | ## The part I would defend hardest, and it is covered `sample_b` needs the coordinate **derivatives**, which only exist in a pixel stage that still runs under its entry mask with no control flow: ```python if self.kind != 'ps' or not self.exec_known or len(self.blocks) > 0: raise Unsupported('image_sample_b needs implicit derivatives: pixel stage, entry mask, no branches') ``` Three separate reasons, and each one is independently mutation-caught. That matters more than usual here, because the fallback the code deliberately refuses is *worse than a refusal*: lowering a biased sample to `SampleLevel(…, 0)` would return a valid-looking colour at the wrong mip, and no downstream check would see it as anything but pixels. The address layout is the other half — `{ offset } { bias } { z-compare } { derivative } { body }` puts the bias **before** the coordinates, opposite to `_L`'s trailing LOD — and taking it from the wrong end is mutation one. ## What the fixture pins beyond the lowering The refusal list is long and specific (`b_cl`, `c_b`, offset, gather4_b, cube, MSAA, 1D, a16, d16, tfe, lwe, unorm, r128, dmask 0, reserved bits, sampler LOD bias), which is the right shape for this translator: each of those would change how many dwords the address block consumes or how the result is filtered, and silently reading the wrong dword is indistinguishable from a working shader until the image looks wrong. `draw model: 6 distinct (mip, slice) cells` is the line I trust most in that output — it means the check does not stop at the emitted text but propagates into what cell each thread samples. ## One thing worth stating in the description The PR says the bias is "the first address VGPR, before the coordinates" and cites section 8.2.5. That is the whole risk of this patch in one sentence, and it is currently only in a source comment. If a reviewer has the PDF, quoting the ordering table in the description would let the next contributor check `image_sample_b_cl` and the other combinations without re-deriving it. ## What I did not check No shader compiled or run: `SampleBias` semantics (bias added to the derivative-derived LOD, clamped by the sampler's min/max) are asserted by the draw model, not by me. And the "static sampler carries neither the descriptor's LOD bias nor…" reasoning is about the stand-in's model, which I read but cannot measure without a build. ## Notes - AI-assisted review.
denn0x commented 2026-11-25 01:02:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T00:26:42Z.


I checked the operand order against the RDNA 2 ISA address order (section 8.2.5, bias before the body). The bias is the first address register in every form: plain, NSA, array, 3D.

Run on the head (79a74816), pure Python:

  • python -B tests/startup_image_sample_b_check.py: all controls print, including the refusals of _b_cl, _c_b, offsets, cube, MSAA, 1D, a16, d16, tfe, lwe, unorm, r128, an empty dmask, reserved bits and a sampler with an LOD bias.
  • Still passing: startup_image_sample_l_check.py, startup_image_3d_check.py and startup_translator_check.py.
  • I did not run the draw mode.

A second, independent lowering (not public) agrees on the operand order and on refusing a16. One difference: it does not refuse a constant sampler whose word 2 carries an LOD bias, and yours does. I think yours is right.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7148516502 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#issuecomment-7148516502). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T00:26:42Z. --- I checked the operand order against the RDNA 2 ISA address order (section 8.2.5, bias before the body). The bias is the first address register in every form: plain, NSA, array, 3D. Run on the head (79a74816), pure Python: - `python -B tests/startup_image_sample_b_check.py`: all controls print, including the refusals of `_b_cl`, `_c_b`, offsets, cube, MSAA, 1D, a16, d16, tfe, lwe, unorm, r128, an empty dmask, reserved bits and a sampler with an LOD bias. - Still passing: `startup_image_sample_l_check.py`, `startup_image_3d_check.py` and `startup_translator_check.py`. - I did not run the draw mode. A second, independent lowering (not public) agrees on the operand order and on refusing a16. One difference: it does not refuse a constant sampler whose word 2 carries an LOD bias, and yours does. I think yours is right.
tedin7 commented 2026-11-25 02:01:32 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head 79a74816aea1d5a9693eb07531c6846739445e72 (comment only, no approval).

Summary: The image_sample_b lowering to SampleBias is correct. The bias is the first address dword, which matches the RDNA 2 ISA address order. The refusal list is conservative and the guards look right. No P1 or P2 findings.

State

  • Title is neutral and the PR is clean-room. It is MERGEABLE.
  • CI: Linux checks, gfx1013 fixtures and Windows build/test pass. The O2 job and the chart job are skipped.

Commands run locally in a worktree of this head

  • git diff --stat origin/main...HEAD: 7 files, +579/-8.
  • python3 tests/startup_image_sample_b_check.py: ended with Self-test passed. It covers the address layouts (plain, NSA, array, NSA array, 3D), the no-bias Sample case, the refusals (b_cl, c_b, offset, gather4_b, cube, MSAA, 1D, a16, d16, tfe, lwe, unorm, r128, dmask 0, reserved bits, sampler LOD bias) and the accepted glc/slc/dlc/partial dmask.
  • python3 tests/docs_links_check.py: 391 links OK, self-test passed.
  • python3 tests/bidi_controls_check.py: 1404 files, no bidi controls.
  • git diff --check origin/main...HEAD: clean.

Mutations (both reverted with git checkout -- .)

  1. In tools/startup/gfx2hlsl.py, I changed bias, cs = cs[0], cs[1:] to cs[-1], cs[:-1]. The check failed with an AssertionError on the array case, so the mutation is killed.
  2. I replaced the pixel/entry-mask/no-branch guard with if False:. The check failed, though by a crash (AttributeError: 'Stage' object has no attribute 'pipe') rather than a clean assertion. It is still killed.

Nits (not blocking)

  • gfx2hlsl.py (sampler LOD-bias refusal): words is None for a heap sampler, so the words[2] & 0xfffff check is skipped. That looks intended, since a heap sampler carries its own state. One test line pinning "heap sampler with bias is accepted (or refused)" would document the choice.
  • The guard len(self.blocks) > 0 refuses all bias samples after any branch. It is conservative and correct. It may cost coverage on real shaders later, so a follow-up note in the docs would help.
  • Mutation 2 is killed by a crash, not by an assertion. A direct test that expects Unsupported for a non-pixel stage would give a clearer failure message.

I did not run a Win2025 WARP job. The CI Windows build/test passed, and the PR's own _warp and _hardware registrations cover that path. The Windows readback result should be confirmed from the author's Verification block before Ready.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050452671 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#pullrequestreview-6050452671). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:55:47Z. **Review:** COMMENTED --- Review of head `79a74816aea1d5a9693eb07531c6846739445e72` (comment only, no approval). **Summary:** The `image_sample_b` lowering to `SampleBias` is correct. The bias is the first address dword, which matches the RDNA 2 ISA address order. The refusal list is conservative and the guards look right. No P1 or P2 findings. **State** - Title is neutral and the PR is clean-room. It is MERGEABLE. - CI: Linux checks, gfx1013 fixtures and Windows build/test pass. The O2 job and the chart job are skipped. **Commands run locally in a worktree of this head** - `git diff --stat origin/main...HEAD`: 7 files, +579/-8. - `python3 tests/startup_image_sample_b_check.py`: ended with `Self-test passed.` It covers the address layouts (plain, NSA, array, NSA array, 3D), the no-bias Sample case, the refusals (b_cl, c_b, offset, gather4_b, cube, MSAA, 1D, a16, d16, tfe, lwe, unorm, r128, dmask 0, reserved bits, sampler LOD bias) and the accepted glc/slc/dlc/partial dmask. - `python3 tests/docs_links_check.py`: 391 links OK, self-test passed. - `python3 tests/bidi_controls_check.py`: 1404 files, no bidi controls. - `git diff --check origin/main...HEAD`: clean. **Mutations (both reverted with `git checkout -- .`)** 1. In `tools/startup/gfx2hlsl.py`, I changed `bias, cs = cs[0], cs[1:]` to `cs[-1], cs[:-1]`. The check failed with an AssertionError on the array case, so the mutation is killed. 2. I replaced the pixel/entry-mask/no-branch guard with `if False:`. The check failed, though by a crash (`AttributeError: 'Stage' object has no attribute 'pipe'`) rather than a clean assertion. It is still killed. **Nits (not blocking)** - `gfx2hlsl.py` (sampler LOD-bias refusal): `words` is `None` for a heap sampler, so the `words[2] & 0xfffff` check is skipped. That looks intended, since a heap sampler carries its own state. One test line pinning "heap sampler with bias is accepted (or refused)" would document the choice. - The guard `len(self.blocks) > 0` refuses all bias samples after any branch. It is conservative and correct. It may cost coverage on real shaders later, so a follow-up note in the docs would help. - Mutation 2 is killed by a crash, not by an assertion. A direct test that expects `Unsupported` for a non-pixel stage would give a clearer failure message. I did not run a Win2025 WARP job. The CI Windows build/test passed, and the PR's own `_warp` and `_hardware` registrations cover that path. The Windows readback result should be confirmed from the author's Verification block before Ready. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 03:00:51 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head 3222f965ff6786215abc427d7cce08bbe9fb6c26 (comment only, no approval). This is a re-review: my earlier review covered 79a74816; the new commit 3222f965 adds the sampler LOD-limit handling.

Summary: The new smpl manifest line and the refusals in sample_b_sampler look correct. MIN_LOD (word 1 bits 11:0) and MAX_LOD (bits 23:12) are u4.8, so /256 is right. LOD_BIAS in word 2 bits 19:0 and MIP_FILTER in word 2 bits 27:26 match the gfx10 SQ_IMG_SAMP layout. Refusing a heap or register sampler, a nonzero descriptor bias, mip filter 0 and MIN_LOD above MAX_LOD is conservative and sound. smp and smpc lines are unchanged for every other sample form. No P1 or P2 findings in the code.

State

  • Mergeable. Title is neutral.
  • CI: Linux checks, gfx1013 fixtures and "Build and test on Windows" pass (this builds and runs startup_sampler_comparison and the WARP/hardware sample_b fixtures). The /O2 job and the chart job are skipped.
  • I did not run a separate Win2025 job: the Windows CI job already covers the C++ decode and the D3D12 fixtures at this head.

Commands run locally in a worktree of this head

  • git diff --stat origin/main...HEAD: 9 files, +788/-18.
  • python3 tests/startup_image_sample_b_check.py: "Self-test passed." (limits, refusals and the 6-cell draw model all listed).
  • python3 tests/docs_links_check.py: 18 files, 399 links, passed.
  • python3 tests/bidi_controls_check.py: 1445 files, no bidi controls.
  • git diff --check origin/main...HEAD: clean.
  • Mutation 1: mip-filter-0 refusal replaced by if False:. The check failed with "mip filter none was accepted". Restored.
  • Mutation 2: MIN_LOD > MAX_LOD refusal replaced by if False:. The check failed with "array min3 max2 was accepted". Restored.

Findings

  • P1: none.
  • P2: none.
  • Nit (repo rule): the trailers of the new commit(s) name an AI tool and model. The repo rule is no AI model names or codenames on GitHub. Please reword those commit messages before merge, or make sure the squash message drops those lines. Check with git log --format=%B origin/main..HEAD | grep -i ai-assisted.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050678563 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#pullrequestreview-6050678563). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:15:43Z. **Review:** COMMENTED --- Review of head `3222f965ff6786215abc427d7cce08bbe9fb6c26` (comment only, no approval). This is a re-review: my earlier review covered `79a74816`; the new commit `3222f965` adds the sampler LOD-limit handling. **Summary:** The new `smpl` manifest line and the refusals in `sample_b_sampler` look correct. MIN_LOD (word 1 bits 11:0) and MAX_LOD (bits 23:12) are u4.8, so `/256` is right. LOD_BIAS in word 2 bits 19:0 and MIP_FILTER in word 2 bits 27:26 match the gfx10 SQ_IMG_SAMP layout. Refusing a heap or register sampler, a nonzero descriptor bias, mip filter 0 and MIN_LOD above MAX_LOD is conservative and sound. `smp` and `smpc` lines are unchanged for every other sample form. No P1 or P2 findings in the code. **State** - Mergeable. Title is neutral. - CI: Linux checks, gfx1013 fixtures and "Build and test on Windows" pass (this builds and runs `startup_sampler_comparison` and the WARP/hardware sample_b fixtures). The /O2 job and the chart job are skipped. - I did not run a separate Win2025 job: the Windows CI job already covers the C++ decode and the D3D12 fixtures at this head. **Commands run locally in a worktree of this head** - `git diff --stat origin/main...HEAD`: 9 files, +788/-18. - `python3 tests/startup_image_sample_b_check.py`: "Self-test passed." (limits, refusals and the 6-cell draw model all listed). - `python3 tests/docs_links_check.py`: 18 files, 399 links, passed. - `python3 tests/bidi_controls_check.py`: 1445 files, no bidi controls. - `git diff --check origin/main...HEAD`: clean. - Mutation 1: mip-filter-0 refusal replaced by `if False:`. The check failed with "mip filter none was accepted". Restored. - Mutation 2: MIN_LOD > MAX_LOD refusal replaced by `if False:`. The check failed with "array min3 max2 was accepted". Restored. **Findings** - P1: none. - P2: none. - Nit (repo rule): the trailers of the new commit(s) name an AI tool and model. The repo rule is no AI model names or codenames on GitHub. Please reword those commit messages before merge, or make sure the squash message drops those lines. Check with `git log --format=%B origin/main..HEAD | grep -i ai-assisted`. AI-assisted; commands listed were executed locally.
JB2WIN commented 2026-11-25 03:01:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-25T02:10:08Z.


Pushed 3222f965 (rebased on current main) for the review:

  • MIN_LOD / MAX_LOD are carried over. image_sample_b now emits its constant sampler as a new manifest line smpl, and the runtime's decode_sampler sets MinLOD = MIN_LOD/256 and MaxLOD = MAX_LOD/256. Both fields are u4.8, per the RDNA 2 ISA section 8.2.7. The bit positions come from Mesa 24.0.0 src/amd/registers/gfx10-rsrc.json (MIN_LOD 0–11, MAX_LOD 12–23) and the encoding from si_state.c, which uses S_FIXED(x, 8). The smp/smpc lines of the other sample forms are unchanged.

  • Still refused: a guest LOD bias, because the ISA scales it by T#.perf_modulation and the desktop sampler has no matching field. Also a mip filter of 0 (mipmapping off), MIN_LOD > MAX_LOD, and every heap or register sampler for image_sample_b, including the default-sampler shortcut for a heap load with a register offset.

  • Discriminator on the existing 3-mip texture, drawn on WARP and hardware with DXC and FXC:

    Guest sampler Bias Must read Unclamped would read
    MAX_LOD 1 +1 mip 1 mip 2
    MAX_LOD 0 +1 mip 0 —
    MIN_LOD 2 -1 mip 2 mip 0
    MIN_LOD = MAX_LOD = 1 -1 mip 1 —

    Each case is also drawn through a plain smp line without the limits and must give the unclamped mip.

  • Mutations: both fail the tests. Dropping the MaxLOD assignment fails startup_sampler_comparison and startup_image_sample_b_warp. Accepting a heap sampler fails the controls.

  • Results: ctest --preset dev --no-tests=error -R '^startup_(image_|gfx2hlsl|sampler)' passed 82/82 before the rebase, and all pure checks pass after it.

image_sample, image_sample_l and image_sample_lz still drop MIN_LOD/MAX_LOD, and they accept heap samplers unchecked. I left them alone here and can take them as a follow-up.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7150397929 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#issuecomment-7150397929). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-25T02:10:08Z. --- Pushed `3222f965` (rebased on current `main`) for the review: - **MIN_LOD / MAX_LOD are carried over.** `image_sample_b` now emits its constant sampler as a new manifest line `smpl`, and the runtime's `decode_sampler` sets `MinLOD = MIN_LOD/256` and `MaxLOD = MAX_LOD/256`. Both fields are u4.8, per the RDNA 2 ISA section 8.2.7. The bit positions come from Mesa 24.0.0 `src/amd/registers/gfx10-rsrc.json` (MIN_LOD 0–11, MAX_LOD 12–23) and the encoding from `si_state.c`, which uses `S_FIXED(x, 8)`. The `smp`/`smpc` lines of the other sample forms are unchanged. - **Still refused:** a guest LOD bias, because the ISA scales it by `T#.perf_modulation` and the desktop sampler has no matching field. Also a mip filter of 0 (mipmapping off), `MIN_LOD > MAX_LOD`, and **every heap or register sampler for `image_sample_b`**, including the default-sampler shortcut for a heap load with a register offset. - **Discriminator** on the existing 3-mip texture, drawn on WARP and hardware with DXC and FXC: | Guest sampler | Bias | Must read | Unclamped would read | |---|---|---|---| | MAX_LOD 1 | +1 | mip 1 | mip 2 | | MAX_LOD 0 | +1 | mip 0 | — | | MIN_LOD 2 | -1 | mip 2 | mip 0 | | MIN_LOD = MAX_LOD = 1 | -1 | mip 1 | — | Each case is also drawn through a plain `smp` line without the limits and must give the unclamped mip. - **Mutations:** both fail the tests. Dropping the MaxLOD assignment fails `startup_sampler_comparison` and `startup_image_sample_b_warp`. Accepting a heap sampler fails the controls. - **Results:** `ctest --preset dev --no-tests=error -R '^startup_(image_|gfx2hlsl|sampler)'` passed 82/82 before the rebase, and all pure checks pass after it. `image_sample`, `image_sample_l` and `image_sample_lz` still drop MIN_LOD/MAX_LOD, and they accept heap samplers unchecked. I left them alone here and can take them as a follow-up. AI-assisted (Claude Code).
JB2WIN commented 2026-11-25 03:01:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-25T02:54:14Z.


@tedin7, thanks for the re-review. About the trailer nit: I can't find a rule against naming the AI tool or model in this repository. .github/PULL_REQUEST_TEMPLATE.md asks for AI assistance to be stated, and several merged commits on main carry the same Co-Authored-By line. If the rule lives elsewhere, please point me to it and I'll reword the commits.

On the Windows readback: startup_image_sample_b_{warp,hardware} passed locally on WARP 10.0.26100.9818 and on an RTX 3080 (32.0.16.2124), Windows 11 build 26200; see the verification above.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7151337602 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#issuecomment-7151337602). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-25T02:54:14Z. --- @tedin7, thanks for the re-review. About the trailer nit: I can't find a rule against naming the AI tool or model in this repository. `.github/PULL_REQUEST_TEMPLATE.md` asks for AI assistance to be stated, and several merged commits on `main` carry the same `Co-Authored-By` line. If the rule lives elsewhere, please point me to it and I'll reword the commits. On the Windows readback: `startup_image_sample_b_{warp,hardware}` passed locally on WARP 10.0.26100.9818 and on an RTX 3080 (32.0.16.2124), Windows 11 build 26200; see the verification above. AI-assisted.
thepatrickworld commented 2026-11-25 04:04:20 +00:00 (Migrated from github.com)

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


Hardware run, RX 9070 XT (driver 32.0.32029.2010), dxc ps_6_0 and fxc ps_5_1:

startup_image_2d_array z=1 color=(0.390625, 1, 0, 3)
fxc sample_b array 1, plain Sample: fails as expected

The biased sample lands on the mip the bias selects, and the plain-sample mutation still fails, so the readback really distinguishes the two.

Limits: AMD only, no NVIDIA here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7152382444 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#issuecomment-7152382444). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-25T03:56:32Z. --- Hardware run, RX 9070 XT (driver 32.0.32029.2010), dxc `ps_6_0` and fxc `ps_5_1`: ``` startup_image_2d_array z=1 color=(0.390625, 1, 0, 3) fxc sample_b array 1, plain Sample: fails as expected ``` The biased sample lands on the mip the bias selects, and the plain-sample mutation still fails, so the readback really distinguishes the two. Limits: AMD only, no NVIDIA here. _AI-assisted._
R0Y00 commented 2026-11-25 07:00:47 +00:00 (Migrated from github.com)

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

Review: APPROVED


The previous LOD finding is resolved. The updated branch carries the constant sampler limits and refuses dynamic samplers for this slice. On Windows Release I reran ten selected checks on the merge resolution. WARP and RTX 4060 Laptop both reproduced the dropped-limit controls in DXC and FXC with a visible mip above MAX_LOD. The A16 sampler and D16 image-load regressions also passed. The latest pushed commit still needs its applicable CI.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053158656 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#pullrequestreview-6053158656). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T06:58:38Z. **Review:** APPROVED --- The previous LOD finding is resolved. The updated branch carries the constant sampler limits and refuses dynamic samplers for this slice. On Windows Release I reran ten selected checks on the merge resolution. WARP and RTX 4060 Laptop both reproduced the dropped-limit controls in DXC and FXC with a visible mip above MAX_LOD. The A16 sampler and D16 image-load regressions also passed. The latest pushed commit still needs its applicable CI.
tedin7 commented 2026-11-25 07:00:47 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head 434aa2fee6adce4865e5d6804b996749367be0d6 (comment only, no approval). Re-review: my earlier review covered 3222f965. The new commit 434aa2fe is a merge of main that keeps the sampler-bias and image-load support.

Summary: The image_sample_b lowering is unchanged in substance since the last review. The smpl manifest line, the /256 decode of MIN_LOD and MAX_LOD, and the refusals in sample_b_sampler (heap, register sampler, nonzero LOD bias, mip filter 0, MIN_LOD above MAX_LOD) still read correctly after the merge. The bias dword is taken before the coordinates and SampleBias is only emitted in a pixel stage with a known entry mask and no branches (tools/startup/gfx2hlsl.py:1946-1970, :2021-2046, :2150-2175). No P1 or P2 findings in the code.

State

  • Mergeable, not Draft, title is neutral.
  • CI at this head: Linux Python checks pass. "Assemble and translate gfx1013 fixtures" and "Build and test on Windows" were still pending when I looked, so please wait for them to go green before merge. The /O2 job is skipped.
  • I did not run a separate Win2025 job: the Windows CI job builds and runs startup_sampler_comparison and the WARP/hardware sample_b fixtures at this head, and the merge did not touch the sample_b lowering.

Commands run locally in a worktree of this head

  • git diff --stat origin/main...HEAD: 9 files, +788/-18.
  • python3 tests/startup_image_sample_b_check.py: exit 0, last line "draw model: 6 distinct (mip, slice) cells".
  • python3 tests/docs_links_check.py: "Checked 18 Markdown files and 417 links."
  • python3 tests/bidi_controls_check.py: "Checked 1519 tracked source, script and build/CI files: no bidirectional controls."
  • git diff --check origin/main...HEAD: clean.
  • Mutation: the mip-filter-0 refusal replaced by if False:. The check failed with "AssertionError: mip filter none was accepted". Restored with git checkout -- ..

Findings

  • P1: none.
  • P2: none.
  • Nit (repo rule, still open): two commits on the branch still carry an AI tool and model in the trailers (git log --format=%B origin/main..HEAD | grep -i -E 'co-authored|ai-assisted' returns 4 lines). The repo rule is no AI model names or codenames on GitHub. Please reword those commit messages before merge, or make sure the squash message drops those lines.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053179899 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2051#pullrequestreview-6053179899). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T07:00:33Z. **Review:** COMMENTED --- Review of head `434aa2fee6adce4865e5d6804b996749367be0d6` (comment only, no approval). Re-review: my earlier review covered `3222f965`. The new commit `434aa2fe` is a merge of main that keeps the sampler-bias and image-load support. **Summary:** The `image_sample_b` lowering is unchanged in substance since the last review. The `smpl` manifest line, the `/256` decode of MIN_LOD and MAX_LOD, and the refusals in `sample_b_sampler` (heap, register sampler, nonzero LOD bias, mip filter 0, MIN_LOD above MAX_LOD) still read correctly after the merge. The bias dword is taken before the coordinates and `SampleBias` is only emitted in a pixel stage with a known entry mask and no branches (`tools/startup/gfx2hlsl.py:1946-1970`, `:2021-2046`, `:2150-2175`). No P1 or P2 findings in the code. **State** - Mergeable, not Draft, title is neutral. - CI at this head: Linux Python checks pass. "Assemble and translate gfx1013 fixtures" and "Build and test on Windows" were still pending when I looked, so please wait for them to go green before merge. The /O2 job is skipped. - I did not run a separate Win2025 job: the Windows CI job builds and runs `startup_sampler_comparison` and the WARP/hardware sample_b fixtures at this head, and the merge did not touch the sample_b lowering. **Commands run locally in a worktree of this head** - `git diff --stat origin/main...HEAD`: 9 files, +788/-18. - `python3 tests/startup_image_sample_b_check.py`: exit 0, last line "draw model: 6 distinct (mip, slice) cells". - `python3 tests/docs_links_check.py`: "Checked 18 Markdown files and 417 links." - `python3 tests/bidi_controls_check.py`: "Checked 1519 tracked source, script and build/CI files: no bidirectional controls." - `git diff --check origin/main...HEAD`: clean. - Mutation: the mip-filter-0 refusal replaced by `if False:`. The check failed with "AssertionError: mip filter none was accepted". Restored with `git checkout -- .`. **Findings** - P1: none. - P2: none. - Nit (repo rule, still open): two commits on the branch still carry an AI tool and model in the trailers (`git log --format=%B origin/main..HEAD | grep -i -E 'co-authored|ai-assisted'` returns 4 lines). The repo rule is no AI model names or codenames on GitHub. Please reword those commit messages before merge, or make sure the squash message drops those lines. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 08:04:42 +00:00
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!2044
No description provided.