Skip to content

startup: take pixel input masks from the exact pipeline's stream description (#1629) - #2592

Merged
R0Y00 merged 5 commits into
R0Y00:mainfrom
roansystemlabs:startup/1629-packed-screen-position-provenance
Nov 26, 2026
Merged

R0Y00 merged 5 commits into
R0Y00:mainfrom
roansystemlabs:startup/1629-packed-screen-position-provenance

Conversation

@roansystemlabs

@roansystemlabs roansystemlabs commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1629

This is the translator side of the mask provenance. The pixel input masks now come from a separately captured stream description of the exact pipeline, and they are part of that pipeline's request identity. Distinct enable and address masks are accepted, and the layout comes from the address mask. Runtime capture and wiring, the composite's own masks and the executable rerun stay with main development and #870. No title data is used. Everything here is built from source.

Five commits: the first takes the masks from the description, the second makes the masks part of the request identity, the third makes the watcher follow the description each translation reads, the fourth withdraws results whose description was removed, and the fifth keeps that withdrawal working when an older .fail is still on disk.

What changes

  • Pipeline (tools/startup/gfx2hlsl.py). It no longer refuses every ENA != ADDR pair. Entry VGPRs are laid out by SPI_PS_INPUT_ADDR and loaded by SPI_PS_INPUT_ENA.
    • Sources: LLVM AMDGPUAsmPrinter::getSIProgramInfo (release/18.x: "By this stage, all enabled inputs are tagged in InputAddr as well. We will use InputAddr to determine whether the input counts against the vgpr total"). LLVM processPSInputArgs marks an input allocated, then enabled only when it is used. Mesa ac_get_fs_input_vgpr_cnt() counts the input VGPRs from spi_ps_input_addr with the same widths.
    • The packed position is modelled only when bit 15 is enabled, and the PERSP_CENTER pair only when bit 1 is enabled.
    • An enabled input that is not allocated has no slot in that layout, so it is refused: contradictory pixel input enable/address masks: an enabled input is not allocated. This follows the compiler and driver conventions. It was not observed on AMD hardware.
  • request_ps_inputs(). It reads req_<key>.psin, one ASCII line: psin1 <key> ena=0x.... addr=0x.....
    • The key must name the request. It must also equal pipeline_key() recomputed from the stored .a/.b/.root/.ia and the description's masks. A description copied from another PSO, left stale after a stage change or rewritten with another mask pair is refused: pixel input description names another pipeline.
    • A missing mask is refused by name: pixel input enable|address mask missing from the stream description. A malformed line is refused as invalid pixel input description.
    • A refusal writes <key>.fail and no translated stages, so there is no translated draw.
    • An RTV variant uses its source pipeline's description.
    • With no .psin, the translation keeps today's model (no hardware inputs), so behaviour without a description is unchanged.
  • Masks in the request identity (second commit).
    • pipeline_key(..., ps_inputs=None): with a stream description, b'psin1' + ENA + ADDR (little-endian u32) is hashed after the input layout, the same way .ia is hashed. Two pipelines with identical stage bytes, root signature and input layout but different masks are therefore two requests with their own results. With no description the key is byte-identical to main.
    • The base/RTV source-key check in load_request (shader: reject base requests with a mismatched source cache key #2595) and shader_cache_rekey.py hash the masks too. With a description, a base-key mismatch is reported as pixel input description names another pipeline. The rekeyer copies the .psin and rewrites its line under the new key. This sits next to startup: re-key slot 57 mesh requests in shader_cache_rekey.py (Part of #2413) #2634's slot 57 rekeying: graphics parts are .b, .root, .ia, .psin, .a; slot 57 parts stay .ps57, .root, .m57, so a .psin is never read or written under a mesh key.
    • When output already exists: a different mask pair is a different key, so it becomes a new pending request, and the existing result is untouched. request_source() (third commit) names the one description a request's translation reads (req_<key>.psin, or the source's for an RTV variant), and pending_keys follows that same file: a description newer than the manifest rechecks the result (base and variants), and a description newer than the .fail retries the request. A mismatching pair is refused by name and its manifest withdrawn. An unchanged rewrite is checked once (the manifest is touched) and then counts as done.
  • Removed description (fourth commit).
    • translate_request writes <key>.psdep, the description line the result is translated with, before the manifest is published, for a base and an RTV variant alike. A legacy request that never had a description gets no record.
    • pending_keys queues a published result again when it has a record and the description request_source() names is gone. A request without a record costs one more stat; its inputs are not read again.
    • Such a request is refused by name, pixel input description missing for a request translated with one, and its manifest is withdrawn. The refusal is not retried until the description is written again, newer than the .fail.
    • On the manifest-only path a success leaves an earlier .fail in place. While the manifest is still published, that older .fail no longer hides the removed description (fifth commit).
  • Wiring. The masks reach translate_request (through translate_to(..., ps_hw_inputs=...)) and request_refusals. load_request keeps its signature.
  • The .psin format is a proposal. Nothing in the runtime writes it today, and the runtime's key (d3d12_draw.inl) does not hash the masks yet. Whoever adds the capture needs the same suffix. I'm happy to rename the file or move the two masks into another request file if you'd prefer a different capture shape.

Tests

tests/startup_packed_position_provenance_check.py puts source-built requests in one cache directory:

  • Target: exports v4, with enable 0x8002 and address 0x8003 (PERSP_SAMPLE allocated, not enabled), so the position is v4. Laying it out by the enable mask would give v2.
  • Decoy: exports v2, with enable = address = 0x8002.

Both draw correctly only if each translation takes its own description. Neither a fixed register nor the other pipeline's masks pass.

  • startup_packed_screen_position_provenance (pure Python, also in the Linux job):
    • Target, decoy and an RTV variant each take their own masks.
    • No description keeps today's model and today's key.
    • Refused by name: the decoy's description under the target's name, a stale description, a missing enable mask, a missing address mask, no masks, contradictory masks, a duplicate field, a malformed line and an unknown version. request_refusals reports the same reasons.
    • Same cache, same bytes: three pipelines with the target's exact stage bytes, root signature and input layout and masks 0x8002/0x8003, 0x8003/0x8003 and 0x8002/0x8002 get three keys. Each takes its own masks and publishes under its own key.
    • Output already exists: a different pair is pending on its own and is translated with its own masks. The existing result stays byte-for-byte unchanged. An in-place rewrite with another pair is refused and its manifest withdrawn. An unchanged rewrite is checked once.
    • Watch follows the description the translation reads: a base and an rtv1 <base> 28 variant are published; a wrong pair in the base .psin queues both, both are refused by name and both manifests withdrawn, and neither is retried while the description is unchanged; the valid line restored newer than the .fail files republishes both, with .a and .rtv untouched.
    • Rekeying a cache with two same-byte pipelines keeps both requests and their descriptions, each naming its own key.
    • Removed description (fourth commit): the masked base and rtv1 <base> 28 are published (both record the line); removing only req_<base>.psin queues both, refuses both by name and withdraws both manifests, with the .fail files of the wrong-pair cycle still on disk; nothing is retried while it stays missing; the restored description republishes both. A legacy request publishes without a record and stays done. The wrong-pair and restore controls are unchanged.
  • startup_packed_screen_position_provenance_{warp,hardware}: translate through translate_request, compile with DXC ps_6_0 and FXC ps_5_1, and draw with the startup: hand off the packed screen-position gradient fixture #1634 gradient (--startup-packed-position, 13x7, every pixel against its own coordinates).
    • Target 91/91 and decoy 91/91.
    • Two same-byte PSOs added to the target's cache after its result exists:
      • 0x8003/0x8003 draws 91/91.
      • 0x8002/0x8002 fails at (1,0) as expected. Its position is v2, so the v4 the code exports reads 0. With the target's masks it would have drawn 91/91.
    • With FXC, the compiled-result path: an unchanged rewrite is checked once, and another pair withdraws the result.
  • tests/startup_packed_position_check.py (startup: hand off the packed screen-position gradient fixture #1634) is unchanged.

Results

Rebased on main fbe249f6 (after #2634). Every run below was made on 86f21e07; the acceptance, PR, rekey, watch, refusal and cache CTests ran again on head 098d7252, which differs only in the pending_keys failure check. Windows 11 26200, MSVC 19.44, DXC/FXC from SDK 10.0.26100.0, RTX 3070 and WARP. The debug layer was on in every run, with debug_errors=0 debug_warnings=0. Each commit passes the provenance checks as they stand in that commit (18, 28, 34, 41 and 41 pure controls), and startup_shader_cache_rekey_check.py with #2634's slot 57 cases (31 checks) at every commit. git merge-tree against 82c70807 is clean.

ctest --preset dev --no-tests=error -R '^startup_packed_screen_position_(hardware|warp)$' -V
  startup_packed_screen_position_warp ......   Passed  1.36 sec
  startup_packed_screen_position_hardware ..   Passed  3.82 sec
ctest --preset dev --no-tests=error -R '^(startup_packed_screen_position_provenance(_hardware|_warp)?|startup_shader_cache_rekey|runtime_shader_cache_rekey_cli_check|startup_shader_cache_key)$' -V
  6/6 Passed (41 pure controls; dxc+fxc on warp and hardware: target 91/91, decoy 91/91,
              same bytes 0x8003/0x8003 91/91, same bytes 0x8002/0x8002 mismatch at (1,0))
ctest --preset dev --no-tests=error -R mesh57 -V
  10/10 Passed

84 neighbouring CTests that use pipeline_key/ps_hw_inputs pass on both adapters. They cover stream, mrt, interp_f16, image, DPP/SDWA/cmp16, translator, refusals, watch and rekey. The cache and refusal checks added to main overnight (getpc refusal, indirect mesh cache, mesh86 cache CLI, ps_input_scan CLI, watch, refusals) pass as well (8/8).

Slot 57 and .psin. A scratch re-key (not in the tree) of an older-revision cache holding a masked graphics request with its .psin, a plain graphics request, a slot 57 request and a stray req_<mesh key>.psin (well-formed, then malformed) gives exactly: the masked request under its masked key with a .psin naming that key, the plain one without .psin, and the mesh request as .ps57/.root/.m57 under mesh57_key, with no .psin under any mesh key; pending_keys lists the three. Adding .psin to the slot 57 parts, dropping it from the graphics parts, or dropping the slot 57 kind fails it. pending_keys and translate_request take the slot 57 branch before any .psin lookup.

Fail-first and mutants. The mutated translator was loaded in memory, with the tree untouched. The counts in the earlier rows were taken on the second commit; the next four rows are on e6368aa1, where the new watch control also catches some earlier mutants (no recheck in pending_keys now fails 6 controls); the next five rows are the deletion control, on the old third commit and on 86f21e07; the last row is on 098d7252:

Mutant Pure controls Draw (WARP and RTX 3070)
main translator fails: distinct masks refused as unverified target mismatch (description ignored)
take the first .psin in the directory decoy fails decoy mismatch
drop the key-in-line check decoy description under the target name accepted not covered by the draw
drop the recomputed pipeline_key check stale description accepted not covered by the draw
compare against the variant key, not the source key RTV variant control fails not covered by the draw
fill a missing mask from the other 3 missing-mask controls fail not covered by the draw
drop the ENA-not-in-ADDR guard 3 contradictory-mask controls fail not covered by the draw
invert that guard target refused (check stops with an exception) not reached (the draw mode runs the controls first)
model the position when only allocated allocated-not-enabled control fails not reached (the draw mode runs the controls first)
lay out by the enable mask target v4 controls fail target mismatch
fixed register v2 target v4 controls fail target mismatch
description not wired into translation 12 controls fail target mismatch
first commit only (mask-free key), same-cache scenario same key for both PSOs; the second is served the first result first PSO mismatch at (1,0)
masks dropped from the key 5 controls fail identities assertion fails
request_ps_inputs recomputes without masks 6 controls fail not covered by the draw
load_request base/RTV check without masks 9 controls fail target refused
no manifest withdrawal old result reused fails
no recheck in pending_keys 3 controls fail fails
no touch of an unchanged manifest passes (manifest-only mode rewrites it) FXC compiled path fails
rekeyer hashing without masks rekey control fails not covered by the draw
second commit (5a81b26c), watch control 4 controls fail: the variant is not queued and keeps its manifest, the base is not requeued not covered by the draw
watch checks req_<variant>.psin 3 controls fail not covered by the draw
failure retry ignores the description 2 controls fail not covered by the draw
request_source maps a variant to its own .psin 5 controls fail not covered by the draw
third commit (e6368aa1, and rebased 2ac49979), deletion control 3 controls fail: no record, the removed description queues nothing, both manifests kept not covered by the draw
no dependency record written 3 controls fail not covered by the draw
pending_keys ignores the record 2 controls fail not covered by the draw
no named refusal (key check only) 1 control fails: shader request source key mismatch / RTV variant source key mismatch not covered by the draw
record written for a legacy request legacy control fails not covered by the draw
an older .fail hides a removed description (fourth commit, 86f21e07) 2 controls fail: the removal queues nothing and both manifests stay not covered by the draw

Not covered

  • Where a title's description stores the two masks. That, capturing raw-stream descriptions next to .a/.b/.root in the runtime, and hashing the masks into the runtime's key are left to main development, P0: main executable startup progress #870 and the record-side work in this issue. The .psin format is only a proposal for that capture.
  • File times. The recheck and the retry compare file times, as the .fail rule and the tooling: resume startup shader compilation after manifest-only runs #2008 resume already do. A rewrite within the same timestamp tick, or a cache copied without its times, can be missed. A deleted .psin is noticed only for results that recorded it (<key>.psdep); a masked result published before this branch has no record and is refused by key at its next translation. After a withdrawal, the old .ps.hlsl/.cso and the record stay on disk without a manifest.
  • AMD hardware. The ADDR layout with ENA != ADDR and the contradictory-mask refusal follow the LLVM/Mesa conventions above. The draws check the translation on D3D12 (NVIDIA, WARP), not the original GPU's input loading.
  • Layout widths. The new test only exercises bits 0-1 of the width table. The pull-model and other widths are unchanged and not covered here.
  • Unloaded registers. A register that is allocated but not enabled still reads as zero when the code uses it. It is not refused here.
  • P0: main executable startup progress #870. No link to the full-screen colour issue in P0: main executable startup progress #870 is claimed.
  • Linux job. The pure check ran on Windows only.

AI-assisted.

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

The source-built target/decoy draws cover the different-register case. Before freezing .psin, please add a same-cache control with identical stage bytes, root signature, and input layout but two different valid mask pairs. pipeline_key() currently hashes the shared inputs, so both stream descriptions would name the same request. The existing wrong-register control is in a different cache directory and its sidecar passes the key check. Two PSOs in a single cache must either get distinct request/output identities that include the masks, or the producer must detect and refuse an ambiguous identity. Please also test what happens when a translator sees a different mask pair after output for that shader key already exists. This can stay source-built and independent of the executable capture work.

@roansystemlabs
roansystemlabs force-pushed the startup/1629-packed-screen-position-provenance branch from 406767d to 5a81b26 Compare November 25, 2026 22:59
@roansystemlabs

Copy link
Copy Markdown
Contributor Author

Thanks, that was a real hole. With a mask-free key, two PSOs that share stage bytes, root signature and input layout also share every request file name. The second .psin overwrites the first, so the translator cannot even see that there were two pipelines, let alone refuse one. I went with distinct identities.

The PR is rebased on 2a14c0d7, and there is a new second commit:

  • pipeline_key() takes the description's masks and hashes b'psin1' + ENA + ADDR (little-endian u32) after the input layout, the same way .ia is hashed. With no description the key is byte-identical to main, so existing caches and the runtime's key stay valid. request_ps_inputs(), the base/RTV source-key check in load_request (shader: reject base requests with a mismatched source cache key #2595) and shader_cache_rekey.py hash the masks too. The rekeyer copies the .psin and rewrites its line under the new key.
  • When output already exists: a different mask pair is a different key, so it becomes a new pending request. It is translated with its own masks, and the existing result stays byte-for-byte untouched. If a .psin is rewritten in place under an existing key, pending_keys checks it again (description newer than manifest). The translation then refuses it with pixel input description names another pipeline and withdraws the published manifest instead of serving it. An unchanged rewrite is checked once and then counts as done.

Tests (tests/startup_packed_position_provenance_check.py), all in one cache directory:

  • Three pipelines with the target's exact stage bytes, root signature and input layout and masks 0x8002/0x8003, 0x8003/0x8003 and 0x8002/0x8002 get three keys. Each one takes its own masks and publishes under its own key.
  • Pure controls cover the output-exists case, the in-place rewrite and rekeying. They are part of the Linux job too.
  • The draw adds two same-byte PSOs to the target's cache after the target's result exists. 0x8003/0x8003 draws 91/91. 0x8002/0x8002 fails at (1,0) as expected: the code exports v4, and under those masks the position is in v2, so v4 reads 0 and the first wrong pixel is (1,0). If that PSO had picked up the target's masks, it would have drawn 91/91. The FXC compiled-result path is checked as well.

The first commit is the previous head, rebased. Its stale-description control now expects #2595's earlier shader request source key mismatch from translation, so each commit passes on its own.

Windows 11 26200, MSVC 19.44, DXC/FXC from SDK 10.0.26100.0, WARP and RTX 3070, debug layer on, debug_errors=0 debug_warnings=0:

ctest --preset dev --no-tests=error -R '^startup_packed_screen_position_(hardware|warp)$' -V        2/2 Passed
ctest --preset dev --no-tests=error -R '^(startup_packed_screen_position_provenance(_hardware|_warp)?|startup_shader_cache_rekey|startup_shader_cache_key)$' -V   5/5 Passed

84 neighbouring CTests that go through pipeline_key/ps_hw_inputs (stream, mrt, interp_f16, DPP/SDWA, image, rekey, ...) pass on both adapters. git merge-tree against the current main (5ca71c5b) is clean.

Fail-first: on the previous head, the two same-byte PSOs get the same key. Once the first result exists, the second is never pending and is served the first result. Retranslated, the key loses the first pipeline's masks, and the first pipeline's draw fails at (1,0). These mutants are each caught: masks dropped from the key, the recheck dropped, the manifest withdrawal dropped, and the rekeyer hashing without masks. The touch-once mutant is caught only by the FXC draw path.

Not covered:

  • The runtime still writes no .psin and does not hash the masks. Whoever adds the capture needs the same suffix in d3d12_draw.inl.
  • A published RTV variant result is not rechecked when its source .psin is rewritten in place.
  • No AMD hardware.

AI-assisted.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of head 5a81b26 (rebased, two commits), against origin/main. Comment only, no approval.

Your earlier question (same-cache control, different masks) is answered. pipeline_key() now hashes b'psin1' + ENA + ADDR after the input layout. With no description the key is byte-identical to main. request_ps_inputs(), the base/RTV check in load_request, pending_keys and shader_cache_rekey.py use the same masks. Three PSOs with identical stages, root and layout but different mask pairs get three keys in one cache directory, and a rewritten .psin under an existing key is refused and the old manifest withdrawn.

What I checked

  • Pipeline: ENA must be a subset of ADDR, the layout comes from ADDR, and the loaded PERSP_CENTER pair comes from ENA. This matches the sources cited in the PR body. It is not observed on hardware, and the PR says so.
  • read_ps_inputs: strict one-line grammar, key must match, a missing mask is refused by name.
  • Test file is new and registered in CTest (startup_packed_screen_position_provenance plus a _warp and _hardware draw variant) and in .github/workflows/windows.yml.

Commands run (Linux, worktree on this head)

  • python3 -B tests/startup_packed_position_provenance_check.py : all controls ok
  • python3 -B tests/startup_shader_cache_rekey_check.py and tests/startup_ps_input_scan_check.py : pass
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD : clean
  • Mutation 1: pipeline_key() ignores the masks -> 6 controls fail.
  • Mutation 2: drop the ena & ~addr refusal -> 3 controls fail.
  • Mutation 3: pending_keys ignores a newer .psin -> 3 controls fail.
  • The negative controls catch the intended failures. No D3D12 draw was run by me; the WARP/hardware draws are not verified here, and CI on this head was still pending.

Points for @R0Y00 (design, not a bug)

  1. The .psin line format and the key change are an interface contract between the future runtime capture and the translator. When a .psin exists, the translator key no longer equals the key the runtime computes from the stages alone. That is intended per the PR, but the runtime side is not in this PR, so the format is frozen before its producer exists. Please confirm you want to freeze psin1 now.
  2. pending_keys decides "description newer than manifest" by file mtime and translate_request touches the manifest after an unchanged result. This works, but it depends on filesystem timestamp resolution. A coarse-timestamp or copied cache could skip a re-check. A content hash stored in the manifest would be sturdier. Not blocking.

This touches the startup path, and I did not run any executable. Merge stays with @R0Y00 or MasterDomino after the Windows CI and WARP/hardware draw results on this head.

AI-assisted; commands listed were executed locally.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The mask-inclusive key fixes the same-cache collision. I found two related watcher cases using the existing synthetic TARGET and DECOY fixture. Publish the base and a valid rtv1 <base> 28 variant, then replace the base .psin with the wrong mask pair (same key in the line) and give it a later mtime than both manifests. pending_keys(..., True) queues the base only. It refuses by name and withdraws the base manifest, but the RTV variant still has its old manifest. Its translation consumes the base .psin, while the watch predicate checks req_<variant>.psin.

Next, restore the original valid sidecar and stamp it newer than the .fail. The base still does not requeue because the failure check compares only .a. Please make manifest invalidation and failure retry use the same effective base-description dependency as translation for both direct requests and variants. A focused check can cover publish → wrong pair withdraws both → corrected sidecar republishes both without touching .a or .rtv. Preserve the no-description legacy key and the incoming same-cache control.

@roansystemlabs

Copy link
Copy Markdown
Contributor Author

Thanks, both cases reproduce on 5a81b26c exactly as you describe: after the wrong pair the queue is [base] and the variant keeps its manifest, and after the restore the queue is empty.

New commit on top (no history rewritten), e6368aa1:

  • request_source(out_dir, key) is now the one place that names a graphics request's source and the stream description its translation reads: req_<key>.psin for a base request, req_<source>.psin for an RTV variant. It is the .rtv parsing that was inside load_request, plus that path.
  • Translation (load_request and request_ps_inputs) reads the masks from that path. pending_keys uses the same path for both decisions: a description newer than the manifest rechecks the result, and a .fail is skipped only while it is at least as new as both the request file (.a/.rtv, as before) and that description.
  • No description: legacy key and behaviour unchanged. The same-cache controls are unchanged and pass.

Focused control in tests/startup_packed_position_provenance_check.py (pure, Linux job too): base + rtv1 <base> 28 published by a watch pass → wrong pair in the base .psin, newer than both manifests → both queued, both refused by name, both manifests withdrawn, not retried while unchanged → valid line restored, newer than both .fail → both queued and republished with the position in v4, .a and .rtv bytes and mtimes unchanged. On 5a81b26c this control fails at the four expected steps. Mutants caught: watch on req_<variant>.psin (3 fail), retry ignoring the description (2), no manifest recheck (6), variant mapped to its own .psin in request_source (5).

Windows 11 26200, MSVC 19.44, DXC/FXC SDK 10.0.26100.0, WARP and RTX 3070, debug layer on, debug_errors=0 debug_warnings=0:

ctest --preset dev --no-tests=error -R '^startup_packed_screen_position_(hardware|warp)$' -V        2/2 Passed
ctest --preset dev --no-tests=error -R '^(startup_packed_screen_position_provenance(_hardware|_warp)?|startup_shader_cache_rekey|startup_shader_cache_key)$' -V   5/5 Passed (34 pure controls)

The same 84 neighbouring CTests (stream, mrt, image, DPP/SDWA, translator, refusals, watch, rekey, ...) pass on both adapters. git merge-tree against e5d8251b is clean.

On @tedin7's point 2: I kept file times. A content check needs a record of which description was checked, either a manifest line, which the runtime reads, or one more output file per request. The .fail retry and the #2008 resume are already time based, so a separate content rule for .psin alone would mix two rules in one watcher. The limit stays: a rewrite in the same timestamp tick, or a cache copied without its times, can be missed. I can add a content stamp as a follow-up if you prefer.

AI-assisted.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The new same-cache rewrite/restore controls pass on e6368aa1 in Windows Python. One remaining watch path serves output whose description is gone. Using the test’s put_request and watch_pass, publish the masked base and rtv1 <base> 28, then remove only req_<base>.psin. pending(cache) is empty and both .txt manifests still exist. Forced translation rejects the base with shader request source key mismatch and the variant with RTV variant source key mismatch. Please add the deletion case and distinguish a published result known to depend on a description from a legacy request that never had one. A small dependency record for masked publications would avoid rescanning legacy inputs. Keep the wrong-pair and restore controls and resolve the current main conflict with #2634’s slot-57 rekeying.

…ription (R0Y00#1629)

Pipeline lays out the entry VGPRs by SPI_PS_INPUT_ADDR and loads them by
SPI_PS_INPUT_ENA, so distinct masks are accepted; an enabled input that is
not allocated is refused as contradictory. request_ps_inputs() reads the
separately captured description req_<key>.psin and refuses one that names
another pipeline (key in the line or recomputed pipeline_key), a missing
enable or address mask, or a malformed line. translate_request and
request_refusals pass the masks on; no description keeps today's model.

tests/startup_packed_position_provenance_check.py: a source-built target
(position in v4 from enable 0x8002 / address 0x8003) and a decoy (v2) in one
cache directory; pure controls, then the R0Y00#1634 gradient draw on WARP and
hardware with a wrong-register control. The R0Y00#1634 check is unchanged.
…00#1629)

Two pipelines with identical stage bytes, root signature and input layout
but different SPI_PS_INPUT_ENA/ADDR masks hashed to the same pipeline_key(),
so they shared every request file name and the second description replaced
the first in the cache.

- pipeline_key() takes the description's masks (ps_inputs) and hashes
  b'psin1' + ENA + ADDR (little-endian u32) after the input layout, as the
  layout itself is hashed. Without a description the key is unchanged, so
  existing caches keep their keys.
- request_ps_inputs() recomputes the key with the masks. A description
  rewritten with another mask pair under an existing key is refused by name
  (pixel input description names another pipeline), and the result already
  published for that key is withdrawn instead of being served.
- pending_keys() checks a published result again when its description is
  newer than its manifest; translate_request() marks the manifest as checked
  when the description still matches, so the check runs once.
- The base and RTV source key check in load_request (R0Y00#2595) and
  shader_cache_rekey.py hash the masks too; with a description, a base
  key mismatch is reported as the description naming another pipeline.
  The re-keyer rewrites the description line under the new key.

The provenance check gains same-cache controls: three pipelines with the
target's exact bytes and three mask pairs get three keys and each takes its
own masks; a different pair after a result exists is translated as its own
request and leaves that result untouched; an in-place rewrite is refused and
withdrawn. The draw mode adds two same-byte pipelines to the target's cache
(0x8003/0x8003 draws the gradient, 0x8002/0x8002 fails at (1,0) as
expected) and checks the compiled-result path with FXC.
)

An RTV variant is translated from its source pipeline's blobs and stream
description, but pending_keys compared req_<variant>.psin with the
variant's manifest, and a failure was retried only when .a or .rtv
changed. A wrong mask pair written into a base description therefore
withdrew the base result and left the variant's result published, and a
corrected description did not requeue the refused request.

request_source() now names the request's source key and the one
description its translation depends on (req_<key>.psin for a base
request, req_<source>.psin for a variant). load_request,
request_ps_inputs and pending_keys all use it: a description newer than
the manifest rechecks the result, and a description newer than the
.fail retries the request, for base requests and variants alike.
Requests without a description keep the legacy key and behaviour.

The new control publishes a base and an `rtv1 <base> 28` variant, writes
the wrong pair into the base description (both are refused by name and
both manifests withdrawn), then restores the valid line (both are
republished without touching .a or .rtv).
…#1629)

With a published base and an rtv1 variant of it, removing only
req_<base>.psin left both manifests in place: pending_keys saw no
description and nothing newer, so the watcher kept serving results that a
forced translation refuses (shader request source key mismatch and RTV
variant source key mismatch).

- translate_request writes <key>.psdep, the description line the result is
  translated with, before the manifest is published, for a base request and
  an RTV variant alike. A legacy request that never had a description gets
  no record.
- pending_keys queues a published result again when it has a record and the
  description request_source() names is gone. A request without a record is
  not read again, so legacy caches keep today's cost.
- translate_request refuses such a request by name, "pixel input
  description missing for a request translated with one", and withdraws its
  manifest. The refusal is not retried until the description is written
  again, newer than the .fail.

The provenance check keeps the wrong-pair and restore controls and adds:
both results record their description line; removing only the base
description queues the base and its variant, refuses both by name and
withdraws both manifests; nothing is retried while it stays missing; the
restored description republishes both; a legacy request publishes without a
record and stays done.
…ail (R0Y00#1629)

On the manifest-only path a successful translation leaves an earlier .fail
in place. A published result whose recorded stream description was later
removed then fell through to the failure check, which compared that old
.fail only with the request file (no description time is left) and skipped
the result, so its manifest stayed published.

pending_keys now queues such a result while its manifest exists; the
translation refuses it by name and withdraws the manifest, and the new
.fail keeps it from being retried until the description returns.

The provenance check no longer deletes the failures of the wrong-pair cycle
before removing the description, so it covers this order.
@roansystemlabs
roansystemlabs force-pushed the startup/1629-packed-screen-position-provenance branch from e6368aa to 098d725 Compare November 26, 2026 01:48
@roansystemlabs

Copy link
Copy Markdown
Contributor Author

Thanks. Reproduced on e6368aa1: with the masked base and rtv1 <base> 28 published, removing only req_<base>.psin left pending(cache) empty and both .txt manifests in place, while a forced translation refused them with shader request source key mismatch and RTV variant source key mismatch.

Fixed in two commits on top of main fbe249f6, head 098d7252:

  • 86f21e07: translate_request writes <key>.psdep, the description line the result is translated with, before the manifest is published, for the base and for an RTV variant. A legacy request that never had a description gets no record, its key is unchanged from main, and pending_keys does not read its inputs again (one more stat).
  • pending_keys queues a published result again when it has a record and the description request_source() names is gone. The translation refuses it by name, pixel input description missing for a request translated with one, and withdraws its manifest. It is not retried while the description stays missing; the restored description, newer than the .fail, republishes both.
  • 098d7252: on the manifest-only path a success leaves an earlier .fail in place, and that older .fail hid the removal (wrong pair, restore, then delete: nothing queued, both manifests kept). A result still published without its recorded description is now queued regardless of an older .fail.

tests/startup_packed_position_provenance_check.py keeps the wrong-pair and restore controls and adds the deletion case (both refused by name and withdrawn, no retry while missing, both republished on restore, .a/.rtv untouched) and the legacy case (no record, stays done). The deletion control no longer clears the .fail files of the wrong-pair cycle. On e6368aa1 it fails 3 controls, on 86f21e07 2.

The conflict with #2634 was in shader_cache_rekey.py only. Both are kept: graphics parts are .b, .root, .ia, .psin, .a; slot 57 parts stay .ps57, .root, .m57, so a .psin is never read or written under a mesh key. startup_shader_cache_rekey_check.py, with #2634's slot 57 cases, passes at every commit.

Windows 11, MSVC 19.44, DXC/FXC SDK 10.0.26100.0, WARP and RTX 3070, debug layer on, debug_errors=0 debug_warnings=0 throughout:

ctest --preset dev --no-tests=error -R '^startup_packed_screen_position_(hardware|warp)$' -V    2/2 passed (on 098d7252)
ctest ... provenance (+_warp, _hardware), shader_cache_rekey, rekey CLI, shader_cache_key, gfx2hlsl watch/refusals/getpc,
    indirect mesh cache, mesh86 cache CLI, ps_input_scan (+CLI), mesh57 skeleton/loop refusal, translator    17/17 passed (on 098d7252)
ctest --preset dev --no-tests=error -R mesh57 -V                                                 10/10 passed (on 86f21e07)

84 neighbouring CTests that use pipeline_key/ps_hw_inputs also pass (on 86f21e07). Each commit passes its own provenance checks (18, 28, 34, 41, 41). git merge-tree against 82c70807 is clean.

AI-assisted.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The exact candidate passes the source-built watcher and re-key tests. Removing the description withdraws both the base and its RTV variant even with the prior failure file. Restoring it republishes both, and legacy results keep their existing identity. WARP and RTX 4060 Laptop each matched the target and decoy on the expected 91 covered pixels, and the wrong-layout control disagreed at (1,0). This resolves the stale cache result finding. The evidence covers the translator and watcher.

@R0Y00
R0Y00 merged commit c1e4c70 into R0Y00:main Nov 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants