startup: bind pixel-stage UAVs from the title's descriptor table #2440
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2448"
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 roansystemlabs on 2026-11-25T17:01:11Z.
Refs #1996 (item F). Follow-up of #2155; also the "Pixel-stage UAV binding" line of #2274.
Change
The runtime now binds the image a translated pixel program stores to. Before this,
load_translationdropped every translation with auavline: first with "pixel-stage UAVs are not bound yet", and since #2059 by refusing everyx2w-manifest 2manifest and everyuavline.load_translationreadsuav N tex2d table P O, the linetools/startup/gfx2hlsl.pywrites for a pixel-stageimage_store. Only that form is read: a view qualifier (float,uint,sint) or achannelsfield, as in the compute line on main (uav N tex2d float table P O channels 4), is refused.uavline is either bound or refused by name, so the vertex-stage buffer line (uav N raw table P O) still keeps its translation from being used and no store is skipped silently. Other manifest versions stay refused. The offline vertex-store note indocs/experiments.mdnow says this instead of "refuses version 2 manifests".u0..after the SRVs in its view table (create_translated_rootandsampler_root_parameterintranslated_sampler_bindings.h, both already on main, take the view count).UNORDERED_ACCESSfor the draw.d3d12_draw.inl(read_pixel_uav_line,pixel_uav_view,resolve_pixel_uavs); no new shared header.Passkeeps the last accepted render and depth targets (bound_targets,bound_depth) so the draw can compare them; the existingtrace_targetsare filled only while the red-producer diagnostic is on.Refused by name, with nothing bound in place of the view:
uav N raw table P O, the vertex-stage store of #2059, or the olderuav N table P O), a view qualifier, another source, an extra field such aschannels, a view index out of order, more than eight views;ALLOW_UNORDERED_ACCESS, an array, 3D, 1D or multisampled resource, a view of another dimension, mip or plane, an integer, sRGB or non-colour format, a format without typed UAV store on the device, and a texture that is also an SRV, a render target or the depth texture of the same draw. These checks run before any view of the draw is written or any texture changes state.uavline, counted in the #2333 census asunsupported_resource_or_entry.Out of scope: compute UAVs (#2274 B) and barriers between draws that write and read the same texture.
Verification
Commit
1247a2895onfbe249f68(rebased; the previous head wase1d5a997bonb442b57fb).git merge-treewith today's main (f02ebd669) is clean. Windows 11 (10.0.26200), MSVC 14.44, NVIDIA GeForce RTX 3070 driver 32.0.16.2101, and WARP 10.0.26100.9818, debug layer on.startup_pixel_uav_warpandstartup_pixel_uav_hardwarepassed (2/2) in each of two runs on1247a2895: 21 cases and the exec guard control on each adapter, debug layer on with 0 errors in every case (42 of 42 per run);a.buffer-lineis refused by name on both adapters. The previous heade1d5a997bpassed the same way, and @Makto94 ran it on an RTX 3070 Ti.1247a2895,ctest --preset dev --no-tests=error -R "^startup_(stream_|draw|pixel_|indirect|sampler|image_|formatted|clear_uav|list_uav|gfx2hlsl_buffer_store|d16_srv|frame_copy|mrt|joined|root_|view_|memory_srv|mubuf)": 214 tests, 0 failed, 1 skipped with its existing capability reason (startup_view_heap_warp), 623 s. This includesstartup_joined_table_pointer_*(#2507, whoseX2W_TEST_JOINED_TABLEflag met ours instartup_stream_consumer.cpp), formatted buffers and views, indirect draws, ClearUAV, UAV barriers andstartup_gfx2hlsl_buffer_store(#2059).^startup_suite on the first rebase of this change (294178042, on8ecaa8ec9, same code): 897 tests, 0 failed, 9 skipped with their existing capability reasons, 2057 s. It was not repeated on1247a2895, whose base adds 16 commits; those that touch the same files (#2002 vertex fetch without elements, #1974/#1975 compute slots, #2648 slot 76) do not touch the translated root signature, the view table or the UAV binding, and the subset above covers the draw path.What the 21 cases check (
tests/startup_pixel_uav_check.py, each case its own process):ALLOW_UNORDERED_ACCESS, aR32G32B32A32_UINTview, a view of mip 1, a one-slice 2D-array view, an entry outside the bound table, no table, the texture also bound as an SRV, the texture also bound as the draw's render target (a fifth texture with both flags, bound through list slot 50), and seven other manifest lines (including the compute form withfloatandchannels 4).v_cmpxvariants from #2155 through the runtime. Exec on writes the texel; exec off leaves it.Negative controls:
texel_mismatch texture A mip 0 texel (1, 2) word 0: got 3f800000, expected c0000024on both adapters.ALLOW_UNORDERED_ACCESScheck removed:no-uafails, the debug layer reports IDs 340 and 524 and the device is removed (0x887a0001);targetfails, the debug layer reports ID 538 (the render target is inUNORDERED_ACCESSat the draw).b442b57fbadded the manifest-version andrawline handling described above (covered by thea.buffer-linecase), and the rebase ontofbe249f68changed only conflict context (docs wording from the compute image store, and the environment-variable list instartup_stream_consumer.cpp).target), and the log showsstores to an image (uav 0 tex2d table 0 0); pixel-stage UAVs are not bound yet, translation not used.X2W_PIXEL_UAV_NO_DEBUG=1, as on a machine without it) the cases still run and reportdebug layer: absent; the zero-error requirement applies only when the layer is on.Evidence and follow-up
tests/startup_pixel_image_store_check.py, no bytes from any retail software). I assembled its source and the twov_cmpxvariants with clang 15.0.7 (--target=amdgcn-amd-amdhsa -mcpu=gfx1013) and extracted.textwith llvm-objcopy 15: all three match the recorded words (64, 68 and 68 bytes). That is the reassembly #2155 could not run; it is not part of the CI test.tests/startup_pixel_uav.cpp(astartup_stream_consumermode) creates the textures through device slot 127, the views through slots 18, 19 and 20 and the table through list slot 36, so the draw goes through the same path as a title.uavline. On mainop_image_storeaccepts only pixel and compute stages, and compute writes its own manifest (stage cs,uav N tex2d float … channels 4, not read byload_translation), so in a graphics manifest only the pixel stage writes atex2dline; a vertex-stage store is always arawline (op_buffer_store_vs), which is refused here. The view table is visible to all stages, so the binding does not depend on the stage either. If a later change lets another graphics stage store to an image, the manifest should carry the stage.retire_hold-ed like a sampled one, becauseretire_classifyalready keeps every resource withALLOW_UNORDERED_ACCESS(which this binding requires) out of the retire class.tex2dline and refuses itsuav N raw table P Oline by name, so those stores still never run; thea.buffer-linecase checks that refusal on both adapters. The draft #2603 binds the same pixeluavline ind3d12_draw.inlin another layout; the overlap is described in a comment on this PR.ALLOW_UNORDERED_ACCESSdecides how often this binds), indirect draws with auavline (refused, no fixture), resources the runtime creates by title address (refused by name, no fixture), and a UAV of the bound depth texture (refused by name with the render-target check, no fixture).Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:25:47Z.
Review: COMMENTED
Review of head
e1d5a997(Linux-side read, no Windows run by me).What I checked
x2w-manifest 2is accepted and everyuavline is either bound (uav N tex2d table P O) or refused by name at load time. Raw/buffer views, qualifiers, extra fields, out-of-order index and more than 8 views all keep the old "translation not used" behavior.resolve_pixel_uavs): all refusals happen before any view or state change is recorded. Slot 19 (UAV) is required, mip/plane/array/MSAA/format/typed-store support are checked, and a texture that is also a render target, depth target or SRV of the same draw is refused. Indirect draws with UAVs are refused.sampler_root_parameter(views)and the draw-time descriptor math usesrvs + uavsconsistently. Existing callers ofcreate_translated_rootkeep the defaultuavs = 0, so their layout is unchanged.bound_targets/bound_depthare copied from the same local array the existing trace code copies (8 entries), so no new out-of-range read.tests/startup_pixel_uav_check.py+tests/startup_pixel_uav.cppdraw through the real runtime on D3D12 and read back every word of four textures (both mips), so it guards the stored texel, the untouched words, each named refusal, and the exec on/off cases with a control. It is wired into CTest per backend and added to the existingstartup_stream_consumerbinary rather than a new one.Commands run (Linux, in a review worktree at the head SHA)
git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: passed (19 files, 465 links)python3 tests/bidi_controls_check.py: passed (1727 files)Not verified by me
No blocking findings.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-25T19:41:50Z.
Hardware run and Windows 11 MSVC build at head
e1d5a997.Environment: Windows 11 Pro build 26300.9974, Debug (
devpreset), MSVC toolset 14.44.35207 (cl 19.44.35230.0), driver 32.0.16.2101. The hardware test printsadapter=NVIDIA GeForce RTX 3070 Ti driver=32.0.16.2101withdebug layer: on, errors: 0in every case. The runs were serial (-j1). The PR body reports an RTX 3070 run on the same driver version; this run used an RTX 3070 Ti.Build:
cmake --build --preset devexited 0 (this PR changes C++ insrc/startup_stubs/andtests/, so the build was rerun at this head).Tests:
ctest --preset dev --no-tests=error -j1 -R '^startup_pixel_uav_' -E hardware -V: 1/1 passed (startup_pixel_uav_warp).ctest --preset dev --no-tests=error -j1 -R '^startup_pixel_uav_' -Nlists one hardware test,startup_pixel_uav_hardware.ctest --preset dev --no-tests=error -j1 -R '^(startup_pixel_uav_hardware)$' -V: 1/1 passed. 0 capability skips (77).The hardware test prints
hardware: 21 cases and the exec guard control:texel (1, 2)written and every other word unchanged:a(texture A) andb(texture B).a.exec-onis drawn with the texel written;a.exec-offis drawn with every word unchanged.missing,srv,no-ua,uint,mip1,array,out-of-range,no-table,srv-and-uav,target, and the manifest linesa.float-line,a.compute-line,a.tex2da-line,a.buffer-line,a.uint-line,a.channels-field,a.second-view.control exec guard removed: fails as expected (texel_mismatch texture A mip 0 texel (1, 2) word 0: got 3f800000, expected c0000024).The WARP run (
adapter=Microsoft Basic Render Driver, driver 10.0.26100.9818) prints the same 21 cases with the same outcomes and reasons, the same control failure, anddebug layer: on, errors: 0in every case. The descriptor stride printed is 32 on the RTX and 64 on WARP, as the PR body describes.On the PR so far: the review of
e1d5a997says "The new test needs Windows/WARP, so I could not run it or mutate the runtime code here", and the PR body lists "Release preset: not run". I found no NVIDIA run from anyone other than the author on this head.Not covered by this run: NVIDIA only (RTX 3070 Ti); no AMD or Intel GPU; no Release build; the wider
ctest -R '^startup_'suite was not run; the four runtime mutants in the PR body (swapped table entry,ALLOW_UNORDERED_ACCESScheck removed, mip 1 instead of mip 0, render/depth target check removed) were not rerun here; the fail-first run onmainwas not repeated.Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-26T02:07:54Z.
@denn0x, a heads-up on overlap with your draft #2603, checked by diffing both heads (#2448
1247a289, rebased onfbe249f6; #26038634f27b); no runtime comparison yet.Both PRs bind pixel-stage
uav N tex2d table P Oviews ind3d12_draw.inl, so they meet in the same places:load_translation: both drop theunsupported uav linerefusal and addTranslation::uavs;draw_translated: #2448 puts the UAVs after the SRVs in table 1, #2603 gives them their own root parameter (uav_parameter);git merge-treeof the two heads reports conflicts ind3d12_draw.inlandtests/startup_stream_draw.cppthat come from #2448 (the other conflicts, ind3d12_xs_device.cppandgfx2hlsl.py, are between #2603 and today'smainalone).One thing that may matter for #2603 itself: at
8634f27b,load_translationstill refuses any manifest other thanx2w-manifest 1, while itsgfx2hlsl.pywritesx2w-manifest 2for every pixel program with a stored image.startup_draw_uav_check.py(modetex) appends theuavline to a version-1 manifest, so it passes, but a translator-written pixel store would be refused beforebind_uav_texture. #2448 accepts version 2 for this reason, and still refuses the vertex-stagerawline of #2059 by name.#2448 is small (10 files), has a hardware run from @Makto94 on the previous head
e1d5a997, and its tests were re-run on WARP and an RTX 3070 after the rebase. Either way works for us:main) and #2603 rebases on top, keeping whichever table layout you prefer;x2w-manifest 2acceptance and the refusal cases instartup_pixel_uav_check.pyare the parts worth keeping, and I'll close #2448.No rush, just say which you prefer.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:34:15Z.
Update for the conflict with main (head
a9f01aa5).What I added:
origin/maininto the branch (no rebase). One conflict insrc/startup_stubs/translated_sampler_bindings.h: main already has theuavsparameter and the UAV range increate_translated_root. I kept main's range code and the PR'ssampler_root_parameter(views)change.startup_pixel_uav_{warp,hardware}failed in theno-uacase. Since #2649 the device records no view for a UAV over a resource without ALLOW_UNORDERED_ACCESS, so the draw is still refused with every word unchanged, but now with the reasontable entry holds no view. I updated that one expected reason intests/startup_pixel_uav_check.py.Commands executed:
python3 tests/startup_pixel_uav_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --checkon Linux: ok.startup_stream_consumerand the sampler checks, then ctest^startup_(pixel_uav|translated_sampler_bindings|sampler_comparison|frame_copy|d16_srv|mubuf_descriptor|address_volume_srv): 13/13 passed in dev and 13/13 in release (incl.startup_pixel_uav_warpand_hardwareon WARP).AI-assisted; commands listed were executed locally.