Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/experiments/startup-pso-recipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@ reaches the append path while the file is owned keeps the PSO it already created
cache write; a reader denied by that handle also falls back to the unchanged creation path.
Neither side can seek to an end offset that another writer selected.

## First use during recording

A translated draw reserves its PSO after the existing eligibility and descriptor heap checks. The
recording thread retains the device, root signature, shader blobs and input layout for preparation.
It releases the draw lock while it creates the PSO, prepares rectangle geometry, replays recipes and
writes any new recipe record. Appends from threads in the same process take a separate mutex.

Recordings that need the same PSO wait for its reservation to finish and recheck the cache. A
recipe replay runs once per bound pipeline, device, ready translation and ordered RTV/DSV
signature. The owner publishes successful recipe PSOs and then uses ordinary creation for any
requested state that still needs a PSO. The cache retains a null result after a driver failure.
An interrupted attempt wakes waiters so one can retry. Rectangle geometry keeps its own one-shot
result per ready translation. Cached PSOs stay alive for closed lists that may be submitted later.

Unrelated recordings and queue submissions can take the draw lock during preparation. The draw
that initiated creation and any draw waiting for the same state still finish synchronously. Each
list has one recording owner, with Close and Reset synchronized by the caller.

The unlock fixture pauses a cold PSO create and checks that an independent draw and a closed
list submission complete before the gate opens. The concurrent fixture also checks same-state
coalescing, terminal failure, retry after interruption, recipe hits and mismatch fallback. It
compares fenced pixels across different RTV/DSV signatures and distinct blend, depth and raster
states on a shared shader translation.

```powershell
cmake --build --preset dev --target d3d12_xs_shim startup_indirect_draw_indexed
ctest --preset dev --no-tests=error -j 1 -V -R '^startup_graphics_pso_load_(unlock|concurrent)_(warp|hardware)$'
```

## Scope and limits

This is state reconstruction, not a D3D12 pipeline library. A replayed record still calls
Expand Down
29 changes: 20 additions & 9 deletions docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -1073,12 +1073,12 @@ created during the run is translated within seconds and the runtime picks it up
instead of on the next run. `compile_dxil --watch` uses the same ready-marker priority, batch size
and rescan cadence. The runtime
looks for an absent manifest again 1 second after the first miss and doubles the wait with each
further miss up to 32 seconds. A translation published during the run is therefore
used on a draw or Dispatch at most 32 seconds later, and a key that never gets a translation costs one
cache lookup every 32 seconds instead of one per second (each lookup holds `draw_lock`, which every draw
and Dispatch takes). The cache persists: a later run reads every published `<key>.txt` and translates only new
requests. The watcher's first pass retries every earlier failure once, so a translator update reaches
requests that failed in an earlier run; after that, a request whose `<key>.fail` is newer than its
further miss up to 32 seconds. A draw or Dispatch can pick up a newly published translation once its retry
is due. A key that never gets a translation costs at most one cache lookup every 32 seconds once the wait
reaches its cap. Compute manifest lookups hold `draw_lock`. The cache persists across runs, so a later
run reads published `<key>.txt` files and translates only new requests. The watcher's first pass retries
every earlier failure once, so a translator update reaches requests that failed in an earlier run.
After that, a request whose `<key>.fail` is newer than its
ready marker is not retried during the run (the runtime writes each request once and never rewrites
it). The one-shot `--pending` scan retries every failure unless `--skip-failed` (`-s`) or
`X2W_SKIP_FAILED=1` is set, which skips requests whose `<key>.fail` is already up to date with their
Expand Down Expand Up @@ -1107,6 +1107,18 @@ print the same results and write the same failures as one, an unexpected transla
`startup_run_ps1` checks that `-Translate` starts the watcher on the cache and stops it together
with a child process.

### Preparing graphics translations in the stand-in

The initiating draw or pipeline creation call prepares a graphics translation synchronously with
`draw_lock` released. Preparation includes request writes, manifest and bytecode reads, eligible native
compilation, and translated root signature creation. Calls that need the same pending key and phase
wait with the lock released. Other keys and guest queue submissions can proceed. The initiating call
publishes the result under the lock. Usable published translations take precedence over native
compilation unless native-only mode is enabled. The manifest retry schedule also applies when
preparation is interrupted or the device changes, including in native-only mode. An absent manifest
can use the existing direct-draw fallback. Translated pipeline state object creation and command
recording hold `draw_lock`.

### Translating compute programs in the stand-in

With `X2W_NATIVE_SHADERS=<directory of dxcompiler.dll and dxil.dll>` (`run.ps1 -Render -NativeShaders <dir>`),
Expand Down Expand Up @@ -1134,9 +1146,8 @@ launchers' default `X2W_NATIVE_SHADERS_ONLY=1`, `load_compute_translation` retur
refusals of a process are logged as
`compute pipeline <key> not translated natively: <reason>`. A refused key is left to the
published translations, so `-Translate` can run beside it for those pipelines. A direct module requires
shader model 6.6 and wave32. The in-process
translation is tried once per key and before a published `<key>.txt`. It covers compute only; graphics
pipelines still need a published translation.
shader model 6.6 and wave32. In-process compute translation is tried once per key and before a published
`<key>.txt`.

Published compute translations from `compile_dxil --requests` and `--watch` carry a `native 1` line in the
`x2w-manifest 2` manifest. The stand-in requires the current native output revision. An unmarked manifest
Expand Down
Loading
Loading