runtime: bind published typed buffer inputs with 32-bit components #3386
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3386"
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 Not-Saii on 2026-11-28T18:06:17Z.
Refs #3224
Behavior
In the #3224 census,
SRV kind typed_buffer_srvis the largest gap between compiling a compute program and publishing its manifest. These are programs that read withbuffer_load_format_xto_xyzw(MUBUF, element index only), which the direct compiler reads as aBuffer<uint4>.src/direct_compute_cache.cpp):format_compute_runtime_manifestwritessrv <register> typed table <parameter> <byte> bytes <n>.nis 4 bytes per component of the widest load on that binding;required_bytesis already the maximum over the binding's loads.src/startup_stubs/d3d12_compute_dispatch.inl): the dispatch path resolves the table entry with the existingindirect_table_bufferrange rules and binds a UINT buffer view (R32_UINTtoR32G32B32A32_UINT) over it. A UINT view returns the same bits as the guest format unit only for 32-bit UINT, SINT and FLOAT components, so only those are bound:token_view, so content tokens decode as in the other buffer readers, then checked with JB2WIN'styped_dword_channels/typed_dword_uint_formatfrom the heap contract (#3042).docs/experiments/compute-typed-buffer-inputs.md). A typed input on an indirect Dispatch is refused.Manifest route only. Since #3449 the launchers set
X2W_NATIVE_SHADERS_ONLY=1, andload_compute_translationreturns before it reads<key>.txt. A default run therefore does not use this binding: the in-process route (translate_compute_natively) is unchanged and still refusestyped_buffer_srvwithview kind 1 is not bound for a natively translated program. The binding applies to runs withX2W_NATIVE_SHADERS_ONLY=0andcompile_dxilmanifests. Binding the kind on the in-process route is a separate change.Not in this PR:
packed_d16_x_uav(#3389) is merged; this branch mergesmainafter it.Tests
tests/startup_compute_typed_buffer_srv_check.py(tests/cmake/startup_compute_typed_buffer_srv.cmake) uses the published route:compile_dxil --requests→<key>.txt→ slot 14 Dispatch on the stand-in._controls(no GPU): source-built programs for 1 to 4 components publishsrv 0 typed table 1 0 bytes 4n._warp/_hardware: for each width, a 32-bit FLOAT descriptor of 50 elements.R32G32B32A32_FLOATview token (new consumer modedispatch-srv-token-typed).dispatch-records32-input-at-<bytes>); the words read shift by one element.dispatch-records32-input-null).no translation.tests/native_compute_manifest_reasons.cpp: atyped_buffer_srvof 20 bytes or of 6 bytes gets no manifest (SRV kind typed_buffer_srv).tests/startup_slot67_indirect_dispatch_check.py: with its manifest line replaced bysrv 0 typed table 1 0 bytes 4, the indirect Dispatch is refused withrequires fixed-table raw buffers.Verification
Branch head
4cd38c90=da4fe59c(review cases) + a merge ofmaine3f9a64f(d2acde2b) +a3854d64(review fixes) +0663f6ed(measurements) + a merge ofmain8a30428a(4cd38c90). Measured at0663f6edand again at4cd38c90. Windows 11 build 26300, MSVC x64 Debug, Windows SDK 10.0.26100 DXC, D3D12 debug layer enabled._controls,native_compute_manifest_reasons(38 cases) andstartup_slot67_indirect_dispatch_hardware: passed._hardware, NVIDIA GeForce RTX 4090, driver 32.0.16.1088: passed. 1, 2, 3 and 4 components read 50 elements and then zeros, the UINT and SINT FORMATs read the same words, a base one element in shifts them, an all-zero descriptor reads zeros, the token reads the same elements, and 8, 11, 11 and 12 refusal controls passed. No debug layer errors.da4fe59c):FirstElement→ 0, the dropped whole-element check, each FORMAT row, and the dropped word 1 bits.0xfff80000→0xff000000fails at INDEX_STRIDE;(words[1] >> 30)→((words[1] >> 30) & 1)fails at bit 31; dropping the all-zero branch fails the null input (expected 00000000, read c5c5c5c5); dropping|| slot.typed_bytesfrom the indirect refusal failsstartup_slot67_indirect_dispatch_hardware._warp, Microsoft Basic Render Driver: capability skip (77). WARP reports 4-lane waves and the direct module needs 32.da4fe59c): with the stand-in's parse of thetypedline disabled,_hardwarefails at word 0 (expected 8b02a7f1, read c5c5c5c5).X2W_D3D12_VIEW_CONTENT_TOKENS=1) throughtoken_view.AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T18:53:35Z.
Measured
4a2720e0on the 878 untranslated requests of the 900 s census in #3224:compile_dxil <dxc dir> <cache> --jobs 8 gfx1013-direct-cs@0 --requests <request dir> <out dir>, built in a local integration ofmainf2972840with this PR and 17 other open PRs (none of the others changes the manifest's SRV kinds). Baseline: the same requests onmaind418f70e. Compile counts are unchanged (290 compiled, 588 refused); runtime manifests go from 124 to 146.Of the 112 programs that stopped at
SRV kind typed_buffer_srv:UAV kind typed_buffer_uavSRV kind comparison_texture_srv 2dUAV kind indexed_atomic_uavUAV kind unknownUAV kind half_scalar_uavNo other program changed manifest state. Whether the 22 bind at Dispatch (the 32-bit FORMAT check) is not measured here; that needs a run.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T20:09:14Z.
Review: CHANGES_REQUESTED
Reviewed
4a2720e0.Run on a release build of
mainf2972840with this PR and 17 other open PRs merged locally, Windows Sandbox, network off, vGPU:startup_compute_typed_buffer_srv_controlspasses.startup_compute_typed_buffer_srv_hardwarepasses on the hardware backend (the Sandbox's only GPU is the NVIDIA GeForce RTX 5080 vGPU). It covers 50 elements and then zeros for 1 to 4 components, the slot 18 token, and 4/6/6/7 refusals._warpskips (77): WARP has no 32-lane wave.Test gaps. Each mutation below still passes
_hardware:dispatch-records32the descriptor addresses the first byte of the placed input buffer, and the slot 18 token view hasFirstElement0. Mutation:src/startup_stubs/d3d12_compute_dispatch.inl:160view.Buffer.FirstElement = range.offset / element->0. Add a dispatch whose descriptor base is4 * channelsbytes into the input buffer, and expect the words shifted by one element.:155droprange.offset % element ||. Add, for 2 or more channels, a descriptor base 4 bytes into the input buffer. It should be refused witha typed input range does not start at a whole elementand leave the output untouched.:111case 20: case 21: case 22: return 1;->case 22: return 1;(the same holds for the 62/72/75 rows). Add dispatches with FORMAT 20 (UINT) and 21 (SINT), expecting the same raw words.:145drop(words[1] >> 30) ||. Add stride field0x4000 | 4 * channels, which sets bit 30 and keeps the 14-bit stride equal to the element size. It should be refused witha typed input descriptor is swizzled or not bounds-checked by record.Request changes for the test gaps above.
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-28T20:28:10Z.
@Leyukaka Thanks. All four gaps were real, and each now has a case that fails under its mutation. Fixed in
da4fe59c, which changes only tests and docs.Nonzero
FirstElement. New consumer modedispatch-records32-input-at-<bytes>puts the input descriptor's base that many bytes into the buffer. Each width reads once with its base at4 * channelsand expects the words shifted by one element.Mutation
view.Buffer.FirstElement = range.offset / element→0: fails,1 channels, base one element in: word 0 expected 8b06bba2, read 8b02a7f1.Whole-element check. For 2 or more channels, a base 4 bytes in must be refused with
a typed input range does not start at a whole element, leaving the output untouched.Mutation that drops
range.offset % element ||: fails,{'mode': 'dispatch-records32-input-at-4'}: word 0 expected c5c5c5c5, read 8b02a7f1(the dispatch reads from element 0 instead of being refused).Integer FORMATs. Each width also reads through its UINT and SINT codes (20/21, 62/63, 72/73, 75/76) and expects the same words. I ran each row's mutation separately (keep only the FLOAT code); each fails at that width's UINT case:
case 22only:1 channels, FORMAT 20: word 0 expected 8b02a7f1, read c5c5c5c5;case 64only:2 channels, FORMAT 62: ...;case 74only:3 channels, FORMAT 72: ...;case 77only:4 channels, FORMAT 75: ....All four read the sentinel, because the dispatch was refused.
Word 1 bits 30/31. A stride field of
0x4000 | 4 * channelsmust be refused witha typed input descriptor is swizzled or not bounds-checked by record.Mutation that drops
(words[1] >> 30) ||: fails,{'stride': 16388}: word 0 expected c5c5c5c5, read 8b02a7f1.Each mutation was applied on its own, the shim rebuilt, and
startup_compute_typed_buffer_srv_hardwarerun, then reverted. Without mutations,_controlsand_hardwarepass onda4fe59c: 1 to 4 components, the UINT/SINT FORMATs, the shifted base, the token, and 5/8/8/9 refusals. The setup was the NVIDIA GeForce RTX 4090, driver 32.0.16.1088, Windows 11 build 26300, Debug, with the debug layer enabled.#3397 (typed outputs, stacked on this PR) had the same four gaps, so I added the matching cases there: UINT/SINT stores, a base 8 bytes into the output (shifted for 1 and 2 components, refused as not element-aligned for 3 and 4), and word 1 bit 30. Under the same procedure, the output
FirstElement→ 0, the dropped alignment check, rows 1, 2 and 4, and the bit 30/31 mutation all fail its_hardwarecheck. The row 3 mutation is caught only by this PR's check: the RTX 4090 has no typed UAV store for R32G32B32, so no 3-component store reaches that row.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T20:34:49Z.
Review: APPROVED
LGTM — clean input-side of typed buffer route.
Adds
typed_dword_format_channelsandtyped_dword_input_viewfor publishedsrv typedinputs. Manifest formatter emitssrv <reg> typed table <param> <byte> bytes <n>lines; dispatch stub resolves table entries, binds UINT views of 32-bit components, and refuses invalid descriptors with precise reasons. Follows the same patterns as #3397 (typed outputs). Test fixture covers 1–4 components with comprehensive refusal controls.Ready to land.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:06Z.
Review: APPROVED
LGTM — clean input-side of typed buffer route.
Adds
typed_dword_format_channelsandtyped_dword_input_viewfor publishedsrv typedinputs. Manifest formatter emitssrv <reg> typed table <param> <byte> bytes <n>lines; dispatch stub resolves table entries, binds UINT views of 32-bit components, and refuses invalid descriptors with precise reasons. Follows the same patterns as #3397 (typed outputs). Test fixture covers 1–4 components with comprehensive refusal controls.Ready to land.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T02:14:07Z.
Review: APPROVED
Reviewed
da4fe59c. It changes only tests and docs since4a2720e0. The four test gaps from that review are covered intests/startup_compute_typed_buffer_srv_check.py:FirstElement(:128): each width dispatchesdispatch-records32-input-at-<4n>and expects the words shifted by one element.:143): for 2 or more components, a base 4 bytes in is refused witha typed input range does not start at a whole elementand the output stays untouched.:28,:126-127): 20/21, 62/63, 72/73 and 75/76 are dispatched and expect the same words.:136): stride field0x4000 | 4nis refused.A local run, release build of
main212d4b5fwithda4fe59cand five other pending changes merged:startup_compute_typed_buffer_srv_controlsand_hardwarepass;_warpskips (77).startup_compute_dispatch_output_warp, the existing failure onmainthat #3394 fixes.range.offset % element ||(src/startup_stubs/d3d12_compute_dispatch.inl:155) makesstartup_compute_typed_buffer_srv_hardwarefail.Not covered: PR CI builds the change, but the
prtest preset includes none ofstartup_compute_typed_buffer_srv_*, so CI does not run these checks.#3397 is stacked on this PR, so this one should merge first.
Approve
da4fe59c.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T12:06:49Z.
This branch conflicts with
main1990feadinsrc/direct_compute_cache.cppandsrc/startup_stubs/d3d12_compute_dispatch.inl(one region each): main added an optionalidentity_dst_selsuffix to thesrv N buf tableline, in the writer and in the parser.Resolution: keep main's
buf tablewriter with theidentity_dst_selsuffix and main'sidentity_dst_selparser branch, then add this branch'styped table ... bytesbranch after each.#3397 is stacked on this head and conflicts in the same two files, so it needs the same merge afterwards. Nothing else is open from my review; the approval is on
da4fe59c.Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T12:40:45Z.
Re-review of head
da4fe59cagainstmain77d1ba4d(204 commits ahead of the merge-base). The binding logic reads correctly: FORMAT codes, stride, DST_SEL, the word30xfff80000bound rule andNumElements= NUM_RECORDS all match the repo's decoder andindirect_table_buffer.MUST
main.git merge-tree --write-tree --name-only origin/main da4fe59cexits 1 insrc/direct_compute_cache.cppandsrc/startup_stubs/d3d12_compute_dispatch.inl, one hunk each, againstmain'sidentity_dst_sellines. The resolution posted at 12:06 is right: keep both branches. I also checked againstmainwith #3398 merged, and the conflict is the same single hunk per file. #3398 adds nothing to it.SHOULD
X2W_NATIVE_SHADERS_ONLY=1.load_compute_translationthen returns atif (native_shaders_only()) {before it reads<key>.txt, so the newsrv <i> typed tableline is never parsed in a default run.translate_compute_nativelystill throwsview kind 1 is not bound for a natively translated programfortyped_buffer_srv, because itssupportedtest has no typed branch. The change helps only-TranslateorX2W_NATIVE_SHADERS_ONLY=0runs withcompile_dxilmanifests. Please say so in the body and doc. A native-route binding (or a follow-up issue for one) is what would remove these refusals by default.typed_dword_input_viewreadsview_records()[words[1]]directly (grep -n 'view_records()\[words\[1\]\]'on the merged tree →if (known) record = view_records()[words[1]];).main's buffer readers usetoken_view(words, record, &created), which #3377 added. With the opt-inX2W_D3D12_VIEW_CONTENT_TOKENS=1, word 1 carriesview_content_bit(0x80000000u), so a valid typed slot-18 token is refused as "not a typed buffer view". That's safe, but the reason is wrong. Usetoken_viewafter the merge.channels = 4; // the 16 zero bytes …):grep -cE 'null|indirect' tests/startup_compute_typed_buffer_srv_check.py→ 0. The manifest guard (b.required_bytes <= 16 && % 4):grep -c typed_buffer_srv tests/native_compute_manifest_reasons.cpp→ 0. A records32 null-input mode and one manifest-reasons row would pin them. The indirect-refusal gap is already listed on #3397.NIT
4, 6, 6 and 7) are stale. The check at the head runs 5/8/8/9.range.offset % elementfails for about 2 in 3 slots. I reasoned this from the code and did not measure it.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T14:24:19Z.
@Leyukaka @JohnConnorNPC Thanks. Head is now
4cd38c90.Conflict.
d2acde2bmergesmainwith the resolution from 12:06: main'sidentity_dst_selwriter and parser branches are kept, and thetyped tablebranch follows each.mainthen moved again, so4cd38c90merges8a30428atoo: the cube SRV reason rows and thedispatch-cubeconsumer modes go next to this branch's rows and modes. Both merges are clean against8a30428a.JohnConnorNPC's points:
docs/experiments/compute-typed-buffer-inputs.mdnow say that this binding is on the manifest route only. WithX2W_NATIVE_SHADERS_ONLY=1(the default since #3449),<key>.txtis not read, andtranslate_compute_nativelystill refusestyped_buffer_srvasview kind 1 is not bound. Binding the kind on the in-process route is a separate change; it would reuse the sameSlot.typed_bytesand dispatch path.typed_dword_input_viewnow reads the token withtoken_view(a3854d64). No test runs withX2W_D3D12_VIEW_CONTENT_TOKENS=1, so that path is checked by reading only.dispatch-records32-input-null, gives each width an all-zero input descriptor, which must read zeros. With the all-zero branch dropped, the check fails atnull input: word 0 expected 00000000, read c5c5c5c5.native_compute_manifest_reasonshas two newSRV kind typed_buffer_srvrows, 20 bytes and 6 bytes.a typed input range does not start at a whole element, but it is refused by name, not misread. Removing that refusal would mean aligning snapshot reservations to the element size, which I left out of this PR.Leyukaka's gaps 2–4 from the #3397 review are in lines from this PR, so the cases are here:
0xfff80000u→0xff000000u, the check fails at the INDEX_STRIDE case.0x8000 | 4nmust be refused. With(words[1] >> 30)→((words[1] >> 30) & 1), the check fails at{'stride': 32772}.startup_slot67_indirect_dispatch_check.pyreplaces its manifest line withsrv 0 typed table 1 0 bytes 4and expectsrequires fixed-table raw buffers. With|| slot.typed_bytesdropped, that check fails.Each mutation was applied alone, the shim rebuilt and the check run, then reverted. Without mutations, on
4cd38c90(main8a30428a), these pass:startup_compute_typed_buffer_srv_controls/_hardware,native_compute_manifest_reasons(38 cases) andstartup_slot67_indirect_dispatch_hardware. The setup was the NVIDIA GeForce RTX 4090, driver 32.0.16.1088, Windows 11 build 26300, Debug, with the debug layer enabled.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T14:37:45Z.
Review: APPROVED
Reviewed
4cd38c90againstmain8a30428a. Diff reading only, nothing run.Since
da4fe59c:d2acde2b,4cd38c90):main'sidentity_dst_selwriter and parser branches are kept and thetyped tablebranch follows each (src/direct_compute_cache.cpp:969,src/startup_stubs/d3d12_compute_dispatch.inl:339). The cube rows anddispatch-cubemodes sit next to the typed ones.git merge-tree origin/main 4cd38c90exits 0.a3854d64): one change.typed_dword_input_viewreads the token withtoken_view(d3d12_compute_dispatch.inl:175) instead of indexingview_records()itself. For an id token this is the same lookup under the same lock. For a content token, words 4-7 are present because the caller reads the entry withread_buffer_words(:855).tests/startup_compute_typed_buffer_srv_check.py: all-zero descriptor reads zeros (:130), word 1 bit 31 (:141), INDEX_STRIDE (:142), ADD_TID (:143). TwoSRV kind typed_buffer_srvrows, 20 and 6 bytes (tests/native_compute_manifest_reasons.cpp:70,:74). Indirect refusal of ansrv typedline (tests/startup_slot67_indirect_dispatch_check.py:209).docs/experiments/compute-typed-buffer-inputs.md:35); control counts 8, 11, 11 and 12 (:65) match the script (8 base, 3 more for 2 or more components, 1 token case for 4).JohnConnorNPC's points 1 to 5 are addressed by the above. Point 6 (12-byte elements on the snapshot path) is unchanged: such an input is refused by name, not misread.
Not covered:
X2W_D3D12_VIEW_CONTENT_TOKENS=1) throughtoken_viewhas no case, as the body says.prtest preset still includes none ofstartup_compute_typed_buffer_srv_*,native_compute_manifest_reasonsorstartup_slot67_indirect_dispatch_*, so the green CI builds these checks without running them. The mutation results are the author's.Approve
4cd38c90.