shader: use published slot 57 pairs when native translation refuses #3531
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3531"
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 lambirou on 2026-11-30T01:50:38Z.
Problem
A fixed slot 57 request whose mesh shader uses the R1 group-index exchange shape (raw
0xbefe0481) is still refused by the native mesh frontend. The request publisher can produce a reviewed.ms57.cso/.ps57.csopair, but the loader previously reached it in a default native-only run, where it could replace the native refusal without an explicit choice.The runtime fixture also failed for a second reason: it published a request against one root blob but created the guest root from a separately serialized description, so the request key and CSO names did not match.
Change
X2W_ALLOW_PUBLISHED_MESH57_PAIR=1is required beforeprepare_native_mesh57opens<key>.ms57.txtor either CSO. Without it, the exact nativemesh57_group_indexexception is rethrown, including in the launchers' defaultX2W_NATIVE_SHADERS_ONLY=1mode; a pair on disk no longer changes a native-only run.mesh57_group_indexrefusal for a buffer-view (X2WM574) profile with no direct heap opens the published pair; every other refusal propagates.stage ms) and derives the buffer reads from itssrvlines in register order: root parameter, table byte offset and the accessedbytesspan. The draw refuses a view shorter than that span. A two-descriptor fixture proves the second table record binds its own buffer.x2w-startup-mesh-57-3to-4in the request publisher, the loader, the draw path, the translator and the fixtures. The published path requires manifest version 4 withstage ms, so a pair from an older translator revision cannot load.gfx2hlsl.py; it shifted both root constants by one and made the shader see a vertex count of 0.DispatchMeshand the native refusal. With the opt-in, the same bytes must load and match 1,024 pixels with one forwarded call. The test compares the pair bytes before and after, builds a fresh subprocess environment with inherited switches removed, and restores the pair after the missing/truncated cases.X2W_ALLOW_PUBLISHED_MESH57_PAIR=1, so they prove native wins and a non-R1 refusal stays a refusal with the fallback authorized.CMakePresets.jsonfilter has its indentation restored while keeping both sides' test families; the version 4 header/stage check now runs before theudlayout check; the version 1 manifest case pinsstderr_contains.Merged
origin/mainata3bfd019(merge6ee7d764).CMakePresets.jsonkeeps main'snative_*,native_direct_meshandstartup_triage_runentries plus this PR'sstartup_mesh57_*andnative_fixed_mesh57_published_pair*families.src/startup_stubs/native_mesh57.inlkeeps this PR's native-first/published-pair structure and re-inserts main'smesh_heap_tokensrefusal from #3619 insideprepare_native; neither side was taken wholesale.Validation
Debug
devbuild after mergingorigin/mainata3bfd019(merge6ee7d764):The build completed successfully.
ctest --preset pr -Nselects 253 tests and includesstartup_mesh57_runtime_warp,native_fixed_mesh57_published_pair_warpandnative_fixed_mesh57_published_pair_refusal_warp.Targeted Python checks:
All exited 0. The docs check reported 195 Markdown files and 757 links.
WARP:
startup_mesh57_runtime_warppassed. Its gate lines werepublished pair without opt-in: 1024 pixels matched, 0 forwarded mesh callsandpublished pair with opt-in: 1024 pixels matched, 1 forwarded mesh calls. The missing/truncated cases stayed cleared with no forwarded call, andcompiled pair restoreddrew again. The twopublished_paircontrols passed 2/2.Physical GPU (reported separately):
3/3 passed on AMD Radeon RX 9060 XT, driver 32.0.32029.2010, Windows build 26200, debug layer unavailable.
startup_mesh57_runtime_hardwarealso passed the two-table-entry case; that sub-case skips on WARP because the CI WARP build faults with exit code 2173 when the runtime writes the second descriptor's view token.ctest --preset dev --no-tests=error -R '^startup_mesh57_real_shape$' -Vpassed as well.Whole mesh57 family on this head:
58/58 passed in 302 s, including every
_hardwarevariant on the local RX 9060 XT. An initial-j4run madestartup_mesh57_skeleton_{draw_warp,draw_hardware,exchange_hardware}exceed the 70 s test timeout; each passed alone in 4-31 s, so that was CPU contention rather than a regression.CI at head
6ee7d764:Build and test on Windowspassed (8m49s),Run platform-independent Python checks on Linuxpassed (3m0s), andAssemble and translate gfx1013 fixturespassed (3m9s). The/O2, coverage-chart and other non-PR jobs were skipped by the workflow.Limits
The accessed span is a lower bound computed from the immediate offset and the load width; dynamic
vaddr/soffset/idxenaddresses remain bounded by the view at draw time. The fallback is deliberately narrow and now opt-in: buffer-view profile only, no direct heap, nouavline, and every manifest read must match a profile view entry. A truncated published pair fails pipeline creation rather than silently falling back.The D3D12 debug layer is unavailable on this host, so no debug-layer result is claimed. This does not establish full-game startup or frame rate.
Refs #2413
Refs #3094
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T07:17:18Z.
Review: COMMENTED
Reviewed
9791a2eaby reading the diff; not built or run.Verdict: comment. No MUST. The published-pair path works for the fixture shape, but it changes which pair wins for every buffer-view profile, and its buffer guards are weaker than the native ones.
src/startup_stubs/native_mesh57.inl:359the pair is used whenever both CSOs exist, andtranslate_mesh_programnever runs. So a buffer-view (X2WM574) profile that translates natively today switches to the gfx2hlsl pair once a translated cache sits beside it. That contradicts the title ("when native translation refuses"). Trying native first and reading the CSOs only in the refusal path keeps native the default.native_mesh57.inl:432the code pushes one read per view entry with offset 0 andminimum_bytes4. The native path uses the reflected register order, the table byte offset andrequired_bytes(:376-400). The draw-time check at:52therefore accepts a 4-byte view for a shader that reads 512 bytes, and a table entry past the first descriptor binds the wrong record. It also assumes that gfx2hlsl's SRV register order equals the profile's view-entry order. With one view entry the fixture cannot tell the difference.src/loaded.ms57.cso. Pairs published before thegfx2hlsl.py:12036fix still carry the shifted constants (the black target this PR describes), and the key revisionx2w-startup-mesh-57-3is unchanged. A stale pair from an older cache would load without any warning. Either bump the revision or check the.ms57.txtmanifest..mesh57-stateprofiles, so this path does not run there.Tests:
startup_mesh57_runtime_{warp,hardware}reaches the new branch (published pair → 1024 pixels; missing/truncated → cleared target, 0 forwarded). It also covers the gfx2hlsl change indirectly. It does not cover a native-translatable profile with CSOs present, or more than one view. Theprpreset filter does not includestartup_mesh57_*, so CI did not run these tests. The green Windows job proves only that the change builds.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-30T11:27:52Z.
Thanks — all three SHOULDs are addressed at
93523de6, rebased onc7cbdf96.prepare_native_mesh57now runstranslate_mesh_programfirst. Only the exactmesh group-index exchange shape or entry state is not coveredrefusal, on anX2WM574buffer-view profile without a direct heap, opens the published pair. Any other refusal propagates, and a non-buffer profile is refused.native_fixed_mesh57_published_pair_*proves native still wins when CSOs are present;..._published_pair_refusal_*proves a non-R1 refusal is not masked.tools/startup/gfx2hlsl.pynow publishes manifest version 4 (x2w-manifest 4,stage ms) withbytes <span>on every buffersrvline, computed from the mesh loads. The runtime parses thesrvlines in register order and validates the index, kind, root parameter, table byte offset and span against the profile's view entries;bind_mesh57_buffersrefuses a view shorter thanminimum_bytes. A two-descriptor fixture proves the second table record binds its own buffer without aliasing the first.x2w-startup-mesh-57-3is nowx2w-startup-mesh-57-4insrc/shader_compute_request.cpp,src/startup_stubs/native_mesh57.inl,src/startup_stubs/d3d12_draw.inl,tools/startup/gfx2hlsl.py, the fixtures and the docs. The published path also requires manifest version 4 withstage ms, so a pair from an older translator revision is refused.Local validation:
startup_mesh57_*andnative_fixed_mesh57_*pass 8/8 on WARP and 7/7 on the RX 9060 XT (driver 32.0.32029.2010), plus the Python mesh, rekey, manifest and docs checks. The only check not validated locally is thellvm-mcencoding comparison (the local ROCmllvm-mcdiffers from LLVM 15); the CI gfx1013 job is the authority for that. CI is running on this head.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T12:33:01Z.
Review: CHANGES_REQUESTED
Reviewed
fd8c7874by reading the diff; not built or run.Verdict: changes requested. Native-first, manifest-derived reads and the revision tie are in place. One gap remains: the published pair's root-constant layout is never checked against the profile.
ud/udsrclines.read_published_mesh57_manifest(src/startup_stubs/native_mesh57.inl:300-341) reads only the header,stage,srvanduav, so it skips the constant layout. The published HLSL readscbuffer entry : register(b0)asud0..udN.setup_entry(tools/startup/gfx2hlsl.py:2605-2611) gives a ud to every constant word of every root-constant parameter, in root order. Later ones, such as('stride', …)or('descword3', …)(:7330,:7991), follow after those. The draw fills b0 with the words ofmapping.root_parameteronly (d3d12_xs_device.cpp:4441-4448). So a root with an earlier constant parameter, or a shader that needs a stride or descriptor-word ud, gets the wrong values or zeros in b0, and the PSO still creates. That is the same silent shift as therectbug this PR fixes. The native path refuses this case throughmapped_constants(native_mesh57.inl:514). Requiringud nwithn <= mapping.count, andudsrc i rootconst <mapping.root_parameter> ifor everyi, would close it. A fixture whose root has two constant parameters would prove the refusal.is_mesh57_group_index_refusalmatches the message text. It is exact today (raised only atgfx1013_direct_mesh.inl:1239, raw0xbefe0481), but a reworded refusal would silently turn the fallback off. A refusal code would be sturdier.native_mesh57.inl:43-48).Tests:
startup_mesh57_runtime_warp(pair, missing/truncated CSOs, short view, version 1 manifest, no pair) andnative_fixed_mesh57_published_pair(_refusal)_warpran and passed in CI. The two-descriptor case skips on WARP, so only the author's hardware run covers it.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-30T12:43:54Z.
Both points are addressed at
d4b671fa.MUST — constant layout.
read_published_mesh57_manifestnow parsesud/udsrcand requiresud nwithn <= mapping.count, plusudsrc i rootconst <mapping.root_parameter> ifor everyi. A line sourced from another root parameter, or audsrcfor astride/descword3ud, refuses the pair withpublished MS57 manifest constant layout differs from the profile. The new runtime sub-case rewrites the firstudsrcto a different root parameter and asserts the cleared target, zero forwarded calls and that message; it passes on WARP and on the RX 9060 XT.NIT — refusal code.
UnsupportedComputeShadernow carries acode; the R1 refusal is thrown withmesh57_group_indexandis_mesh57_group_index_refusalchecks that code instead of the message text, so a reworded refusal cannot disable the fallback.Re-run:
startup_mesh57_runtime_warpand_hardware(the new foreign-constant case included),startup_mesh57_skeleton_draw/_exchange,native_fixed_mesh57_buffers,startup_logical_view_table,native_fixed_mesh57_constantand thepublished_pair/published_pair_refusalcontrols pass on both adapters. CI is running on this head.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T12:54:51Z.
Review: APPROVED
Reviewed
d4b671faby reading the diff; not built or run.Verdict: approve. The published pair is now refused unless the manifest's entry constants are exactly the profile's constant words, in order. That closes the constant-layout gap. No MUST.
read_published_mesh57_manifest, theudcheck (src/startup_stubs/native_mesh57.inl:363) now runs before the header/stage check (:367). A version-1 manifest, such as the test'sx2w-manifest 1\nstage ms, is still refused, but it logs "constant layout differs" instead of "not a version 4 mesh manifest". Swap the two blocks, and let the "old revision manifest" case passstderr_contains(tests/startup_mesh57_runtime_check.py:123) so the reason is pinned.ud Nandudsrc i <source…>(tools/startup/gfx2hlsl.py:12829-12831). Astride/descword3source fails therootconst %u %uparse and refuses the pair.word == indexandcount <= mapping.countmatches how the draw fills b0: words 0..count-1 ofmapping.root_parameter, with no offset (native_mesh57.inl:680). The missing-index check also refuses a pair whoseudsrclines are duplicated or missing.UnsupportedComputeShader::codepoints to a string literal, so it outlives every copy of the exception. Exceptions without a code keepnullptrand re-throw as before.Tests: the new "foreign constant" case reaches the
udsrcrefusal through the real publisher output. It checks the cleared target, 0 forwarded calls and the message. It does not cover audcount larger than the profile's. CI ranstartup_mesh57_runtime_warpandnative_fixed_mesh57_published_pair(_refusal)_warpat this head (theprfilter includes them), and they passed. The two-descriptor case still skips on WARP.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T18:08:39Z.
Review: APPROVED
Reviewed
2426afceby reading the diff; not built or run.Verdict: approve. The rebase onto
bee9c64dchanged the PR's own diff in one place only, theprtest filter conflict inCMakePresets.json. Everything else is byte-identical tod4b671fa, which we approved. No MUST."name"line inCMakePresets.jsonlost its indentation and now starts at column 0. The regex itself is right: it keepsmain'sstartup_indirect_mesh_cache_heap(_wide)?_warpandruntime_mesh86_cache_cli_checkand adds this PR's two families.udcheck runs before the header/stage check (src/startup_stubs/native_mesh57.inl:363vs:367). A version-1 manifest therefore logs "constant layout differs".d3d12_draw.inl(#3593, #3597, #3627),gfx2hlsl.pyandgfx1013_compute_native.cpp. Nox2w-startup-mesh-57-3string is left anywhere in the tree. The new slot 86 window code does not use the slot 57 key..m57request files but no.ms57.csopairs (there are none). So no published translation is lost there, and the requests are rewritten under the new keys.Tests: CI ran
startup_mesh57_runtime_warp(2.73 s),native_fixed_mesh57_published_pair_warpandnative_fixed_mesh57_published_pair_refusal_warpat this head: 93/93 passed. The two-descriptor case still skips on WARP, so only the author's RX 9060 XT run covers it.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-30T19:31:11Z.
Review: CHANGES_REQUESTED
The fallback can load a published pair in the default native-only run. In
prepare_native_mesh57, theis_mesh57_group_index_refusal(error)catch takes the published manifest/CSO path without consultingX2W_NATIVE_SHADERS_ONLY. The runtime fixture also publishes its pair viagfx2hlsl.py. Please preserve the native refusal in the default C++-only mode for pairs without verified native provenance. If the legacy pair is supported, gate it behind explicit opt-in and add a control proving the same on-disk pair is refused in native-only mode and can draw when opted in.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-30T20:24:29Z.
Thanks for the catch. Addressed at
4034d32a.prepare_native_mesh57now checksX2W_ALLOW_PUBLISHED_MESH57_PAIRbefore entering the published-manifest/CSO path. Without it, the originalx2w::UnsupportedComputeShaderis rethrown withthrow;, preserving the exact message and code, including withX2W_NATIVE_SHADERS_ONLY=1. With the opt-in, native translation still runs first and only themesh57_group_indexrefusal may fall back.gfx2hlsl.pyand runs that same on-disk pair twice in native-only mode. Without the opt-in it requires a cleared target,0 forwardedmesh calls and the nativemesh group-index exchange shape or entry state is not coveredrefusal. With the opt-in it requires 1,024 matching pixels anddispatchmesh 1. The test compares the pair bytes before and after, clearsX2W_ALLOW_PUBLISHED_MESH57_PAIRin the default subprocess, setsX2W_NATIVE_SHADERS_ONLY=1explicitly, and restores the CSOs after the missing/truncated cases.native_fixed_mesh57_published_pair{,_refusal}_{warp,hardware}now set the opt-in too, so they prove native priority and a non-R1 refusal with the fallback authorized rather than merely relying on the default gate.CMakePresets.jsonfilter keeps both sides' test families with its indentation restored; the version 4 header/stage check now precedes theudlayout check; the version 1 manifest case pinsstderr_contains.Validation at
4034d32aafter mergingorigin/mainatd5970858:cmake --preset devandcmake --build --preset dev: success.ctest --preset dev --no-tests=error -R '^startup_mesh57_runtime_warp$' -V: passed. Gate lines:published pair without opt-in: 1024 pixels matched, 0 forwarded mesh calls;published pair with opt-in: 1024 pixels matched, 1 forwarded mesh calls. Missing/truncated stages stayed cleared andcompiled pair restoreddrew again.ctest --preset dev --no-tests=error -R '^native_fixed_mesh57_published_pair(_refusal)?_warp$' -V: 2/2 passed.ctest --preset dev --no-tests=error -R '^(startup_mesh57_runtime_hardware|native_fixed_mesh57_published_pair(_refusal)?_hardware)$' -V: 3/3 passed on AMD Radeon RX 9060 XT, driver 32.0.32029.2010, Windows build 26200, debug layer unavailable. The two-table-entry case passed here and still skips on WARP for the existing descriptor-write fault.tests/docs_links_check.py(192 Markdown files, 747 links), andstartup_mesh57_real_shapepassed.The published pair remains legacy input and is unavailable by default.
gh pr checks 3531reached a terminal state at this head.CI terminal state at
4034d32a:Build and test on Windowspass (4m21s),Run platform-independent Python checks on Linuxpass (3m29s),Assemble and translate gfx1013 fixturespass (3m56s). The/O2, coverage-chart and other non-PR jobs were skipped by the workflow.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-01T00:04:12Z.
Review: APPROVED
Re-read at
4034d32a, diff only. The published pair is now used only withX2W_ALLOW_PUBLISHED_MESH57_PAIR=1: without it, themesh57_group_indexrefusal is rethrown before the manifest or a CSO is opened (src/startup_stubs/native_mesh57.inl:633-634). The version 4 header and stage check now runs before theudlayout check (:370-377).Question on the key revision
x2w-startup-mesh-57-3->-4(src/shader_compute_request.cpp:203,src/startup_stubs/d3d12_draw.inl:536,src/startup_stubs/native_mesh57.inl:433,tools/startup/gfx2hlsl.py:13554): it changes every slot 57 request key, and the.mesh57-statevariant derived from it (native_mesh57.inl:434-437). Every existing slot 57 request, translation and captured state profile is therefore asked for again, including in the default run that never loads a pair. The pair is now opt-in, and only a version 4 manifest is accepted, which only this PR's translator writes (tools/startup/gfx2hlsl.py:13039). Is the bump still needed? If it is, does the rekey mode carry-3slot 57 entries over?Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T00:20:07Z.
Review: COMMENTED
The new opt-in addresses the default-path concern in my earlier review. I checked that an unset
X2W_ALLOW_PUBLISHED_MESH57_PAIRrethrows the original native group-index refusal, and that the fixture runs the same published pair with the switch both unset and set.#3619 has now landed and overlaps
src/startup_stubs/native_mesh57.inl. Please sync withmainand retain its explicit refusal for native heap-token reads until the runtime binds the token views andb1. Then rerun^startup_mesh57_runtime_(warp|hardware)$so the default native refusal, explicit published fallback, and native-priority controls are covered on the combined code.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-01T00:58:55Z.
Synced with
mainata3bfd019in merge6ee7d764.CMakePresets.jsonkeeps main'snative_*,native_direct_meshandstartup_triage_runentries plus this PR'sstartup_mesh57_*andnative_fixed_mesh57_published_pair*families.src/startup_stubs/native_mesh57.inlkeeps this PR's native-first/published-pair structure and re-inserts main'smesh_heap_tokensrefusal from #3619 insideprepare_native; neither side was taken wholesale.Validation on the merge head: the full mesh57 family passed 58/58 in 302 s, including every
_hardwarevariant on the local RX 9060 XT.ctest --preset pr -Nnow selects 253 tests and includes all four mesh57 controls.docs_linkschecked 195 Markdown files and 757 links;native_direct_mesh,native_compile_dxil_{refusals,rekey}and the gfx2hlsl checks passed. CI is green at6ee7d764: Windows 8m49s, Linux Python 3m0s, gfx1013 fixtures 3m9s.On the key revision question: rekey mode recomputes
mesh57_keyfor each.m57request, so existing-3entries are carried over under the-4key rather than orphaned. The bump still separates old request/state names from the v4-only manifest path.The
-j4run hit three skeleton timeouts at 70 s under CPU contention; each of those tests passed alone in 4-31 s, and the serial family run is clean.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T01:14:37Z.
Review: APPROVED
Follow-up to my earlier change request. The current head retains the native heap-token refusal from #3619. An unset
X2W_ALLOW_PUBLISHED_MESH57_PAIRrethrows the original native group-index refusal. With the explicit opt-in, the published pair can be used after that refusal.ctest --test-dir <build> --no-tests=error -j1 -R '^startup_mesh57_runtime_(warp|hardware)$' --output-on-failurepassed on WARP and RTX 4060 Laptop. For the same on-disk pair, both backends matched 1,024 pixels with zero forwarded calls by default and one forwarded call with the opt-in. The native-first and corrupt-pair controls passed.