native: carry byte-window formatted loads and typed heap loads to main #3409
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3409"
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-28T22:50:56Z.
Brings the two
cpp-migrationfeatures tomain: #3034 (formatted loads through a byte-address rewritten descriptor, as RonLogic's #3232) and #3042 (one-channel typed loads through a GPU-selected heap slot). Takes over #3232 under the 2-hour rule (no activity since 12:39 UTC, see the comment there). RonLogic's commits are kept as they are.This is the first step toward #3063 on
main. Its bucket, "direct resource-heap load requires the selected GPU slot and its view type", is the largest in #3224 (330 shaders, 4.67 M dispatches in Leyukaka's 900 s run).Changes on top of #3232
main8ecd30fe.indirect_table_buffergainedalignmentas its sixth parameter onmain, so the compute input call passesD3D12_RAW_UAV_SRV_BYTE_ALIGNMENTbeforetrue, slot.requires_identity_dst_sel(Leyukaka's point 1 on #3232). Every other caller was checked against the new signature.formatted_byte_loaduses a byte window the caller already bound (main's graphics path) and otherwise selectsbyte_window_srvfrom the zero-stride rewrite.heap_typed_srvgoes afterindexed_raw_srv(kinds are serialized by value, so appending keeps existing caches valid). Thetyped_dwordcache identity sits inmain'scached_compute_ir. Test section 12 sits next tomain's sections 10 and 11.offen, an immediate offset or a nonzerosoffsetis refused by the decoder ("formatted load requires zero or a single linear index"). Doc updated (typed_dwordcontract, 160 assertions).Leyukaka's point 2 on #3232 (the pixel-shader MTBUF path has no test) is not covered here.
Tests
Windows 11 26200, RTX 3080 (32.0.16.2124), WARP, dev preset,
-j1:^(native_.*|startup_compute_.*|compute_manifest.*|direct_compute.*)$: all pass exceptstartup_compute_dispatch_output_{warp,hardware}andstartup_compute_half_buffer_uav_{controls,hardware}. Those four fail the same way onmainwithout this PR (see #3353). WARP wave32 cases skip with 77.native_global_srv_heap_replay_hardware: 160 assertions pass. With thesrc/,tools/and fixture changes of the #3042 commit reverted, it fails at "record typed select 3".startup_compute_mtbuf_window_{controls,hardware}(identity and swapped X/Y, writable alias, CBV token) pass after the merge.Refs #3232, #3042, #3034, #3023, #3224.
AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-29T00:25:28Z.
Hardware test on the Windows test PC (RTX 4070 Ti, Windows 11) at head
d4d9af41:cmake --build --preset dev: build exit 0ctest --preset dev -j 1 -R '^(native_.*|startup_compute_.*|compute_manifest.*|direct_compute.*)$' -E 'startup_audio_(output|pacing|provider)': 515/519 passedThe 4 failures are
startup_compute_dispatch_output_warp,startup_compute_dispatch_output_hardware,startup_compute_half_buffer_uav_controlsandstartup_compute_half_buffer_uav_hardware. They are the same ones that fail onmainwithout this PR (#3353). No other failures, timeouts or not-run tests.AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T01:18:54Z.
Thanks, that matches my run: the same four failures, which also fail on
mainwithout this PR (#3353, fixed by #3389).AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T01:37:15Z.
Review: CHANGES_REQUESTED
Request changes at
d4d9af41. Read from the diff only, not built here.Blocking: the in-process path drops the DST_SEL check.
translate_compute_natively(src/startup_stubs/d3d12_compute_dispatch.inl, slot loop) acceptsbyte_window_srvthroughaccepts_cbv_windowand pushes the slot without copyingview.requires_identity_dst_sel, sorecord_translated_dispatchcallsindirect_table_buffer(..., false). That path is tried before the published manifest. Onmainthis program was refused at translation. With this PR andX2W_NATIVE_SHADERSset, a V# with swapped DST_SEL, a slot 18 SRV with a non-default mapping or a slot 17 CBV token binds without a check (the three checks ind3d12_draw.inlare all gated on that flag). The same drop applies when the pack returns a prepared program, not only on live translation. I could not find what the doc line "The in-process path falls through to that manifest for a byte window" refers to.startup_compute_mtbuf_window_check.pyremovesX2W_NATIVE_SHADERS, so this path is not tested. Suggested fix: setslots.back().requires_identity_dst_sel = view.requires_identity_dst_sel;and run theswappedcase once with the variable set.One-line mutations the tests do not catch:
src/startup_stubs/native_global_srv.h,global_srv_contract:view.dword_channels != 1->!view.dword_channels. There is nodword 3 2case.view.stride != 4 ||or!view.bytes || view.bytes % 4 ||. No stride or size negative exists.src/startup_stubs/d3d12_draw.inl:(words[3] & 0xfffu) != 0xfacu->(words[3] & 0x3fu) != 0x2cu. Only an X/Y swap is tested, and the test load is_xy.Checked and correct:
0xfacis identity DST_SEL. The decoder refuses typed heap loads withop > 3(so no d16),offen, an immediate offset or a nonzerosoffset.heap_typed_srvis appended last and the cache decode bound covers it.compute_heap_bindingincludes it, so the pipeline treats it as heap-indexed. The revision hash coversdirect_compute_cache.cpp, so cached bindings in the old format do not decode under the new layout.git merge-treeagainstmain212d4b5fis clean.Scope: the startup runtime still passes
HeapViewContract::none(translate_computehardcodes it atgfx1013_compute_native.cpp:2048;compile_dxilline 858 for runtime requests). So "direct resource-heap load requires the selected GPU slot and its view type" still refuses every runtime request.typed_dwordapplies only tocompile_dxilwith a.viewsfile. In the runtime, the only change is that compute MTBUF loads through a table byte window are no longer refused with "non-contiguous resource descriptor".The only build file is
tests/cmake/startup_compute_mtbuf_window.cmake(add_testonly). It is picked up by the existing glob, andCMakeLists.txtis unchanged.Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T02:10:30Z.
Thanks, all addressed in
30de88b6:In-process DST_SEL:
translate_compute_nativelynow copiesrequires_identity_dst_selinto the slot.startup_compute_mtbuf_windowruns the identity and swapped X/Y cases a second time withX2W_NATIVE_SHADERSandX2W_NATIVE_SHADERS_ONLYset. With that line reverted, the swapped case writes the output (word 0 reads01234567, not the sentinel). The doc sentence about the in-process route now says what the code does.Mutations:
0x0103edec) must refuse on the published route;global_srv_contractgetsdword 3 2, stride 8, an odd byte count and a zero byte count as compile refusals.I ran each of your four one-line mutations locally, and each now fails its test.
Scope: agreed, the runtime still passes no contract, so for a title run this only changes the MTBUF table byte window. The PR body says it is translator side only. #3023 has the measurement for the runtime side.
native_global_srv_heap_replay_hardware,startup_compute_mtbuf_window_*,native_mtbuf_*andnative_direct_container*: 6/6 pass on an RTX 3080 (32.0.16.2124). The WARP wave32 cases skip with 77. #3415 has the same fix merged in (242 assertions on that branch).AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T02:39:30Z.
Review: APPROVED
Approve at
30de88b6. Read from the diff only, not built or run here.Blocking point fixed.
src/startup_stubs/d3d12_compute_dispatch.inl:358copiesview.requires_identity_dst_selinto the slot, and line 789 passes it toindirect_table_buffer. The live translation (line 325) and the prepared pack program (line 317,decodereads the flag atdirect_compute_cache.cpp:141) both reach that loop.startup_compute_mtbuf_window_check.py:117-123runs identity and swapped X/Y withX2W_NATIVE_SHADERSandX2W_NATIVE_SHADERS_ONLY=1.load_compute_translationreturns before reading the published manifest under_ONLY(line 130), so the identity readback can only come from the in-process route, and the refusal text is produced only by the binder (d3d12_draw.inl:2573).The four mutations, by reading:
dword_channels != 1->!dword_channels:typed_dword_2(native_global_srv_heap_replay_check.py:556) no longer gets the refusal text, so itsrequirefails.view.stride != 4 ||:typed_stride_8(line 557).!view.bytes ||orview.bytes % 4 ||:typed_bytes_zero(561) andtyped_bytes_odd(559, 256 + 2 bytes).0xfff/0xfac->0x3f/0x2c:SWAPPED_ZW = 0x0103edec(startup_compute_mtbuf_window_check.py:112-114) has0xdec & 0x3f == 0x2c, so it binds and the guard compare fails.Not blocking, follow-up (by reading): a byte window read through a GPU-selected heap descriptor still has no identity requirement.
resource()returns fromheap_resource(gfx1013_direct_compute.inl:411-412) before the flag is set (433), and the heap loop in the dispatch (d3d12_compute_dispatch.inl:934) passes no flag.translate_computepassesHeapViewContract::none(gfx1013_compute_native.cpp:2048), under whichheap_resourcerefuses, so the runtime does not reach this today. It needs the same check when the contract is wired into the runtime.CI does not run the changed tests: on a pull request the Windows job runs
ctest --preset pr(windows.yml:493), and that filter matches neitherstartup_compute_mtbuf_window_*nornative_global_srv_heap_replay*. The inter-diff fromd4d9af41touches no build, CI or hook file. #3415 (e232e475) contains30de88b6.Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T02:41:05Z.
Thanks for the re-review. Noted the heap byte-window follow-up for #3023: in the raw-twin proposal there, a byte window read through a GPU-selected heap record needs the same identity requirement before the runtime passes any contract. Until then it stays refused.
AI-assisted.