shader: lower image_sample_d and document image_sample_c_d refusal in gfx2hlsl (Part of #1723) #2075
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2082"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:04:09Z.
Part of #1723
What this unblocks: gradient texture samples (
image_sample_d) in startup shaders now lower to HLSLSampleGradinstead of stopping translation.Lowering (
tools/startup/gfx2hlsl.py):image_sample_dtakes ddx, then ddy (one register per axis each), then the coordinates: 2D = 6 registers, 2D array = 7 (slice last), 3D = 9 (a contiguous volume range is padded to 16 and trimmed to 9).Texture.SampleGrad(sampler, uv, ddx, ddy).dim,dmask,glc,slc,dlc(for exampletfe,a16, offsets).image_sample_c_dis refused by name: it needsSampleCmpGrad, which is shader model 6.8 (same reason asimage_sample_c_l).Test:
tests/startup_image_sample_d_check.py, registered asstartup_image_sample_dinCMakeLists.txt. Fixture words come from llvm-mc and are re-checked bybinary <llvm-mc>.Verification:
python3 -B tests/startup_image_sample_d_check.pypasses.python3 -B tests/startup_image_sample_d_check.py binary /usr/bin/llvm-mc-19passes (fixture words match).startup_image_sample_l_check.pyandstartup_image_gather_lz_check.pystill pass.origin/main(noimage_sample_dlowering).ctest -R startup_image_sample_dstill need to be run.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:11:53Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
23dc24916eℹ️ 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".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:04:20Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
23dc249ℹ️ 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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:11:54Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1416Adding
image_sample_dsupport changes the startup translator's public capabilities, but neither the README nordocs/experiments.mdis updated. The capability-documentation requirement inAGENTS.mdcalls for an update when this happens. Document the supported dimensions, refused forms and exact reproduction commands, distinguishing the verified Python translation checks from unverified D3D12 readback, so contributors can discover and reproduce the new capability without relying on the commit message or test source.AGENTS.md reference: AGENTS.md:L211-L212
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:11:54Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1321For a mipmapped SRV with a guest sampler capped to
MAX_LOD = 0, this newly accepted path can silently sample a higher mip. The startup binding'sdecode_sampler()insrc/startup_stubs/translated_sampler_bindings.h:30-45ignores sampler word 1 and unconditionally sets desktopMaxLODtoD3D12_FLOAT32_MAX, while this lowering passes the gradients directly toSampleGradwithout compensating for that cap. For example, sampler words(0, 0, 0x04000000, 0)are accepted even though gradients selecting mip 2 must still return mip 0. Preserve the guest LOD cap in the desktop sampler or refuse unsupported capped samplers before accepting this instruction.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:47Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:49Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:47Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1416Documented in README.md and docs/experiments.md (new section: supported dims, refused forms, repro commands, translation-check vs unverified D3D12 readback). Fixed in f889ef76 (branch rb2082, pending push).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:48Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1321gfx2hlsl now refuses image_sample_d unless the sampler is constant with MAX_LOD 0xfff (uncapped); a capped sampler such as words (0,0,0x04000000,0) is refused, with a test. Fixed in f889ef76 (branch rb2082, pending push).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:01:59Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:02:03Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:01:59Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1416Re-checked on current head
e0cf1d3a:image_sample_dis documented in docs/experiments.md, and the guest MAX_LOD cap is honored with a test (e0cf1d3a). Resolving. AI-assisted; commands listed were executed locally.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:02:02Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1321Re-checked on current head
e0cf1d3a:image_sample_dis documented in docs/experiments.md, and the guest MAX_LOD cap is honored with a test (e0cf1d3a). Resolving. AI-assisted; commands listed were executed locally.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:52:15Z.
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is.
We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here.
AI-assisted; commands listed were executed locally.