Skip to content

tooling: draft reviewed slot 57 profiles from captures - #3505

Closed
Leyukaka wants to merge 14 commits into
R0Y00:mainfrom
Leyukaka:tooling-mesh57-profile-draft
Closed

Leyukaka wants to merge 14 commits into
R0Y00:mainfrom
Leyukaka:tooling-mesh57-profile-draft

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

Refs #3416

Stacked on #3493, #3497 and #3503. Until they merge, this PR also shows their commits (including 1014e85 and ea3a90c) and the merges 196adf8, 5a5df32 and 2ca22af. Its own commits are 527ee33, d8af54b, 243d7e4 and 5b05bac.

Why

A reviewed slot 57 profile needs the desktop state of the pipeline. Writing that by hand for 100+ pipelines is not practical. The capture and the .t57 sidecar from #3502 already hold most of it, so the tool can prefill what it can decode exactly and leave the rest to the reviewer.

What

Depth-only profiles (527ee33, d8af54b). mesh57_profile.py accepts a capture with a zero-length .ps57:

  • rt_formats and blend.targets must be empty.
  • Depth must be enabled with depth_write_mask 1.
  • depth_format must be a typed DSV format (20, 40, 45 or 55).
  • Version 1 has no pixel field. Versions 2–5 need all three pixel fields zero. Version 6 is refused.
  • Blend RT0 is filled with a fixed disabled entry (ONE/ZERO, ADD, NOOP, all channels). The runtime leaves it unchecked for zero RTVs.

d8af54b fixes the padding added in 527ee33, which produced a 564-byte header instead of 532. The padding is now computed from the rasterizer offset (384) minus the 32-byte prefix. The test asserts a 532-byte header on every successful write and adds a refusal case for a depth-only capture with one RTV format and a matching blend target.

Draft mode (243d7e4, 5b05bac). --draft ARCHIVE DRAFT_JSON writes a JSON in the reviewed schema to a new path:

  • Depth and stencil are decoded from block A, tag 6, words at A+0x10C, 0x110, 0x114 and 0x118, with the rules of pipeline_state_decode.h.
  • Blend is decoded from the eight words at A+0x124+4n with the word rules of cb_blend.h and state_block_blend.h: factor table, bit 29 shared or separate alpha, combine mapping, MIN/MAX needing ONE/ONE, alpha forms and dual-source restrictions. All eight words are validated. The draft keeps one target per RTV.
  • RTV formats, DSV format and sample settings come from the .t57 sidecar when it holds exactly one distinct tuple. Several tuples or an overflow line are refused, and the refusal lists them. Without a tuple these fields and blend stay null.
  • A depth-only tuple with an empty .ps57 gives an empty target list.
  • Every other field is null. Each field carries its provenance, and the draft has review_required: true. The stencil reference and DSV writability appear in provenance only, because the profile has no field for them.

The profile writer refuses a draft that still has a null anywhere or still has the review_required key. For a tag 6 capture it also reruns the decoder refusals.

Intentional differences from the C++

  • A tag other than 6 is refused. The C++ falls back to the vertex offsets.
  • Depth bounds, and a back face whose masks or reference differ from the front, are refused. The C++ only flags them.
  • independent is derived from differences between the selected targets. The C++ always sets it. With identical targets the result is the same, since RT0 then applies to all.

Not covered

Tests

Dev preset, X2W_WITH_OPUS=OFF.

  • At d8af54b, ctest -R '^(native_direct_mesh|native_fixed_mesh57_depth_only_)': 3/3 passed (native_direct_mesh, native_fixed_mesh57_depth_only_warp, native_fixed_mesh57_depth_only_hardware).
  • At 243d7e4, ctest -R '^(mesh57_profile_draft|native_direct_mesh|startup_pipeline_state(_offset_control|_mesh_shift_control)?)$': 5/5 passed.
  • At 5b05bac, ctest -R '^(mesh57_profile_draft|native_direct_mesh|startup_state_block_blend|startup_cb_blend_decode)': 5/5 passed (mesh57_profile_draft, native_direct_mesh, startup_state_block_blend, startup_cb_blend_decode, startup_cb_blend_decode_dest_alpha_control).

Mutations, each caught and then restored:

Mutation Failing test
Padding without the 32-byte prefix native_direct_mesh (the writer's 532 assert fires first)
Depth-only RTV-count check removed native_direct_mesh
Depth write no longer gated by depth enable mesh57_profile_draft
Two .t57 tuples accepted mesh57_profile_draft
Writer review_required check removed mesh57_profile_draft
Blend offset 0x124 changed to 0xD0 mesh57_profile_draft
Bit 29 ignored (alpha always separate) mesh57_profile_draft
Legacy paired factor BOTH_SRC_ALPHA accepted mesh57_profile_draft

@Leyukaka

Copy link
Copy Markdown
Collaborator Author

New head cf40d84: the writer now re-derives from the capture the fields the draft decoded exactly (depth/stencil, blend words, RT/DSV formats and samples) and refuses a reviewed state that contradicts them, naming the fields. Fields left null in the draft stay reviewer-supplied. It also refuses a malformed .t57; without a .t57, only depth/stencil is checked.

Test: tests/mesh57_profile_draft_check.py edits depth function, blend source, RTV format, and DSV + sample fields, and expects each refusal to name the fields and leave the output directory empty; a valid review is compared byte-for-byte. ctest --preset dev -R '^(native_direct_mesh|mesh57_profile_draft)': 2/2 passed.
Mutation: with if mismatches: disabled in the writer, the edited depth_func is accepted and the test fails.

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed cf40d844 (own commits 527ee33..cf40d84; #3497 and #3503 are merged, #3493 is still below) by reading the diff; not built or run. Draft PR.

Verdict: approve. The draft path only fills what it can decode exactly, and since cf40d84 the writer re-checks those fields against the capture. One SHOULD can follow. No MUST.

  • SHOULD check DSV writability against depth writes. read_captured_state drops the .t57 writable bit (tools/startup/mesh57_profile.py:258-259). It reaches the draft only as provenance text (:343), and the writer never compares it. A capture that decodes depth_write_mask 1 but was only observed with a read-only DSV (writable 0) therefore builds a profile that writes depth through a read-only view. The fixture's alternate tuple (tests/mesh57_profile_draft_check.py:152) alone would make a refusal case. Refusing depth_write_mask 1 with writable 0 next to the mismatch check (:491) closes it.
  • NIT depth-only requires depth_write_mask 1 (:402), so a stencil-only pass (depth writes off, stencil writes on) is refused. That is fine for now; a line in the experiment note would say so.
  • Checked, no finding:
    • All eight blend words are validated, including unused ones. That matches the C++ (state_block_blend.h:55), so draft and runtime refuse the same captures.
    • capture_mismatches compares only the decoded keys. Lists of different lengths count as a mismatch. Fields left null in the draft stay reviewer-owned.
    • The header padding is now computed from the rasterizer offset, and the 532-byte assert guards it. --draft opens its output with "x", so it never overwrites a file.
    • read_targets accepts exactly what #3502's writer emits: format 0 RTVs, and writable 1 without a DSV, are refused.

Tests: mesh57_profile_draft proves the depth/stencil and blend decoding, the .t57 conflict and overflow refusals, review_required, and (cf40d84) refusals of edited fields with an empty output directory. CI ran it in the Linux Python job (green). native_direct_mesh (depth-only writer, 532-byte header) is not in the Windows pr filter or the Linux list, so only the author's local runs cover it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P0 Highest project priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants