shader: lower image_sample_l and image_sample_b in gfx2hlsl (Part of #1723) #2045
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2045
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2045/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tedin7 on GitHub · 2026-11-24 23:37 UTC · original
tedin7:x2w-r21-sample-lb→main· +242 −5 · 3 files · 4 commits · closed without mergingPart of #1723
What this unblocks: startup pixel shaders that use biased sampling (
image_sample_b) now translate toSampleBiasinstead of stopping at "Unsupported".image_sample_lwas already lowered on main, so this change adds onlyimage_sample_b.Change
tools/startup/gfx2hlsl.py:image_sample_bshares theimage_sample_laddress handling. The bias is the last address register (after u, v and the slice or z). It becomesTexture.SampleBias(sampler, uv, bias).image_sample_lmessages are unchanged.tests/startup_image_sample_b_check.py, registered inCMakeLists.txtasstartup_image_sample_b: reuses the recordedimage_sample_lstages with only the MIMG opcode changed (0x24 to 0x25). It checks the bias register for 2D, NSA, 3D and 2D array, and the refusals.Verification
Run on the Linux worker (Python only, no GPU):
python3 -B tests/startup_image_sample_b_check.pyonorigin/main: fails (Unsupported: image_sample_b).startup_image_sample_b_check: ok.python3 -B tests/startup_image_sample_l_check.py: PASS.python3 -B tests/startup_image_sample_c_check.py,startup_image_sample_a16_check.py,startup_image_gather_lz_check.py,startup_sampler_heap_check.py: PASS.Not run: Win2025 GPU/D3D12 commands. The new test is Python only, and
tests/pixel_sample_lod_check.pyalready covers the bias on D3D12 for the other translator.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:37 UTC · original · edited 2026-11-24 23:42 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
f97aa96ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:42 UTC · original
For gfx1013
image_sample_b, the address layout is(bias, u, v[, z/slice]), not coordinates followed by bias; the existing lowering intools/pixel_aot.py:4507–4514also uses this order. The newplainfixture should therefore sample(v1, v2)with biasv0, but this shared extraction emits(v0, v1)with biasv2. Newly accepted shaders consequently sample the wrong coordinates and mip, including the NSA, 3D, and array forms. Extract the first component for'b'while retaining the last for'l', and correct the new test assertions that currently enforce the wrong order.Useful? React with 👍 / 👎.
@ -1894,2 +1906,4 @@self.image(ops, mods, 'l')def op_image_sample_b(self, ops, mods):self.image(ops, mods, 'b')@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:42 UTC · original
Adding
image_sample_bsupport changes a public translator capability, but this commit updates neitherREADME.mdnordocs/experiments.md, contrary to the rootAGENTS.mdrequirement. The startup experiment documentation does not record this new path's supported dimensions, straight-line pixel-stage restriction, reproduction command, or Python-only verification status. Update the relevant startup experiment section so contributors can discover and reproduce the capability without relying on the commit message.AGENTS.md reference: AGENTS.md:L211-L212
Useful? React with 👍 / 👎.
@denn0x on GitHub · 2026-11-25 00:26 UTC · original
The bias is read from the wrong address register.
{ offset } { bias } { z-compare } { derivative } { body }, with the bias "One Dword float". The coordinates are the body, so the bias is the FIRST address register. That differs fromimage_sample_l, where the level is the last one. (#2051 also cites LLVM 15'ssample_bintrinsic argument order to the same effect.)image_sample_b v[4:7], v[0:2], s[0:7], s[8:11] dmask:0xf dim:SQ_RSRC_IMG_2DbecomesSampleBias(smp, float2(v0, v1), v2). The correct lowering isSampleBias(smp, float2(v1, v2), v0).tests/startup_image_sample_b_check.pyasserts the last-register reading (bias_register(...) == ('v0', 'v1', None, 'v2')), so it passes on the wrong semantics.image_sample_lhere only if it adds something #2051 and main do not already cover.@tedin7 on GitHub · 2026-11-25 00:38 UTC · original
Fixed in 42becacd: image_sample_b now reads bias from the first address register per RDNA 2 ISA section 8.2.5, and the test was updated accordingly.
@tedin7 on GitHub · 2026-11-25 00:58 UTC · original
Fixed in fe23a5b3 (bias now read from the first address register; WARP draw test added in fff7d500, rebased on current main, push pending). Verified locally: tests/startup_image_sample_b_check.py and all startup_gfx2hlsl_*_check.py pass. AI-assisted; commands listed were executed locally.
@ -1894,2 +1906,4 @@self.image(ops, mods, 'l')def op_image_sample_b(self, ops, mods):self.image(ops, mods, 'b')@tedin7 on GitHub · 2026-11-25 00:58 UTC · original
Docs already cover this path in docs/experiments.md (startup section: image_sample_b, first-register bias, SampleBias lowering, 2D/single-channel/straight-line limits, refused forms). Nothing further needed in fff7d500. AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 07:28 UTC · original
Closing as superseded:
image_sample_bandimage_sample_lare already onmainvia #2051.@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:42 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
f97aa96eafℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Pull request closed