Repository navigation
startup: take pixel input masks from the exact pipeline's stream description (#1629) - #2592
Conversation
|
The source-built target/decoy draws cover the different-register case. Before freezing |
406767d to
5a81b26
Compare
|
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 The PR is rebased on
Tests (
The first commit is the previous head, rebased. Its stale-description control now expects #2595's earlier Windows 11 26200, MSVC 19.44, DXC/FXC from SDK 10.0.26100.0, WARP and RTX 3070, debug layer on, 84 neighbouring CTests that go through 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:
AI-assisted. |
tedin7
left a comment
There was a problem hiding this comment.
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_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: clean- Mutation 1:
pipeline_key()ignores the masks -> 6 controls fail. - Mutation 2: drop the
ena & ~addrrefusal -> 3 controls fail. - Mutation 3:
pending_keysignores 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)
- The
.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.
R0Y00
left a comment
There was a problem hiding this comment.
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.
|
Thanks, both cases reproduce on New commit on top (no history rewritten),
Focused control in Windows 11 26200, MSVC 19.44, DXC/FXC SDK 10.0.26100.0, WARP and RTX 3070, debug layer on, The same 84 neighbouring CTests (stream, mrt, image, DPP/SDWA, translator, refusals, watch, rekey, ...) pass on both adapters. 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 AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
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.
e6368aa to
098d725
Compare
|
Thanks. Reproduced on Fixed in two commits on top of
The conflict with #2634 was in Windows 11, MSVC 19.44, DXC/FXC SDK 10.0.26100.0, WARP and RTX 3070, debug layer on, 84 neighbouring CTests that use AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
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.
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(shader: reject base requests with a mismatched source cache key #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 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.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 startup: hand off the packed screen-position gradient fixture #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(startup: hand off the packed screen-position gradient fixture #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, P0: main executable startup progress #870 and the record-side work in this issue. The.psinformat is only a proposal for that capture..failrule 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.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.