compile_dxil: add --rekey mode matching shader_cache_rekey.py #3014
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3014"
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 stan495 on 2026-11-27T05:11:56Z.
Adds
--rekeytocompile_dxilas the native C++ equivalent oftools/startup/shader_cache_rekey.py.Changes
src/shader_compute_request.{h,cpp}: Expose sharedfnv1a_64,graphics_request_key,compute_request_key,mesh57_request_key,.psinparser/formatter, and.rtvparser/formatter helpers reused byread_graphics_request,read_compute_request, andcompile_dxil --rekey.tools/startup/compile_dxil.cpp: Implementcompile_dxil --rekey OLD_CACHE_DIR NEW_REQUEST_DIR [--jobs N](noSDK_DIRECTORYor DXC required):OLD_CACHE_DIRforreq_<16-hex>markers (.a,.c67,.m57,.rtv), counts.m86markers, and ignores result/diagnostic files (.txt,.fail,.cso,.psdep).NEW_REQUEST_DIR; incomplete/unreadable/malformed requests exit1without writing anything, and invalid CLI usage orOLD_CACHE_DIR == NEW_REQUEST_DIRexits2..a,.c67,.m57written last), rewrites.psinand.rtvpayloads with the updated keys, skips already-present files inNEW_REQUEST_DIR, and leavesOLD_CACHE_DIRuntouched.tests/native_compile_dxil_rekey_check.py&tests/cmake/native_compile_dxil_rekey.cmake: Registernative_compile_dxil_rekeytesting revision-constant parity across C++ and Python, byte-for-byte parity withshader_cache_rekey.py,gfx2hlsl.pending_keyscompatibility,--jobs 1vs--jobs 2determinism, idempotency, source-directory immutability, 7 incomplete/corrupted negative controls, and 8 CLI negative controls.docs/experiments/native-compile-dxil-rekey.md: Document--rekeyusage and verification.Verification (commit
50d53508)Result:
5/5passed (native_compile_dxil_refusals,native_compile_dxil_rekey,native_compile_dxil_watch,native_rtv_variant_controls,native_startup_request_cache_controls).Result: all passed (
54Markdown files /571links,2170tracked files checked).Fixes #3012
Refs #2935
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T05:26:52Z.
Review: COMMENTED
A merge trial of
50d53508with #30065c49bbe3conflicts intools/startup/compile_dxil.cpp. Please coordinate the landing order and rebase the second PR, preserving both rekey behavior and the native output revision checks. After resolving, the focused integration coverage isnative_compile_dxil_rekey,native_compile_dxil_watch, and the published-dispatch refusal controls.Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:38:04Z.
Review: COMMENTED
What works
computations, psin/rtv parsing) into shader_compute_request.{h,} and
reuse of
read_rekey_bytesandread_rekey_stringin the compile_dxil--rekey mode. The C++ rekey is a proper parity match with the Python
original.
exit code 1 failure before any writes on incomplete/malformed requests.
This avoids partial-cache corruption on rekey failure.
hardware_concurrency, capped at 64) -- sensible defaults and good CLI.
idempotency, read-only preservation, and all incomplete-request / CLI
negative controls.
Issues
shader_compute_request.hadds several top-level declarations (fnv1a_64,request key functions, parse_pixel_input_description, etc.) as
non-namespaced C functions but also declares
x2w::PixelInputDescriptionand
x2w::RtvVariantDescriptioninside thex2wnamespace. The mixednamespace placement could be confusing -- the helper functions should
likely live inside x2w:: too.
rekey_request_pathuses a hardcodedreq_prefix string literal.This is consistent with the marker format but should ideally reference a
shared constant if marker parsing is done elsewhere.
.m86(already-present) vs.a/.c67/.m57) markercounting. The doc mentions counting
.m86markers but the test doesn'texplicitly verify this count (good that it preserves already-present files,
but a dedicated test would help).
Recommendations
into the x2w namespace or into an internal detail namespace.
Overall
Excellent utility function: a native rekey parity match with the Python
original, with proper atomicity, parallelism, and error handling.
Approvable after the namespace note.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-27T05:45:31Z.
@R0Y00 Happy to let #3006 land first since it touches more files. As soon as #3006 merges into
cpp-migration, I'll rebase #3014 on top, preserve both--rekeyand the native output revision checks, and re-runnative_compile_dxil_rekey,native_compile_dxil_watch, and the published-dispatch refusal controls (or if you prefer to merge #3014 first, it is currently clean on999e17cd).@KelboLive Thanks for reviewing! Two quick clarifications from the diff:
fnv1a_64,graphics_request_key,compute_request_key,mesh57_request_key,parse_*,format_*) insrc/shader_compute_request.hare already insidenamespace x2w { ... }(lines 8–30)..m86counter is already explicitly tested intests/native_compile_dxil_rekey_check.py(seedingreq_123456789abcdef0.m86, asserting'not re-keyed (own key strings): m86 1' in res_cpp.stdout, and verifying no.m86file is copied)."req_"matches the existing prefix spelling used throughouttools/startup/compile_dxil.cpp(--refusals,--watch,--requests) andsrc/shader_compute_request.cpp.Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T00:56:03Z.
I tried merging
cpp-migrationa0f67731into50d53508to clear the conflict, and stopped. The conflict is semantic, so I did not push.The conflicting file is
src/shader_compute_request.cpp, inread_graphics_requestandread_compute_request.What clashes:
x2w::graphics_request_keyandx2w::compute_request_key, which hard-codex2w-startup-shader-28andx2w-startup-shader-28cs. The readers call those helpers.cpp-migrationnow uses revision 29 (x2w-startup-shader-29/-29cs) in both readers, and also accepts a revision-28 key so older archives still replay. It does this with a localrequest_key(revision)lambda.tools/startup/gfx2hlsl.pywrites revision 29.What a resolution needs:
compile_dxil --rekeywrites. As merged, it would write 28, which no longer matches whatgfx2hlsl.pywrites.tests/native_compile_dxil_rekey_check.pychecks for the-28tokens and would need the same decision.Those are your choices, so I left the branch as it was.
tools/startup/compile_dxil.cppmerged without conflict.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T01:04:23Z.
#3006 landed in main at
7364e6a9. Please carry this existing PR onto current main and retarget it there once the conflict is resolved. Preserve revision-29 output keys, revision-28 input compatibility, and both the watcher and published-dispatch native-output revision checks. Please rerun native_compile_dxil_rekey, native_compile_dxil_watch and the relevant native Dispatch and legacy-cache controls. #3138 also touches sidecar parsing on the compiler stack, so keep the key helpers and parsing changes easy to compare there.Imported from R0Y00/Xbox2Windows. Originally posted by akimfomin on 2026-11-28T01:30:29Z.
I also checked
50d53508together with #3138 (e31ffc6d); the source pair conflicts inshader_compute_request.cppandcompile_dxil.cpp. This is distinct from the #3006 migration. After retargeting, use a stale-timestamp changed.ps57inplus an unchanged rekeyed derived RTV request. Request identity can move under--rekey, but the watcher must still compare canonical sidecar content; an unchanged request is the cache-hit control.Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-28T06:17:55Z.
Rebased onto current
main(6a1968a1) asc507563dand retargeted this PR tomain.x2w::graphics_request_keyandx2w::compute_request_keynow default to revision 29 (x2w-startup-shader-29/x2w-startup-shader-29cs) and accept an optionalrevision_override, socompile_dxil --rekeyemits revision-29 keys whileread_graphics_requestandread_compute_requestcontinue accepting revision-28 archives.tools/startup/compile_dxil.cppkeeping bothnative_compute_output.handshader_compute_request.h.tests/native_compile_dxil_rekey_check.pyto check the revision-29 strings across C++ and Python.Verified on
c507563dwithctest --preset dev --no-tests=error -V -R '^(native_compile_dxil_(rekey|watch|refusals)|native_rtv_variant_(controls|warp)|native_startup_request_cache_(controls|warp))$': 7/7 passed (native_compile_dxil_refusals,native_compile_dxil_rekey,native_compile_dxil_watch,native_rtv_variant_controls,native_rtv_variant_warp,native_startup_request_cache_controls,native_startup_request_cache_warp).Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T06:27:10Z.
Review: CHANGES_REQUESTED
Independent Release re-review on
c507563dafter retargeting to main. Builtcompile_dxil,offscreen_check,startup_stream_consumerandd3d12_xs_shim, then ranctest --preset release --no-tests=error --output-on-failure -j 1 -R '^(native_compile_dxil_(rekey|watch|refusals)|native_rtv_variant_(controls|warp)|native_startup_request_cache_(controls|warp))$'. All seven passed with no skips, including the two inbox WARP cases. The C++/Python rekey comparison, idempotency and negative controls passed. The shared helpers output revision 29 and the readers retain revision 28 input compatibility.Please correct
docs/experiments/native-compile-dxil-rekey.md, which still listsx2w-startup-shader-28andx2w-startup-shader-28csas the current output revisions. Document 29 output and 28 reader compatibility. The separate #3138 merge on the compiler stack still overlapsshader_compute_request.cppandcompile_dxil.cpp; the ordinary main-targeted test above did not exercise that stacked combination.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T07:01:42Z.
Review: APPROVED
Re-reviewed
8ce91312. The only change from the previous tested head is the experiment note, which now says revision 29 output and revision 28 input compatibility. The docs-link check passed. All seven Release rekey, watcher, refusal, RTV and startup request cache tests passed again with zero skips, including both inbox WARP cases. The requested change is resolved. The separate #3091 compiler stack still needs its overlap with these helpers reconciled when it refreshes onto main.