Repository navigation
shader: use published slot 57 pairs when native translation refuses - #3531
Conversation
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed 9791a2ea by 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.
- SHOULD make the published pair a fallback. At
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. - SHOULD derive the reads instead of using placeholders. At
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. - SHOULD tie the CSOs to the translator. Until now nothing in
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. - Not related to issue #3560: our title caches have no
.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. The pr preset filter does not include startup_mesh57_*, so CI did not run these tests. The green Windows job proves only that the change builds.
04e1efc to
93523de
Compare
|
Thanks — all three SHOULDs are addressed at
Local validation: |
e0a1b74 to
fd8c787
Compare
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed fd8c7874 by 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.
- MUST check the manifest's
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. - NIT
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. - Checked, no finding: a native throw leaves nothing half-filled. Sampler, heap and PS-binding mismatches fail at PSO creation. A table slot that is not an SRV/CBV is refused at draw (
native_mesh57.inl:43-48).
Tests: startup_mesh57_runtime_warp (pair, missing/truncated CSOs, short view, version 1 manifest, no pair) and native_fixed_mesh57_published_pair(_refusal)_warp ran and passed in CI. The two-descriptor case skips on WARP, so only the author's hardware run covers it.
fd8c787 to
d4b671f
Compare
|
Both points are addressed at MUST — constant layout. NIT — refusal code. Re-run: |
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed d4b671fa by 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.
- NIT In
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. - Checked, no finding:
- The publisher always writes
ud Nandudsrc i <source…>(tools/startup/gfx2hlsl.py:12829-12831). Astride/descword3source fails therootconst %u %uparse and refuses the pair. - Requiring
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.
- The publisher always writes
Tests: the new "foreign constant" case reaches the udsrc refusal through the real publisher output. It checks the cleared target, 0 forwarded calls and the message. It does not cover a ud count larger than the profile's. CI ran startup_mesh57_runtime_warp and native_fixed_mesh57_published_pair(_refusal)_warp at this head (the pr filter includes them), and they passed. The two-descriptor case still skips on WARP.
The fixed slot 57 frontend does not cover every group-index exchange shape (raw 0xbefe0481). When the publisher has already written the reviewed .ms57.cso/.ps57.cso pair for a buffer-view profile, build the mesh pipeline from that pair and keep the profile's root and view mappings instead of dropping the request. The fixture now creates the guest root from the exact root blob the request publisher compiled against, so the profile key, request key and CSO names agree. gfx2hlsl no longer inserts the rectangle-list selector into mesh pipelines, which had shifted both root constants by one word and produced a black target. Tests: startup_mesh57_runtime warp/hardware, startup_mesh57_skeleton_draw and startup_mesh57_skeleton_exchange warp/hardware, native_fixed_mesh57_buffers and native_fixed_mesh57_constant warp/hardware.
d4b671f to
2426afc
Compare
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed 2426afce by reading the diff; not built or run.
Verdict: approve. The rebase onto bee9c64d changed the PR's own diff in one place only, the pr test filter conflict in CMakePresets.json. Everything else is byte-identical to d4b671fa, which we approved. No MUST.
- NIT The resolved
"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. - NIT (still open from our last review) the
udcheck runs before the header/stage check (src/startup_stubs/native_mesh57.inl:363vs:367). A version-1 manifest therefore logs "constant layout differs". - Checked, no finding:
- Main changed several of this PR's files in the rebase window, notably
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. - The revision bump turns every slot 57 key into a miss. In our revision 29 caches, that orphans 622 and 996
.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.
- Main changed several of this PR's files in the rebase window, notably
Tests: CI ran startup_mesh57_runtime_warp (2.73 s), native_fixed_mesh57_published_pair_warp and native_fixed_mesh57_published_pair_refusal_warp at this head: 93/93 passed. The two-descriptor case still skips on WARP, so only the author's RX 9060 XT run covers it.
R0Y00
left a comment
There was a problem hiding this comment.
The fallback can load a published pair in the default native-only run. In prepare_native_mesh57, the is_mesh57_group_index_refusal(error) catch takes the published manifest/CSO path without consulting X2W_NATIVE_SHADERS_ONLY. The runtime fixture also publishes its pair via gfx2hlsl.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.
# Conflicts: # CMakePresets.json
Keep the exact native mesh57 refusal when no explicit opt-in is set, including in the default native-only run. X2W_ALLOW_PUBLISHED_MESH57_PAIR=1 permits only the mesh57_group_index fallback after native translation has been attempted. The runtime control runs the same on-disk pair without and with the opt-in, and the native-priority controls now run with the fallback permitted. The version 1 manifest case pins the header/stage refusal reason.
|
Thanks for the catch. Addressed at
Validation at
The published pair remains legacy input and is unavailable by default. CI terminal state at |
Leyukaka
left a comment
There was a problem hiding this comment.
Re-read at 4034d32a, diff only. The published pair is now used only with X2W_ALLOW_PUBLISHED_MESH57_PAIR=1: without it, the mesh57_group_index refusal 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 the ud layout 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-state variant 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 -3 slot 57 entries over?
R0Y00
left a comment
There was a problem hiding this comment.
The new opt-in addresses the default-path concern in my earlier review. I checked that an unset X2W_ALLOW_PUBLISHED_MESH57_PAIR rethrows 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 with main and retain its explicit refusal for native heap-token reads until the runtime binds the token views and b1. 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.
|
Synced with Validation on the merge head: the full mesh57 family passed 58/58 in 302 s, including every On the key revision question: rekey mode recomputes The |
R0Y00
left a comment
There was a problem hiding this comment.
Follow-up to my earlier change request. The current head retains the native heap-token refusal from #3619. An unset X2W_ALLOW_PUBLISHED_MESH57_PAIR rethrows 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-failure passed 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.
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.