tooling: build slot 57 mesh profiles from runtime captures #3497
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3497"
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 Leyukaka on 2026-11-29T18:01:53Z.
Refs #3416
Why
The native slot 57 path only builds a PSO from a reviewed
<variant>.mesh57-stateprofile, and so far only the test fixtures wrote such profiles.X2W_MESH57_CAPTURE_STATE=1already writes capture sets (134 in one long local run of the application). This tool turns one capture set plus reviewed desktop state into a profile.What changes
tools/startup/mesh57_profile.py(new): reads a capture archive (.s57) with its three request companions (.m57,.ps57,.root) and a JSON record of the reviewed desktop and entry state, then writes<variant>.mesh57-state.tools/startup/mesh57_pixel_entry.py: capture validation moved into a sharedread_creation. Behaviour is unchanged except for error texts and check order (the length check now runs before the key check). No test or caller matches the old strings.tests/native_direct_mesh_check.py:check_profile_writeradds a version 2 byte round-trip and refusal controls.docs/experiments/native-fixed-mesh57.md: invocation.Keep the three request companions beside the archive.
check_profile_writershows a complete version 2 record.Behaviour
Mesh57Profile(src/startup_stubs/mesh57_profile.h) byte for byte: magic 0, lengths 8, mesh 32, blend 56, rasterizer 384, depth-stencil 428, render target formats 480, depth format 516, sample desc 520, sample mask 528. The tool asserts 532.native_mesh57.inl: pixel entry (v2+), constant (v3+), view list (v4+),heap_sgpr(v5+), then the six spans (descriptor, two state blocks, root, MS, PS), with no trailing bytes.native_mesh57.inl: v1/v2 refuse heap flags or root parameters, v3+ need a heap flag, v5+ need the view heap flag.Verification
On
1014e85f(base1b8e2fee),X2W_WITH_OPUS=OFF:1/1 passed. Only
compile_dxilhas to be built;llvm-mcis not needed.Mutations, each reverted afterwards:
9IB3x->9I3xB(write_maskmoved 3 bytes)Not covered
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T23:05:36Z.
Review: APPROVED
Reviewed at head
1014e85f37416174e6523c2dffef2658c33f81a1(base1b8e2fee). I read the diff statically and ran the PR's tests in an isolated, network-disabled Windows Sandbox. Approve. There are no blocking findings. The two SHOULDs are about how much the byte round-trip actually proves, and a mutation confirmed the first one.What I checked against the runtime
Mesh57Profile(src/startup_stubs/mesh57_profile.h) field by field:D3D12_BLEND_DESCat 56 (9IB3xper target, 40 bytes),D3D12_RASTERIZER_DESCat 384 (44 bytes),D3D12_DEPTH_STENCIL_DESCat 428 (4I2B2xplus two faces in fail/depth-fail/pass/func order, 52 bytes),D3D12_RT_FORMAT_ARRAYat 480, depth format 516, sample desc 520, sample mask 528, total 532.X2WM57<n>is NUL-padded to 8 bytes, which is what thememcmpinnative_mesh57.inl:266-275expects.native_mesh57.inl:271-299. The0xc00mask equalsroot_flags_heap_indexed(src/startup_stubs/heap_indexed_root.h:17-19), and v5+ requires 0x400. The runtime reads no extra fields for v6, and the tool treats v6 like v5.native_mesh57.inl:320-325.read_creationrefactor. It keeps every check the oldpixel_entrymade. Only the messages and the order change, as the body says.NaN/Infinityall end in exit 1 with no output. Publishing is a same-volume stagedreplace.Findings
MUST
None.
SHOULD
tests/native_direct_mesh_check.py:36-56,:113-118). Many fields in the reviewed record are 0:front_ccw, the three depth-bias fields,multisample,antialiased_line,forced_sample_count,conservative_raster,depth_enable,depth_write_mask,stencil_enable, both stencil masks, everyfront_face/back_facefield,alpha_to_coverage,independent,blend_enable,logic_op_enableandquality. Any reordering among them gives the same bytes. I confirmed this with a mutation (below): swapping the face loop infixed_statestill passes. A fix: add a second record that only goes through the tool, with a distinct nonzero value in every field, and compare it with an expected header packed at absolute offsets. The tool only enforces the sample and attachment rules, so such a record is accepted as long as it keeps count 1, quality 0, mask all ones, and a depth format when depth is enabled.tools/startup/mesh57_profile.py:103-131). The body notes this. The constant, view-list andheap_sgprencoding is only reached through the v3 refusal, and that refusal stops earlier, at the root flags. So a field-order slip insgpr root_parameter root_address, or a missing view count, would go unnoticed. The test already compiles a root with DXC. A second capture set withRootFlags(CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED)would allow a v6 round-trip against the v6 layout thatchecked_pixel_entryalready builds at:130-133.NIT
unique_fields), a request key or companion mismatch, a variant/archive-name mismatch, an empty PS, and non-finite floats. The duplicate check is what backs the "duplicates refused" claim in the body. Each needs about onerun(...)line; the duplicate key needs raw JSON text instead ofjson.dumps.not list(output.iterdir())never exercises staging cleanup. This could go under "Not covered".rt_formatsentries forDXGI_FORMAT_UNKNOWN. The runtime doesn't check this either, so it's optional.What each test proves
native_direct_mesh(check_profile_writer, called fromchecked_pixel_entry):Mesh57Profileheader plus the pixel entry and the six spans, for every field with a nonzero value.pixel_entryand compile path still accept the v2 and v6 fixture profiles and reject a changed byte, which exercises theread_creationrefactor.startup_tools_lintlints both changed Python files.Sandbox run
1014e85f37, exported withgit archive, built from a scratch copy.d3d12SDKLayers.dllin the sandbox). Neither test uses D3D12.native_direct_mesh,startup_tools_lint(2/2)._hardwareor_warptests.Mutations
Each mutation was applied to a scratch copy of
tools/startup/mesh57_profile.py, never to the PR branch. I checked the file hash after each change and restored the file afterwards. The test runs the tool straight from that source tree, so no rebuild was needed. A Python traceback, not a build error, shows each result.fill_mode cull_modein the rasterizer field listnative_direct_meshfailed at the byte round-trip assertion (read_bytes() == blob, line 70). Caught.("back_face", "front_face")native_direct_meshpassed. Not caught.CI
Run 46292887497 at
1014e85f: the Windows PR job passed 82/82 (xmem_placeholder_split_{control,deployed,partial}skipped by design). It ranstartup_tools_lint. It did not runnative_direct_mesh, which is outside theprtest-preset filter. The Linux Python job and the gfx1013 assembly job also don't include it, because it needscompile_dxiland DXC. So CI covered only the lint; the run above is the only one of the behavioural test.Overlap with #3505
Draft #3505 by the same author contains this PR's commit and rewrites the same tool,
mesh57_pixel_entry.py, test and doc section. Suggest merging this PR first and rebasing #3505, then reviewing #3505 as a diff against this PR.