Skip to content

Runtime: declare title-facing functions extern "win64" - #524

Closed
spidercraft wants to merge 2 commits into
Marvisak:mainfrom
spidercraft:win64-abi
Closed

spidercraft wants to merge 2 commits into
Marvisak:mainfrom
spidercraft:win64-abi

Conversation

@spidercraft

Copy link
Copy Markdown

What

Title code calls our exports, and is called by us, with the Windows x64 convention. extern "system" means that only on Windows: on Linux it is SysV, so a native Linux runtime would get the title's arguments in the wrong registers. Every title-facing function (808) is now extern "win64", which is the same convention on every x86-64 host, so nothing changes on Windows.

Callbacks we hand to the host's own APIs stay "system": the crash reporter's exception handlers, the write-watch handler, window and dialog procedures, EnumWindows, our TLS callback, the probe test's CreateThread start routine. The title fixture keeps "system" (it is only built as a Windows PE). The doc comment in modules/mod.rs states the rule.

Builds on #523 (its one commit is included; review the second).

Tested

  • cargo check --workspace --all-targets --all-features --target x86_64-pc-windows-msvc: no diagnostics (the type checker flagged every host callback; those are the ones kept as "system").
  • Linux: cargo test --workspace passes, 162 passed, 13 ignored.
  • cargo xtask policy ok.

🤖 Generated with Claude Code

spidercraft and others added 2 commits November 24, 2026 02:17
Since the world bring-up, main no longer builds on Linux: victory-gpu
names host_resource outside its cfg(windows), and victory-hle reaches
Windows-only modules (xmem, files, lifecycle, the text entry dialog).
This gates those uses only, as the smallest base for a native Linux
runtime:

- view_format and the D3D12 allocator hookup are Windows-only, like
  what they call.
- XLaunchNewGame ends the title only on Windows; the text entry dialog
  answers "dismissed" elsewhere.
- translate --validate / --pipelines refuse to start off Windows (no
  host DXIL validator or D3D12 there); translation itself runs.
- Tests that parse the test binary as a PE image, or use Windows title
  paths, are ignored off Windows with the reason.

Tested: Linux (CachyOS, rustc 1.98.1): cargo test --workspace passes
(162 passed, 13 ignored). cargo check --target x86_64-pc-windows-msvc
--all-targets gives the same diagnostics as before (none).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Title code calls our exports, and is called by us, with the Windows x64
convention. `extern "system"` is that convention only on Windows; on
Linux it is SysV, so a native Linux runtime would receive the title's
arguments in the wrong registers. `"win64"` is the same convention on
every x86-64 host, so this changes nothing on Windows.

Callbacks we hand to the host's own APIs stay `"system"` (the crash
reporter's exception handlers, the write watch handler, window and
dialog procedures, EnumWindows, our TLS callback, the probe test's
CreateThread start routine). The title fixture keeps `"system"`: it is
built only as a Windows PE.

Tested: cargo check --workspace --all-targets --all-features for
x86_64-pc-windows-msvc: no diagnostics; on Linux cargo test --workspace
passes (162 passed, 13 ignored).

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

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test-merge with current main (ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touched lower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.

@jeremygold02

Copy link
Copy Markdown
Contributor

Verification ran against PR head 53282a65ad88ff5e826585a3340ebaf806f41ca0; the PR was open at refresh.

  • Command: cargo test -j 1 -p victory-loader --test load_probe
  • Result: 2 passed: maps_a_title_dll_the_title_loads_itself and loads_binds_and_calls_probe. The probe exercises Win64 calls into a synthetic stand-in DLL and checks HLE, host, title-DLL and delay-loaded imports, plus thread attach/detach behavior.
  • Limit: this integration target is #![cfg(windows)], so it does not validate the Linux-host x86_64 ABI distinction between system and win64. No Linux cross-target check was available for this run.

This verification was AI-assisted.

@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because it is outside the project's scope (VIctory targets Windows hosts; ports, launchers and tooling for other platforms are not being taken).

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
Fayberr pushed a commit to Fayberr/Victory-United that referenced this pull request Nov 25, 2026
… calls and sanitize committed aliasing barriers

Fix two Direct3D 12 barrier validation bugs in `crates/victory-gpu/src/list.rs`:

1. Duplicate `ALL_SUBRESOURCES` transitions in a single `ResourceBarrier` call
   (D3D12 error `Marvisak#524`): `host_barrier()` flattens per-subresource transition
   barriers to `D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES`. When a title passes
   two barriers transitioning different subresources of the same texture to
   different states in one `ResourceBarrier(count, barriers)` call, `barrier()`
   previously submitted both whole-resource transitions together in a single
   `ResourceBarrier` slice. Split the translated barriers via
   `for_barrier_batches()` so no single `ResourceBarrier` call repeats a
   `Transition` (`kind == 0`) barrier for the same host `ID3D12Resource`.

2. Committed resources in `D3D12_RESOURCE_BARRIER_TYPE_ALIASING` barriers:
   `host_barrier()` previously passed raw `ID3D12Resource*` pointers for host
   textures created via `CreateCommittedResource` directly into aliasing
   barriers (and forwarded `flags`). D3D12 forbids committed resources and
   non-zero barrier flags on aliasing barriers (only placed/reserved resources
   or `NULL` are allowed). Resolve each non-null endpoint via
   `resource::host_copy()` and `aliasing_barrier()`, preserving reserved
   (`host.tiled.is_some()`) resource pointers while downgrading committed
   resources to `NULL` (yielding a valid half-open or global aliasing barrier)
   and zeroing `flags`.

Add unit tests covering batch splitting, aliasing normalization, and a real
D3D12 device test exercising committed aliasing and multi-subresource
transitions in a single `barrier()` call.
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.

4 participants