Integrate the native C++ shader translator and resource binding updates #3039
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!3039
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/3039/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?
@R0Y00 on GitHub · 2026-11-27 10:03 UTC · original
R0Y00:cpp-migration→main· +25403 −27 · 161 files · 35 commits · merged 2026-11-27 10:13 UTCChange
Integrate the published C++ shader migration branch into main. The direct compute translator gains packed integer conversions, bit alignment and bit-field operations, and preservation of the high destination half for binary16 arithmetic. The resource path handles a byte-address descriptor selected through the GPU heap. The offline compiler resolves, caches and watches RTV variants. Implementation and fixture history are in #2986, #2989, #2996, #2998, #3003, #3020 and #3025.
Verification
Head under review is
b8f49259. Integration checks on the merge result are pending. On x64 Windows with the documented development prerequisites, run:Record the tested merge commit, build configuration, failures and capability skips. For GPU results include adapter, driver, backend and debug-layer status. Compare the existing main paths and the new translator on identical inputs with independent caches. Report any previously accepted request that now fails, changes bindings or produces different output.
Review
Please check the shared decode, binding and cache interfaces, preservation of existing runtime behavior, and explicit diagnostics for unsupported forms. Corpus coverage is a regression measurement. Further instruction coverage can land independently. Keep the PR in draft pending integration results and review.
AI-assisted integration PR.
* xmem: split slot 31 placeholders when the OS hides the placeholder bit The region query reports placeholders with Flags bit 0x100 on Windows. Wine leaves it 0, so alias_placeholders refused every split or coalesce and queue slot 31 batches failed with ERROR_INVALID_ADDRESS whenever a run was not exactly one placeholder. Probe once: if the bit is missing and VirtualFree with MEM_PRESERVE_PLACEHOLDER refuses a plain reservation and leaves it whole, offer any reserved region to the split. A plain one then fails the split instead of being released. Where the bit is reported nothing changes. * tests: slot 31 split inside an XMem reservation, with a committed-target control xmem_placeholder_split maps two pool pages into the middle of an XMem reservation through X2WMapPageBatch and checks the bytes, a write through the destination and the reserved neighbours. A batch onto a committed page in the same reservation must fail and keep its bytes. xmem_placeholder_split_control disables the fallback and passes only when the split step fails; it skips where the OS reports the placeholder bit. * docs: placeholder fallback for slot 31 splits under Wine * xmem: copy DirectStorage destinations under the mapping mutex Add x2w_xmem_copy_to_destination. It checks that the whole destination capacity is committed and writable, and copies the data, both under memory.mutex. A run break (unmapping a page of a shared run and mapping its other pages again) also runs under that mutex, so it can neither make the check see a transient reservation nor start during the copy. Lazily mapped pages of both ranges are committed before the mutex is taken. A fault under the mutex is passed on: the lazy commit handler now skips mapping threads, as retry_remapped_page already did. The region walk moves from XCRDAPI's destination_writable to x2w_local::committed_writable, so both DLLs share one implementation. * startup: copy DirectStorage data through x2w_xmem_copy_to_destination A plain-memory destination is now checked and written by xmem.dll under its mapping mutex when the export is there. Before, the VirtualQuery pre-check could run while an XMem run break had the destination's page unmapped for a moment, and refuse a destination that was mapped before and after. Without xmem.dll the check and the copy run in XCRDAPI as before. A copy that faults on its source now fails the request ("copy faulted (source not readable)") instead of raising in the stand-in. * tests: DirectStorage copy during an XMem run break startup_dstorage_break_window holds an unmap of page 5 of an 8-page run in the window where the run is apart (the xmem test-controls build's X2W_XMEM_TEST_HOLD_WINDOW), checks that page 2 reads MEM_RESERVE there, and submits a memory-source request into page 2. The request must not complete within the 1000 ms hold, then complete with S_OK with every byte in place after the release. It also covers a request with no break and a read-only destination refused on the xmem path. startup_dstorage_break_window_control builds XCRDAPI with the export lookup's name changed, so it judges the destination with its own VirtualQuery inside the window. It must report "refused while the run was broken". * xmem: split an owned placeholder before mapping a page into it A map into the middle of a larger placeholder always fails first, so every single-page XMemMapPhysicalPages call made two MapViewOfFile3 attempts. Under Wine each attempt is a server round trip whose cost grows with the view count. Split first when the target is not an exact placeholder; fall back to the map-first path if the split or the map fails. X2W_XMEM_TEST_MAP_FIRST=1 keeps the old order for tests. x2w_xmem_map_counts reports the attempts. * xmem: answer non-faulting readers outside run breaks With X2W_XMEM_SHARED_VIEWS=1, unmapping a page inside a run unmaps the whole run and maps its other pages again. A touch of those pages in between is retried by the fault handler, but a region query or a kernel copy does not fault: it reads the pages as reserved, or fails. x2w_xmem_stable_call(fn, context) runs fn when no break begins or ends around it, else again under the mapping mutex. XMemVirtualQuery, and through x2w_local::outside_run_breaks the stand-ins' x2w_local::writable, measure_placed_buffer (slot 133) and snapshot_samplers, now answer that way. Without shared views no break begins, so fn runs once as before. xmem_run_break_readers holds a break open with the test-controls build and checks that each reader waits for it and then sees the page committed; its control build runs the stand-in readers directly and they answer inside the window. * xmem: answer the main module's VirtualQueryEx outside run breaks The title queries its own pages through its VirtualQueryEx import. With X2W_XMEM_SHARED_VIEWS=1 xmem.dll now points that import at a wrapper that runs the query through x2w_xmem_stable_call, so a page of a run that is being taken apart is not reported as reserved. The module is pinned only when an import was changed (the pin is undone with the import if it is refused), so a main module without the import can still unload the shim before its first mapping call. xmem_run_break_readers checks the wrapped import of its own executable inside a held break. * xmem: retry a fault in the break after the one the handler saw end retry_remapped_page names the break a fault belongs to as seen | 1. When the handler reads the generation after the break has ended (even), that names the next break, so a fault on the same page in that next break is not retried and the access violation ends the process. Name the break that just ended instead: (seen - 1) | 1. Back-to-back breaks over one page made this show up: with a reader on page 20 and page 21 toggled, the hold-ignored child of xmem_page_runs_check.py crashed in 6 of 6 runs once map calls also open a break, and passed 6 of 6 with this. Test build: X2W_XMEM_TEST_HOLD_RETRY=<name> holds the handler before it reads the break. xmem_run_break_readers gets a case that faults in break A, is held until A ends, and faults on the same page in break B. The xmem_run_break_readers_next_break_control test runs it without the hold. * xmem: run readers once without shared views, and write their answers after a break Without X2W_XMEM_SHARED_VIEWS, every unmap still counts in the break generation (begin_break is not gated on the switch), so x2w_xmem_stable_call made default-mode readers wait for memory.mutex. Each page has a view of its own there, and no break takes a page away from a reader, so stable_call now runs fn directly until shared views are on. The comment, and the message of "xmem: answer non-faulting readers outside run breaks", saying no break begins without the switch were wrong. XMemVirtualQuery and the VirtualQueryEx import wrapper answered into the caller's buffer inside stable_call. On its mutex path the lazy-commit handler passes faults on, so a buffer in an uncommitted mapped slot was not committed there. Both now answer into a local copy and write it out after the call. A refused pin of the VirtualQueryEx wrapper is logged with its error and the restore count. measure_placed_buffer keeps the query count of a pass that ran again. The docs describe stable_call and the load-time read of the switch. "xmem: answer the main module's VirtualQueryEx outside run breaks" said the title queries its own pages through VirtualQueryEx. An import scan shows only that the executable under test imports it. How often it is called was not measured. Checks in xmem_run_break_readers: a break that begins while fn runs makes it run again under the mutex (pins the after-check); default mode answers inside an unmap (xmem_run_break_readers_default); lazy commit with the output in an uncommitted slot (xmem_run_break_readers_lazy); the reader's 300 ms now count from its start. * xmem: join a page mapped on its own call to the view before it Start-up maps nearly every page with a call of its own (45595 of 45602 runs had one page), and under Wine each map costs more the more views the process has. With X2W_XMEM_SHARED_VIEWS=1, a mapping call whose pages form one run now joins the recorded run that ends at its address. It joins only when its first page is the next slot of the section behind that run's last page, and both lie in one reservation of the shim. The new pages' range is split to a placeholder of its own, the run is unmapped inside a break (begin_break, as for an unmap), the two placeholders are joined, and one view is mapped over both. A refused step before the unmap changes nothing. After it, the run is mapped again as it was (map_recorded) and the new pages get a view of their own. If the run cannot be restored, its pages are forgotten and the call fails, as in an unmap. Default mode is unchanged. Test build: X2W_XMEM_TEST_NO_MERGE=1 turns the merge off; X2W_XMEM_TEST_FAULT stages 4 (joined map) and 5 (joining the placeholders) refuse a step. xmem_cross_call_merge covers 32 single-page calls -> one view, an unmap in the middle, slots in reverse order (32 views), a reader held in the window, both refused steps, and two reservations. xmem_cross_call_merge_control keeps the old one-view-per-call layout under NO_MERGE. xmem_cross_call_merge_deployed shows the deployed shim ignores that switch. xmem_cross_call_merge_default covers default mode. xmem_page_runs_check.py expected "Mapping the page again does not join the pieces: three views". The page now joins the lower piece (two views). The three-view layout stays asserted by xmem_cross_call_merge_control. xmem_page_runs_device_check maps the upper view first and the single pages in reverse slot order, so its view boundaries stay. * xmem: stop a joined run at 64 pages An unmap inside a run takes the whole run apart and maps its other pages again, and a cross-call merge does the same to the run it joins. Nothing bounded the joined run, so after loading every title unmap inside a run of thousands of pages cost one long break: 46-72 ms each in a gate run under Wine, with readers waiting 63 s in all and presents at 2.4/s. merge_with_previous now leaves a page on its own when the joined run would be longer than max_merged_run_pages (64); the next pages join that one. The test build's X2W_XMEM_TEST_MERGE_CAP replaces the cap for a timing mode. Measured under Wine with every byte of the run written (xmem_cross_call_merge_check timing, median of 5): an unmap inside a run of 64 pages takes 0.28 ms, of 512 pages 2.1 ms, of 4096 pages 13 ms; joining a page to a run of 63 takes 1.5 ms, about what a page mapped on its own costs (1.4 ms). The fixture process has a few views, the title process tens of thousands. xmem_cross_call_merge gets a capped case: 192 single-page calls make three views of 64 pages, and an unmap held in its window in the middle one takes apart 64 pages while the outer two stay mapped. The control, deployed and default modes now print their pass line at the end of main, only with no failed check. * xmem: retry a fault from any of the last 64 breaks, not only the last begin_break replaced the recorded ranges, so retry_remapped_page saw only the last break. A handler that ran after a later break on another run had begun found its address outside those ranges and passed the fault on. Joins made that the normal case: one permissive XMemMapPhysicalPages call joins the CPU run and then its GPU mirror run under one memory.mutex hold, and each map call opens a break of its own. RemapWindow now keeps the ranges of the last 64 breaks with their id (the odd generation). The handler names the newest break whose ranges hold the address, so a fault in a later break of the same page is still retried once more. xmem_run_break_readers_two_runs faults in break A on run 1 and holds the handler until break B on a disjoint run 2 is held open. xmem_run_break_readers_mirror does the same across the CPU join and the GPU mirror join of one call (X2W_XMEM_PERMISSIVE, X2W_XMEM_GPU_MIRROR). With one kept break both end the process with an access violation (exit 5). The RemapWindow and hold_window comments now also name the merge. * xmem: run title ReadFile/WriteFile again after a run break refused the buffer Inside a run break a kernel copy into or out of a page of the run fails at once, with no fault to retry. Measured under Wine with the break held open (xmem_run_break_readers ReadFile_import/WriteFile_import, before this change): ReadFile fails with ERROR_NOACCESS and leaves the file position at 0, WriteFile fails with ERROR_INVALID_USER_BUFFER. With X2W_XMEM_SHARED_VIEWS=1 at load, the main module's ReadFile and WriteFile imports go through a wrapper. A synchronous call that fails with one of those errors while a break was in progress, or began or ended around it, and whose buffer lies in a run, waits for memory.mutex and runs again, at most 4 times in all. Other failures return at once as before: a read into a reserved page in no run fails at once (io_outside_runs). With lazy commit the ReadFile wrapper calls read_file_committed inside (lazy_read_file). Overlapped I/O, a call that a break cuts short after part of the copy, and I/O from other modules stay uncovered. * xmem: write back only what XMemVirtualQuery's query writes, and pass lines at the end XMemVirtualQuery copied all 64 bytes of the caller's buffer before the query and wrote all 64 back after it. era_query writes 49 (the MBI and the tail byte at 0x30), so bytes 49-63 were read and rewritten where they never were before, and a buffer of 49-63 bytes that ends at a page end could fault. The caller's buffer is no longer read; on success tail_offset + 1 bytes go back, on failure none. xmem_run_break_readers_default prints its pass line at the end of main, only with no failed check, so a crash after the cases does not read as a pass. xmem_page_runs_device_check prints a check_failed line before the map-order returns, which were silent and looked like a refused device. * xmem: say the run cap bounds joined runs only, and test the break ring's edge The cap of 64 pages (max_merged_run_pages) is checked only where a page joins the run before it (merge_with_previous). A run mapped by one call (map_run in map_pages_locked) is not capped, and neither are the survivors map_recorded maps again after an unmap inside such a run. Both are as long as before the cap; a single large call is the title's own choice and was not the regression. The comment above the cap and docs/startup-runtime.md said the cap bounds every later break of a run; they now say it bounds the runs that joining builds, and name the two uncapped paths. xmem_run_break_readers_ring_edge holds a fault in break A before its handler reads the breaks, ends A, then makes 63 or 64 later breaks (map and unmap a lone page). After 63, A is still recorded and the fault is retried; after 64, A's slot (RemapWindow::kept) holds the newest break and the fault is passed on, which the reader's own __except catches. * tests: map single-page XMem views from high to low * tests: preserve the XMem linear buffer view boundary --------- Co-authored-by: JohnConnorNPC <[email protected]> Co-authored-by: Codex <[email protected]>AMD's user-mode DXIL compiler (`amdxc64.dll` `8.18.10.0514`, driver `32.0.32029.2010` on Radeon RX 9070 XT) queries `llvm::Module::getNamedMetadata("llvm.ident")` and dereferences the returned `NamedMDNode*` (`[rcx + 0x40]`) without a null check during `CreateComputePipelineState` and `CreateGraphicsPipelineState`. `dxc.exe` always emits `!llvm.ident`, while `IDxcValidator::Validate` treats it as optional, so direct DXIL containers from `DxilModule` passed validation, WARP, and NVIDIA while crashing all seven direct-DXIL `_hardware` tests with `0xC0000005` on RDNA 4. - `src/dxil_module.h`: emit `!llvm.ident = !{!<id>}` (`!{!"x2w"}`) in `DxilModule::finish_compute`, covering `cs`, `vs`, `gs`, and `ps`. - `src/gfx1013_pixel.cpp`: emit `!llvm.ident = !{!0}` (`!{!"x2w"}`) in `x2w::direct_gfx1013_constant_pixel`. - `tests/native_dxil_llvm_ident_check.py`, `tests/cmake/native_dxil_llvm_ident.cmake`: check `!llvm.ident` across `gfx1013-container-cs`, `gfx1013-container-vs`, `gfx1013-container-ps`, `gfx1013-container-rect` (`vs`, `gs`, `ps`), and `gfx1013-direct-constant-ps` with stripped-`!llvm.ident` negative controls, and draw both direct pixel paths on WARP and hardware with mutated-output negative controls. - `docs/experiments/native-dxil-llvm-ident.md`: record the A/B isolation and RX 9070 XT + WARP verification results. Refs #2915 AI-assisted.The direct compute frontend refused these three VOP3 bit operations. They now follow the gfx2hlsl.py VOP3 table: v_alignbit_b32 returns bits [k + 31 : k] of {S0, S1} with k = S2[4:0], v_alignbyte_b32 the same with k = 8 * S2[1:0], both returning S1 for k = 0, and v_bfm_b32 is ((1 << S0[4:0]) - 1) << S1[4:0] like s_bfm_b32. The zero case is a select, so the masked shift in the other arm stays in range. tests/native_align_bfm_check.py dispatches every shift 0 to 31 and every byte count, repeated with bit 5 set, against a CPU reference, and its controls check that the zero-shift, exchanged-source and unmasked references differ. Refs #2985. AI-assisted. Co-authored-by: legacy-code-archaeologist <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>