startup: take pixel input masks from the exact pipeline's stream description (#1629) #2584
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2592"
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 roansystemlabs on 2026-11-25T22:15:09Z.
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
.failis still on disk.What changes
Pipeline(tools/startup/gfx2hlsl.py). It no longer refuses every ENA != ADDR pair. Entry VGPRs are laid out bySPI_PS_INPUT_ADDRand loaded bySPI_PS_INPUT_ENA.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"). LLVMprocessPSInputArgsmarks an input allocated, then enabled only when it is used. Mesaac_get_fs_input_vgpr_cnt()counts the input VGPRs fromspi_ps_input_addrwith the same widths.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 readsreq_<key>.psin, one ASCII line:psin1 <key> ena=0x.... addr=0x.....pipeline_key()recomputed from the stored.a/.b/.root/.iaand 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.pixel input enable|address mask missing from the stream description. A malformed line is refused asinvalid pixel input description.<key>.failand no translated stages, so there is no translated draw..psin, the translation keeps today's model (no hardware inputs), so behaviour without a description is unchanged.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.iais 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.load_request(#2595) andshader_cache_rekey.pyhash the masks too. With a description, a base-key mismatch is reported aspixel input description names another pipeline. The rekeyer copies the.psinand rewrites its line under the new key. This sits next to #2634's slot 57 rekeying: graphics parts are.b,.root,.ia,.psin,.a; slot 57 parts stay.ps57,.root,.m57, so a.psinis never read or written under a mesh key.request_source()(third commit) names the one description a request's translation reads (req_<key>.psin, or the source's for an RTV variant), andpending_keysfollows that same file: a description newer than the manifest rechecks the result (base and variants), and a description newer than the.failretries 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.translate_requestwrites<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_keysqueues a published result again when it has a record and the descriptionrequest_source()names is gone. A request without a record costs one morestat; its inputs are not read again.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..failin place. While the manifest is still published, that older.failno longer hides the removed description (fifth commit).translate_request(throughtranslate_to(..., ps_hw_inputs=...)) andrequest_refusals.load_requestkeeps its signature..psinformat 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.pyputs source-built requests in one cache directory:0x8002and address0x8003(PERSP_SAMPLE allocated, not enabled), so the position is v4. Laying it out by the enable mask would give v2.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):request_refusalsreports the same reasons.0x8002/0x8003,0x8003/0x8003and0x8002/0x8002get three keys. Each takes its own masks and publishes under its own key.rtv1 <base> 28variant are published; a wrong pair in the base.psinqueues 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.failfiles republishes both, with.aand.rtvuntouched.rtv1 <base> 28are published (both record the line); removing onlyreq_<base>.psinqueues both, refuses both by name and withdraws both manifests, with the.failfiles 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 throughtranslate_request, compile with DXCps_6_0and FXCps_5_1, and draw with the #1634 gradient (--startup-packed-position, 13x7, every pixel against its own coordinates).0x8003/0x8003draws 91/91.0x8002/0x8002fails 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.tests/startup_packed_position_check.py(#1634) is unchanged.Results
Rebased on
mainfbe249f6(after #2634). Every run below was made on86f21e07; the acceptance, PR, rekey, watch, refusal and cache CTests ran again on head098d7252, which differs only in thepending_keysfailure 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, withdebug_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), andstartup_shader_cache_rekey_check.pywith #2634's slot 57 cases (31 checks) at every commit.git merge-treeagainst82c70807is clean.84 neighbouring CTests that use
pipeline_key/ps_hw_inputspass on both adapters. They cover stream, mrt, interp_f16, image, DPP/SDWA/cmp16, translator, refusals, watch and rekey. The cache and refusal checks added tomainovernight (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 strayreq_<mesh key>.psin(well-formed, then malformed) gives exactly: the masked request under its masked key with a.psinnaming that key, the plain one without.psin, and the mesh request as.ps57/.root/.m57undermesh57_key, with no.psinunder any mesh key;pending_keyslists the three. Adding.psinto the slot 57 parts, dropping it from the graphics parts, or dropping the slot 57 kind fails it.pending_keysandtranslate_requesttake the slot 57 branch before any.psinlookup.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 inpending_keysnow fails 6 controls); the next five rows are the deletion control, on the old third commit and on86f21e07; the last row is on098d7252:maintranslator.psinin the directorypipeline_keycheckrequest_ps_inputsrecomputes without masksload_requestbase/RTV check without maskspending_keys5a81b26c), watch controlreq_<variant>.psinrequest_sourcemaps a variant to its own.psine6368aa1, and rebased2ac49979), deletion controlpending_keysignores the recordshader request source key mismatch/RTV variant source key mismatch.failhides a removed description (fourth commit,86f21e07)Not covered
.a/.b/.rootin the runtime, and hashing the masks into the runtime's key are left to main development, #870 and the record-side work in this issue. The.psinformat is only a proposal for that capture..failrule and the #2008 resume already do. A rewrite within the same timestamp tick, or a cache copied without its times, can be missed. A deleted.psinis 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/.csoand the record stay on disk without a manifest.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T22:16:43Z.
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.Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-25T22:59:59Z.
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
.psinoverwrites 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 hashesb'psin1' + ENA + ADDR(little-endian u32) after the input layout, the same way.iais 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 inload_request(#2595) andshader_cache_rekey.pyhash the masks too. The rekeyer copies the.psinand rewrites its line under the new key..psinis rewritten in place under an existing key,pending_keyschecks it again (description newer than manifest). The translation then refuses it withpixel input description names another pipelineand 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:0x8002/0x8003,0x8003/0x8003and0x8002/0x8002get three keys. Each one takes its own masks and publishes under its own key.0x8003/0x8003draws 91/91.0x8002/0x8002fails 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 mismatchfrom 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: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-treeagainst 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:
.psinand does not hash the masks. Whoever adds the capture needs the same suffix ind3d12_draw.inl..psinis rewritten in place.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:02:26Z.
Review: COMMENTED
Review of head
5a81b26c(rebased, two commits), against origin/main. Comment only, no approval.Your earlier question (same-cache control, different masks) is answered.
pipeline_key()now hashesb'psin1' + ENA + ADDRafter the input layout. With no description the key is byte-identical to main.request_ps_inputs(), the base/RTV check inload_request,pending_keysandshader_cache_rekey.pyuse 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.psinunder 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.startup_packed_screen_position_provenanceplus a_warpand_hardwaredraw 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 okpython3 -B tests/startup_shader_cache_rekey_check.pyandtests/startup_ps_input_scan_check.py: passpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: cleanpipeline_key()ignores the masks -> 6 controls fail.ena & ~addrrefusal -> 3 controls fail.pending_keysignores a newer.psin-> 3 controls fail.Points for @R0Y00 (design, not a bug)
.psinline format and the key change are an interface contract between the future runtime capture and the translator. When a.psinexists, 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 freezepsin1now.pending_keysdecides "description newer than manifest" by file mtime andtranslate_requesttouches 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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T23:14:05Z.
Review: CHANGES_REQUESTED
The mask-inclusive key fixes the same-cache collision. I found two related watcher cases using the existing synthetic
TARGETandDECOYfixture. Publish the base and a validrtv1 <base> 28variant, then replace the base.psinwith 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 checksreq_<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.aor.rtv. Preserve the no-description legacy key and the incoming same-cache control.Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-25T23:49:12Z.
Thanks, both cases reproduce on
5a81b26cexactly 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>.psinfor a base request,req_<source>.psinfor an RTV variant. It is the.rtvparsing that was insideload_request, plus that path.load_requestandrequest_ps_inputs) reads the masks from that path.pending_keysuses the same path for both decisions: a description newer than the manifest rechecks the result, and a.failis skipped only while it is at least as new as both the request file (.a/.rtv, as before) and that description.Focused control in
tests/startup_packed_position_provenance_check.py(pure, Linux job too): base +rtv1 <base> 28published 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,.aand.rtvbytes and mtimes unchanged. On5a81b26cthis control fails at the four expected steps. Mutants caught: watch onreq_<variant>.psin(3 fail), retry ignoring the description (2), no manifest recheck (6), variant mapped to its own.psininrequest_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:The same 84 neighbouring CTests (stream, mrt, image, DPP/SDWA, translator, refusals, watch, rekey, ...) pass on both adapters.
git merge-treeagainste5d8251bis 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
.failretry and the #2008 resume are already time based, so a separate content rule for.psinalone 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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T00:04:37Z.
Review: CHANGES_REQUESTED
The new same-cache rewrite/restore controls pass on
e6368aa1in Windows Python. One remaining watch path serves output whose description is gone. Using the test’sput_requestandwatch_pass, publish the masked base andrtv1 <base> 28, then remove onlyreq_<base>.psin.pending(cache)is empty and both.txtmanifests still exist. Forced translation rejects the base withshader request source key mismatchand the variant withRTV 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 currentmainconflict with #2634’s slot-57 rekeying.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T02:02:41Z.
Review: APPROVED
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.
Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-26T01:48:57Z.
Thanks. Reproduced on
e6368aa1: with the masked base andrtv1 <base> 28published, removing onlyreq_<base>.psinleftpending(cache)empty and both.txtmanifests in place, while a forced translation refused them withshader request source key mismatchandRTV variant source key mismatch.Fixed in two commits on top of
mainfbe249f6, head098d7252:86f21e07:translate_requestwrites<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 frommain, andpending_keysdoes not read its inputs again (one morestat).pending_keysqueues a published result again when it has a record and the descriptionrequest_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.failin place, and that older.failhid 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.pykeeps 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/.rtvuntouched) and the legacy case (no record, stays done). The deletion control no longer clears the.failfiles of the wrong-pair cycle. One6368aa1it fails 3 controls, on86f21e072.The conflict with #2634 was in
shader_cache_rekey.pyonly. Both are kept: graphics parts are.b,.root,.ia,.psin,.a; slot 57 parts stay.ps57,.root,.m57, so a.psinis 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=0throughout:84 neighbouring CTests that use
pipeline_key/ps_hw_inputsalso pass (on86f21e07). Each commit passes its own provenance checks (18, 28, 34, 41, 41).git merge-treeagainst82c70807is clean.AI-assisted.