startup: carry the constant sampler LOD range for image_sample, _l and _lz #2257
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2265"
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 JB2WIN on 2026-11-25T08:51:40Z.
Refs #2177
Change
This is the constant-sampler slice agreed in #2177.
image_sample,image_sample_landimage_sample_lznow emit a constant sampler as ansmplline, the same manifest path #2051 added forimage_sample_b, so the runtime setsMinLOD = MIN_LOD/256andMaxLOD = MAX_LOD/256. A shared helper intools/startup/gfx2hlsl.pyapplies #2051's validation to all four forms.New refusals for the three forms. Each is a behaviour change, since these samplers used to translate without limits:
MIN_LOD > MAX_LOD.A constant sampler with
MAX_LOD≠ 0 now clamps the level, where it used to be unbounded.What stays as before:
image_sample_b, where the bias matters. For the other three forms such a sampler stays ansmpline. Refusing it there would drop every pipeline with an all-zero inline sampler, and seven existing checks build exactly that. Your note named only the bias and malformed ranges. If you want it refused there too, the switch ismip_filter_none_okinStage.lod_sampler_words, and those fixtures would need updating.translate_toandtranslate_computeprint one line per module saying their LOD fields are not validated (#2221), and the docs describe the gap. A sampler that is neither heap nor constant stays refused.image_sample_ckeeps its MAX_LOD rule.Test
New check
tests/startup_image_sample_lod_check.py, registered asstartup_image_sample_lod_controls,_warpand_hardware. It also has an LLVM 15.0.7binarymode, and is listed in the pure-Python job and inAGENTS.md. Each form is drawn on its own:smplreadssmpcontrol reads_limage_sample_lzimage_sample, LOD 1 comes from replacing only theuinitialiser of the translated HLSL, as in #2051. TheSamplecall is untouched.image_sample_b's three discriminators stay green.startup_image_sample_b_check.pyused to assert that a plainimage_samplehas nosmplline. That is now intended, so it asserts instead that the same words give the samesmplline.smplfor_l,image_sampleor_lzfails the controls; each was tried separately.startup_sampler_comparison,startup_image_sample_b_warpandstartup_image_sample_lod_{warp,hardware}.Run with an NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), WARP (Microsoft Basic Render Driver) and Windows 11 build 26200, debug layer on with 0 errors. DXC
ps_6_0and FXCps_5_1gave the same results.After the rebase, all
tests/startup_image_*_check.py,tests/startup_gfx2hlsl_*_check.py,tests/startup_translator_check.pyandtests/docs_links_check.pypass.Not drawn: fractional LOD values, a linear mip filter, 1D, 3D, a16 and compute stages. Heap LOD stays with #2221.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T08:54:23Z.
Review: COMMENTED
Review of head
0750f9ae00ec09356d57a46a81e1aa4f1b5333b3(Linux-side only).Scope read:
git diff --stat origin/main...HEAD(9 files, +441/-14), then targeted reads oftools/startup/gfx2hlsl.py,src/startup_stubs/translated_sampler_bindings.h,CMakeLists.txtand theimage_sample_btest change. Title is neutral, PR is mergeable. Linux CI job passes. Windows and fixture CI jobs were still pending when I looked.Commands run locally (all passed):
python3 -B tests/startup_image_sample_lod_check.py(controls: smpl line and call, refusals, mip filter 0 stays smp, heap accepted and logged once, draw model)python3 -B tests/startup_image_sample_b_check.pypython3 tests/docs_links_check.py(433 links ok)python3 tests/bidi_controls_check.py(clean)git diff --check origin/main...HEAD(clean)Mutations (both killed, tree restored with
git checkout -- .):lod_limits=bool((words[2] >> 26) & 3)forced toFalsein the new constant-sampler branch:startup_image_sample_lod_check.pyfails ('l limits' manifest showssmp, notsmpl).if words[2] & 0xfffff:forced toif False:: fails withl bias was accepted.Findings
src/startup_stubs/translated_sampler_bindings.h, thelod_limitscomment): the first line is now about 150 columns, while the file otherwise wraps near 120. Please re-wrap it.tools/startup/gfx2hlsl.py, around lines 2021-2038): a constantimage_sample,_lor_lzsampler with a non-zero LOD bias or MIN_LOD above MAX_LOD is now refused. Before this change it translated. This looks intended and is covered by tests, but please say in the PR body that it can drop pipelines that translated before.startup_image_sample_lod_{warp,hardware}draw tests were not run by me. I did not run the Windows WARP job. The PR's Windows CI job is the relevant evidence and was pending, so it should be green before this leaves review.AI-assisted; commands listed were executed locally.