gpu: bind translated startup sampler heaps #1230
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1237"
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 Jess-Doit on 2026-11-24T04:52:47Z.
Refs #1143. Stacked on #1217.
Change
Bind the manifest's 2,048-entry sampler table at
s0, space1beside the translated static samplers. The stand-in snapshots the bound heap's 16-byte entries, decodes the sampler words, and publishes a private shader-visible heap. Unavailable entries use a transparent-black border sampler and are counted by cause. Recorded heaps stay alive through queue completion. The guarded manifest reserves entry 2047, and the original manifest can address all 2,048 entries. Translation stays opt-in throughX2W_SAMPLER_HEAP=1.Keep the 16-byte wrapped source stride separate from the adapter's desktop increment when creating and copying samplers.
Verification
Tested
2cf332e3(this change merged with #1217's head1e0a9834) on Windows 10 22H219045.6456, GTX 1060 6 GB32.0.15.6094, and in-box WARP10.0.19041.5794, with the D3D12 debug layer enabled. Debug and Release each passed 19/19 with zero skips: the 12 focused checks below plus main's neighbouringstartup_cb_blend_*(4) andstartup_stream_*(3) fixtures. The source-built desktop readback shares the stand-in's binding helpers and uses DXC and FXC. It verifies separate wrap and clamp results, an unreadable entry, the reserved fallback, and static-only manifests. Wrapped-device checks verify the 16-byte CPU handles and single and ranged copies against desktop increments of 32 and 152 bytes, respectively.Two draws recorded before one submission sample the same index. The first heap clamps and the new heap wraps, producing 0.75 and 0.25. Rebinding the old heap for the second draw gives 0.75 again and fails the second pixel check. A separate source mutation decoded slot zero for every readable entry. Both adapters failed at offset 16 with
expected=3f400000 actual=3e800000. Restoring the source passed all 12 focused CTests in each preset with zero skips and zero D3D12 warnings or errors.After merging the updated #1217 branch, Debug and Release each passed 12/12 sampler, 4/4 CB blend, and 3/3 stream tests with zero skips. The GTX 1060 and WARP stream draws matched all 32 RGBA pixels and the shader swap changed exactly 16.
Set
$pythonto a Python interpreter with the repository's test dependencies.Until #1217 merges, this PR's diff also shows #1217's commits; the change here is the last commit before the merge (
f1fa4355) and the merge itself.AI-assisted (Codex, reviewed with Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:58:39Z.
Review: COMMENTED
Reviewed
2cf332e3on Linux (Windows build/tests were not run locally).Stacking & diff audit
#1217is already merged (1e0a9834) and merged into this branch at2cf332e3.src/startup_stubs/translated_sampler_bindings.h:smpheap 2048 1andsmpheap 2048 1 fallback 2047manifests;create_translated_rootbinds the 2,048-entry sampler descriptor table ats0, space1viasampler_root_parameter(srvs)(2whensrvs > 0,1whensrvs == 0).snapshot_samplersguards pointer overflow (source.address > UINTPTR_MAX - translated_sampler_count * title_sampler_stride), reads page-aligned runs withReadProcessMemory, and zeros words on partial/failed reads.create_sampler_snapshot_heapcreates a 2,048-entry shader-visible sampler heap, tracksunbound/out_of_range/unreadable/invalid_tokencounts, and fills missing/invalid entries with transparent-blackborder_sampler().src/startup_stubs/d3d12_draw.inl&src/startup_stubs/d3d12_xs_device.cpp&src/startup_stubs/d3d12_capture.inl:device_create_descriptor_heap/desktop_cpu_handle/title_descriptor_stridekeep the 16-byte title sampler stride separate from the desktop descriptor increment.list_set_descriptor_heaps(slot 32) tracks the active shader-visible sampler heap;retire_draw_sampler_heapsretains submitted heaps behind a signaledID3D12Fence(and retains indefinitely if fence creation/signal fails).docs/startup-runtime.md,tests/startup_sampler_heap.cpp,tests/startup_sampler_heap_check.py,CMakeLists.txt: 100% title-neutral.Linux checks (
2cf332e3)tests/startup_sampler_heap_check.py(default Python/manifest self-test mode): passed (exit 0).docs_links_check.py: passed (16 Markdown files, 280 links).bidi_controls_check.py: passed (1047 files).form_coverage_check.py: passed.git diff --check: clean.startup_sampler_heap_{warp,hardware}andstartup_sampler_heap_wrapped_{warp,hardware}: not built or run locally.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:08:56Z.
Tested on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
2cf332e3:--preset dev):cmake --preset dev && cmake --build out/build/dev -j 6 --target d3d12_xs_shim offscreen_checkctest --test-dir out/build/dev -R "^startup_sampler_heap_(controls|warp|wrapped_warp)$" --output-on-failure-> 3/3 passed (2.17stotal:startup_sampler_heap_controls0.18s,startup_sampler_heap_warp1.72s,startup_sampler_heap_wrapped_warp0.24s)/O2(--preset release):cmake --preset release && cmake --build out/build/release -j 6 --target d3d12_xs_shim offscreen_checkctest --test-dir out/build/release -R "^startup_sampler_heap_(controls|warp|wrapped_warp)$" --output-on-failure-> 3/3 passed (1.93stotal:startup_sampler_heap_controls0.17s,startup_sampler_heap_warp1.50s,startup_sampler_heap_wrapped_warp0.22s)