Skip to content

GPU: mesh pipelines load from the pipeline library (name their topology) - #352

Closed
rhuantac wants to merge 1 commit into
Marvisak:mainfrom
rhuantac:fix/mesh-pipelines-load-from-library
Closed

rhuantac wants to merge 1 commit into
Marvisak:mainfrom
rhuantac:fix/mesh-pipelines-load-from-library

Conversation

@rhuantac

Copy link
Copy Markdown

A mesh pipeline never loaded from the host pipeline library: LoadPipeline refused it with E_INVALIDARG (debug layer 972, "does not match the one used to create the PSO") even with the very stream it was made from, so every mesh pipeline was compiled again on every run and its store then refused (970, "already exists") — the 972/970 pair in #264 (item 3; #334 covers its items 1 and 2).

Measured with synthetic pipelines on an RTX 3060 Ti, Windows 11 26300, with and without the debug layer: compute, graphics (DXBC and DXIL) and VS/PS streams load; a mesh stream loads only with a PRIMITIVE_TOPOLOGY subobject that is not UNDEFINED. The debug layer wants it to match the mesh shader's output topology (1323), and our translation makes triangle mesh shaders only (mesh_prologue), so the stream now names TRIANGLE. Mesh pipelines get a new library name ("mesh triangles"), so entries stored without a topology are not looked up again.

Test: a_mesh_pipeline_loads_from_the_library makes a mesh pipeline twice through mesh_pipeline and requires the second to come from the library; it fails before this change and passes after (skipped without a PC dxc.exe). cargo test -p victory-gpu: 44 passed, 1 ignored. Not measured: the effect on the title's loading time.

AI use: Claude Code ran the experiments and wrote the change; I reviewed it.

🤖 Generated with Claude Code

A mesh pipeline never loaded from the host pipeline library: LoadPipeline
refused it with E_INVALIDARG (debug layer 972, "does not match the one used
to create the PSO") even with the very stream it was made from, so every
mesh pipeline was compiled again on every run and its store then refused
(970, "already exists"), the 972/970 pair in Marvisak#264.

Measured with synthetic pipelines on an RTX 3060 Ti, Windows 11 26300, with
and without the debug layer: compute, graphics (DXBC and DXIL) and VS/PS
streams load; a mesh stream loads only with a PRIMITIVE_TOPOLOGY subobject
that is not UNDEFINED. The debug layer wants it to match the mesh shader's
output topology (1323), and the translation makes triangle mesh shaders
only (mesh_prologue), so the stream now names TRIANGLE. Mesh pipelines get
a new library name ("mesh triangles"), so entries stored without a
topology are not looked up again.

a_mesh_pipeline_loads_from_the_library makes a mesh pipeline twice through
mesh_pipeline and requires the second to come from the library; it fails
before this change and passes after (skipped without a PC dxc.exe).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ifBars

ifBars commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

I reproduced the cache miss on Windows 10 with Agility SDK 620 and the WARP software adapter. I ran the same synthetic triangle mesh pipeline through Causeway's mesh-pipeline creation path 21 times, saved the library, then reopened it in a new process. Without the topology, the reopened library served 0/21 calls. With the triangle topology and the new cache key, it served all 21. On an empty cache the changed build compiled the first pipeline and loaded the next 20.

Our last story trace includes successful mesh pipeline creations, but it only reports aggregate library hits. These results establish the cache behavior. The effect on story loading time and FPS remains unmeasured.

@fuzeofficlal

Copy link
Copy Markdown
Contributor

I verified the on-disk pipeline library on exact head f77bd28 with a physical RTX 5090 (driver 616.56) and Windows build 26200. Both processes used VIctory's production HostPipeline::new path with the same synthetic triangle mesh shader and a separate VS/PS control.

Process Mesh created / loaded VS/PS created / loaded
Empty library, then save 1 / 0 1 / 0
New process, reopen saved library 0 / 1 0 / 1

The processes used the same GPU LUID and the same 3,512-byte library. The cold run had two expected name-not-found messages (971). The reopen run had no D3D12 diagnostics. This measures reuse of the synthetic PSOs across process launches.

Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
…Marvisak#358 Marvisak#89 Marvisak#331 Marvisak#86 Marvisak#83 Marvisak#211 Marvisak#260 Marvisak#275)

Conflict in crates/victory-gpu/src/descriptor/host.rs: gpu-state (Marvisak#251)
moved the dynamic-slot search into free_table(); gpu-draw (Marvisak#86) bounds
the search by the heap's spare slots instead of DYNAMIC. free_table() works
over taken.len(), which is the spare count, so the helper is kept with
gpu-draw's spare-based cursor wrap. Both sides' tests kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
Conflicts:
- crates/victory-gpu/src/pipeline/host.rs: Marvisak#352 (gpu-draw) added a
  triangle topology subobject to mesh_pipeline's stream and renamed the
  library key "mesh triangles"; Marvisak#158 generalised that function into
  stream_pipeline, shared by mesh pipelines and vertex pipelines with
  depth bounds. The topology now sits in a MeshStages stage struct (with
  Marvisak#352's explanation), not in the shared stream, as VertexStream carries
  its own topology and a stream may name one only once. Marvisak#352's cache key
  and Marvisak#158's depth-stencil choice are both kept; Marvisak#352's library test
  calls a test-only mesh_pipeline() over stream_pipeline.
- README.md: Marvisak#158's GPU: world row (depth bounds) with the Shaders row
  from shader-opcodes (64-bit image atomics no longer listed as missing).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qntic

qntic commented Nov 24, 2026

Copy link
Copy Markdown

another data point from amd, rx 6600 xt with driver 32.0.21045.5002.

a_mesh_pipeline_loads_from_the_library passes both with this pr and after removing the topology subobject entirely.

setting it to D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED instead causes E_INVALIDARG.

looks like the original issue may be driver-specific. the fix itself works fine on my card too.

justr4mzi pushed a commit to justr4mzi/VIctory that referenced this pull request Nov 24, 2026
…ts (Marvisak#780, Marvisak#352)

- Stream names PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE so D3D12 pipeline library does not refuse mesh PSO loads with E_INVALIDARG/972.
- Renames mesh library prefix to 'mesh triangles'.
- Zeros unused RTVFormats beyond NumRenderTargets to prevent cache description mismatches.
- Cleans InputLayout.pInputElementDescs to null when inputs is empty.
Closes Marvisak#780. Refs Marvisak#352, Marvisak#264.
@rhuantac

Copy link
Copy Markdown
Author

In-title check of this PR, on an RTX 3060 Ti (driver 610.88, Windows 11) with retail 1.0.2.1. Details are in #732 (comment).

test/world-stack (e0c3385) with and without this PR (f77bd28, merges cleanly), diag with VICTORY_D3D12_DEBUG=1, two runs per tree from a new empty cache, about 2 min of the intro cutscene each:

run 1: 972 / 970 run 2: 972 / 970
without #352 16 / 17 82 / 82
with #352 0 / 0 0 / 0

No id=1323 with the PR. Not measured: the effect on loading time.

AI-assisted (Claude Code); the numbers are counted from the logs.

@bittertea0323

Copy link
Copy Markdown

Real-title confirmation: made goes 512 → 72 → 1

Your fix does more than the synthetic case in #780. Measured on a 4070 SUPER, Windows 10, Series X,
try/wave64 (i.e. #189 + #940 + #729 + #737 + this) + VICTORY_WAVE64_EMULATE=emulate +
VICTORY_TEXTURE_MIP_DROP=1, diag build, 240 s per run:

run pipelines rebuilt (made) loaded from library early list
without #352 (4 runs, stable) 512–534 586 → 705 1229 → 1246
with #352, first run 72 743 1246
with #352, after warming the library 1 1272 1307

The first run alone confirms your diagnosis: mesh PSOs that never loaded before start loading, so the
rebuild count drops by 86 % on a cold library. What the later run shows is that the rest was only
cold-miss too — once the library holds the entries, exactly one pipeline still needs compiling, and
1272 load.

Knock-on effects that matter more than the counter:

  • Slowest host submission in the world stage fell from 13318 ms to 1031 ms (the 13 s submission was
    the title compiling a batch that your fix now loads).
  • building … (N being made) during the world dropped from 167–243 to 122–165, and the frame budget
    finally stopped being dominated by compilation.
  • The same 240 s run now reaches 3370 draws/frame and completes without a device removal, where
    before it died at 93 s on a 13.3 s submission.

Not measured: whether made=1 needs a second warm run on other hardware, and which single pipeline it
is (we did not enable VICTORY_D3D12_DEBUG=1 to get its name). If you want that name I can run once
with the debug layer on.

@Yaekai

Yaekai commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head f77bd28:

  • cargo test -p victory-gpu --lib: 44 passed, 0 failed (including a_mesh_pipeline_loads_from_the_library).
  • cargo clippy -p victory-gpu -- -D warnings: 0 warnings.
  • Live GTA VI (1.0.2.1, --console series-s): confirmed mesh pipelines save to and reload cleanly from the host pipeline library (loaded=2102 on warm restart). Ready to merge!

yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
…ied together

Merges Marvisak#72 Marvisak#347 Marvisak#1000 Marvisak#358 Marvisak#352 Marvisak#626 Marvisak#1152 Marvisak#1129 Marvisak#1203 Marvisak#24 Marvisak#642 Marvisak#427 Marvisak#485
Marvisak#550 Marvisak#174 Marvisak#1279 onto main (ffe310e), each head unchanged, no conflicts.

One change of mine: three of the PRs each add a `mod tests` at the end of
pipeline/host.rs, so the merge defines `tests` three times (E0428). The
second and third are named `library_tests` and `blend_tests`; nothing else
changes.

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(367 passed, 6 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Bullet18x

Copy link
Copy Markdown
Contributor

RTX 5090 A/B of the pipeline-library messages: this PR vs #1041 vs plain main, same machine, same protocol.

Machine: RTX 5090 32 GB, driver 621.40 (32.0.16.2114), Ryzen 9 9950X3D, 64 GB, Windows 11 Pro 10.0.28000 (in-box D3D12 10.0.28000.3365, Graphics Tools installed).
Builds: each PR's single commit applied on main ffe310e (f77bd28 for this PR, 4111946 for #1041; each applies cleanly alone, the two conflict in pipeline/host.rs), cargo build --profile diag -p victory --features diagnostics.
Protocol per build: empty pipeline library (host-pipelines.bin and early-pipelines.txt removed, shader translations kept), run 1 to fill it, then run 2 with VICTORY_D3D12_DEBUG=1; debug-layer messages counted in run 2. Both runs: VICTORY_KEYS=8:Enter,20:Enter,35:Enter, VICTORY_D3D12_DRED=1, victory.exe run <dump>\game_scarlett_master.exe --execute.

Build 972 (desc does not match) 970 (already exists) 971 (not stored)
main ffe310e 350 358 256
+ #352 (this PR) 0 5 386
+ #1041 288 211 186

Not tested: AMD / Intel, more than one run per build, the two PRs together (they conflict).

No game data, title-content log lines or screenshots attached. AI use: Claude Code (Claude Opus 5.5) built, ran and counted the messages; I checked the results.

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.

8 participants