Wine/vkd3d: deferred uploads are skipped because VirtualQuery() reports mapped memory as MEM_FREE #128

Closed
opened 2026-11-26 03:51:18 +00:00 by github-bot · 6 comments
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:45 UTC · original

Under Wine + vkd3d-proton, every deferred copy into a host-mapped destination is skipped, because the guard in copy_mapped checks VirtualQuery(...).State == MEM_COMMIT and vkd3d-proton's mapped memory is not in Wine's virtual-memory bookkeeping.

Environment

  • Arch Linux x86_64; Wine 11.22; vkd3d-proton 3.1 (system vkd3d-proton-bin); AMD Radeon RX 9060 XT (RADV 26.3.1).
  • Windows build of main 7d33c46: cargo xwin build/test --release --target x86_64-pc-windows-msvc (cargo-xwin 0.24.1, rustc 1.98.1).
  • No game data, no victory.toml (synthetic tests only).

Reproducer

victory_gpu-*.exe resource::tests::buffer_data_reaches_the_host_texture fails:

assertion `left == right` failed: row 0
  left: [0, 0, 0, 0, ...]
 right: [0, 1, 2, 3, ...]

The rest of the crate's host-GPU tests pass: 36 passed, 3 failed (the other two are environment gaps, listed below).

Cause

HostList::run_deferred runs Step::Copy as

copy_mapped(dst as *mut u8, src as *const u8, len, true)   // crates/victory-gpu/src/host.rs:1120

and copy_mapped starts with

if len == 0 || title_dst && !crate::texture::committed(dst, len) { return; }   // host.rs:1214

texture::committed (crates/victory-gpu/src/texture.rs:260) walks the range with VirtualQuery and requires MEM_COMMIT. In this environment VirtualQuery on the staging upload buffer that Map handed out returns:

n=48 state=0x10000 (MEM_FREE) type=0x0 protect=0x1 base=0x7fdebf000000 size=0xb7e0000

so the copy is skipped and the texture keeps zeros. The address is a vkd3d-proton allocation (large mmap arena) that Wine's VirtualQuery reports as free.

Scope

copy_texture_region's staging path uses defer_copy (crates/victory-gpu/src/list.rs:529), and copy_buffer_region / copy_resource use the same Step::Copy arm, so any deferred copy whose destination is host-mapped memory is exposed. On Windows the same guard reads MEM_COMMIT; this shows up only under Wine/vkd3d.

Confirmed fix direction

Changing the Step::Copy call locally to pass title_dst = false makes the test pass under Wine:

test resource::tests::buffer_data_reaches_the_host_texture ... ok

The flag also drives watch::writing, so the real fix should distinguish a destination we mapped ourselves (the staging buffer from HostList::upload / Host::upload_buffer, known committed) from title memory that needs the guard — a per-step flag or a registry of our mapped ranges — rather than flipping it globally.

Other failures in the same run (environment, not this issue)

  • indirect::tests::argument_clamp_builds: Wine's builtin d3dcompiler_47 cannot compile the clamp shader — E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'. Under Wine this also drops indirect execution at runtime (clamp() returns None); a native Microsoft d3dcompiler_47.dll in the prefix is the likely workaround.
  • pipeline::library::tests::a_rejected_blob_gives_an_empty_library: vkd3d-proton returns D3D12_ERROR_DRIVER_VERSION_MISMATCH (0x887E0002) for the damaged blob (expected) and E_INVALIDARG (0x80070057) for the empty library, so open() returns None. The runtime handles that (no pipeline cache), only the test's expectation differs.

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:45 UTC · [original](https://github.com/Marvisak/VIctory/issues/128) Under Wine + vkd3d-proton, every deferred copy into a host-mapped destination is skipped, because the guard in `copy_mapped` checks `VirtualQuery(...).State == MEM_COMMIT` and vkd3d-proton's mapped memory is not in Wine's virtual-memory bookkeeping. ### Environment - Arch Linux x86_64; Wine 11.22; vkd3d-proton 3.1 (system `vkd3d-proton-bin`); AMD Radeon RX 9060 XT (RADV 26.3.1). - Windows build of `main` `7d33c46`: `cargo xwin build/test --release --target x86_64-pc-windows-msvc` (cargo-xwin 0.24.1, rustc 1.98.1). - No game data, no `victory.toml` (synthetic tests only). ### Reproducer `victory_gpu-*.exe resource::tests::buffer_data_reaches_the_host_texture` fails: ``` assertion `left == right` failed: row 0 left: [0, 0, 0, 0, ...] right: [0, 1, 2, 3, ...] ``` The rest of the crate's host-GPU tests pass: **36 passed, 3 failed** (the other two are environment gaps, listed below). ### Cause `HostList::run_deferred` runs `Step::Copy` as ```rust copy_mapped(dst as *mut u8, src as *const u8, len, true) // crates/victory-gpu/src/host.rs:1120 ``` and `copy_mapped` starts with ```rust if len == 0 || title_dst && !crate::texture::committed(dst, len) { return; } // host.rs:1214 ``` `texture::committed` (`crates/victory-gpu/src/texture.rs:260`) walks the range with `VirtualQuery` and requires `MEM_COMMIT`. In this environment `VirtualQuery` on the staging upload buffer that `Map` handed out returns: ``` n=48 state=0x10000 (MEM_FREE) type=0x0 protect=0x1 base=0x7fdebf000000 size=0xb7e0000 ``` so the copy is skipped and the texture keeps zeros. The address is a vkd3d-proton allocation (large mmap arena) that Wine's `VirtualQuery` reports as free. ### Scope `copy_texture_region`'s staging path uses `defer_copy` (`crates/victory-gpu/src/list.rs:529`), and `copy_buffer_region` / `copy_resource` use the same `Step::Copy` arm, so any deferred copy whose destination is host-mapped memory is exposed. On Windows the same guard reads `MEM_COMMIT`; this shows up only under Wine/vkd3d. ### Confirmed fix direction Changing the `Step::Copy` call locally to pass `title_dst = false` makes the test pass under Wine: ``` test resource::tests::buffer_data_reaches_the_host_texture ... ok ``` The flag also drives `watch::writing`, so the real fix should distinguish a destination we mapped ourselves (the staging buffer from `HostList::upload` / `Host::upload_buffer`, known committed) from title memory that needs the guard — a per-step flag or a registry of our mapped ranges — rather than flipping it globally. ### Other failures in the same run (environment, not this issue) - `indirect::tests::argument_clamp_builds`: Wine's builtin `d3dcompiler_47` cannot compile the clamp shader — `E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'`. Under Wine this also drops indirect execution at runtime (`clamp()` returns `None`); a native Microsoft `d3dcompiler_47.dll` in the prefix is the likely workaround. - `pipeline::library::tests::a_rejected_blob_gives_an_empty_library`: vkd3d-proton returns `D3D12_ERROR_DRIVER_VERSION_MISMATCH` (`0x887E0002`) for the damaged blob (expected) and `E_INVALIDARG` (`0x80070057`) for the empty library, so `open()` returns `None`. The runtime handles that (no pipeline cache), only the test's expectation differs. No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:18 +00:00
Author
Owner

@⁠arthurprudenteres on GitHub · 2026-11-24 00:55 UTC · original

I'd like to take this issue. I will focus on deferred host upload destinations in crates/victory-gpu/src/host.rs and list.rs, with synthetic copy coverage in the GPU crate. The reported texture-upload path uses a staging allocation owned by the host list. I will verify how the buffer-copy callers choose their destinations and preserve the existing commitment checks and write tracking for title-memory destinations. I will post Windows and Wine/vkd3d validation results separately.

**@⁠arthurprudenteres** on GitHub · 2026-11-24 00:55 UTC · [original](https://github.com/Marvisak/VIctory/issues/128#issuecomment-7118571319) I'd like to take this issue. I will focus on deferred host upload destinations in `crates/victory-gpu/src/host.rs` and `list.rs`, with synthetic copy coverage in the GPU crate. The reported texture-upload path uses a staging allocation owned by the host list. I will verify how the buffer-copy callers choose their destinations and preserve the existing commitment checks and write tracking for title-memory destinations. I will post Windows and Wine/vkd3d validation results separately.
Author
Owner

@⁠arthurprudenteres on GitHub · 2026-11-24 01:02 UTC · original

The texture staging allocation already has the destination-specific operation it needs: HostList::defer_fill writes to mapped upload memory before execution and uses the same source-read path as defer_copy. The two buffer-to-buffer call sites obtain their destinations from title resources and should keep defer_copy.

I am testing the existing buffer-to-texture readback fixture on Windows against a validation-only forced negative commitment result. The upstream test build also has the duplicate module reported in #129; the name change will be local to validation. I do not have a Wine/vkd3d runtime on this Windows machine.

**@⁠arthurprudenteres** on GitHub · 2026-11-24 01:02 UTC · [original](https://github.com/Marvisak/VIctory/issues/128#issuecomment-7118697459) The texture staging allocation already has the destination-specific operation it needs: `HostList::defer_fill` writes to mapped upload memory before execution and uses the same source-read path as `defer_copy`. The two buffer-to-buffer call sites obtain their destinations from title resources and should keep `defer_copy`. I am testing the existing buffer-to-texture readback fixture on Windows against a validation-only forced negative commitment result. The upstream test build also has the duplicate module reported in #129; the name change will be local to validation. I do not have a Wine/vkd3d runtime on this Windows machine.
Author
Owner

@⁠LaunchDoesntCode on GitHub · 2026-11-24 01:03 UTC · original

Wine/vkd3d validation for the defer_fill direction described above, since that runtime is the missing piece.

Setup: main at d2a4bae, cross-built for x86_64-pc-windows-msvc on Linux Mint, run under Proton 10.0 (wine-10.0, its vkd3d-proton and DXVK dxgi), NVIDIA RTX 5090, driver 595.99.2.

Change tested: only the buffer-to-texture staging path in copy_texture_region (crates/victory-gpu/src/list.rs) switched from defer_copy to defer_fill; the two buffer-to-buffer call sites untouched.

cargo test -p victory-gpu --lib:

passed failed
main 40 3
with the change 41 2

resource::tests::buffer_data_reaches_the_host_texture goes from failing (row 0 all zeros) to passing. The two that still fail are the environment gaps already listed in this issue (indirect::tests::argument_clamp_builds, pipeline::library::tests::a_rejected_blob_gives_an_empty_library).

The one-line commit is at LaunchDoesntCode/VIctory@d5447c8 (branch fix/wine-deferred-copy) if it is useful to pick up or compare against. I have not opened a pull request since this issue is claimed; happy to if that helps.

Not tested here: Windows, and the title itself. No game data used. AI-assisted (Claude Code).

**@⁠LaunchDoesntCode** on GitHub · 2026-11-24 01:03 UTC · [original](https://github.com/Marvisak/VIctory/issues/128#issuecomment-7118712118) Wine/vkd3d validation for the `defer_fill` direction described above, since that runtime is the missing piece. **Setup:** `main` at `d2a4bae`, cross-built for `x86_64-pc-windows-msvc` on Linux Mint, run under Proton 10.0 (wine-10.0, its vkd3d-proton and DXVK dxgi), NVIDIA RTX 5090, driver 595.99.2. **Change tested:** only the buffer-to-texture staging path in `copy_texture_region` (`crates/victory-gpu/src/list.rs`) switched from `defer_copy` to `defer_fill`; the two buffer-to-buffer call sites untouched. `cargo test -p victory-gpu --lib`: | | passed | failed | |---|---:|---:| | `main` | 40 | 3 | | with the change | 41 | 2 | `resource::tests::buffer_data_reaches_the_host_texture` goes from failing (row 0 all zeros) to passing. The two that still fail are the environment gaps already listed in this issue (`indirect::tests::argument_clamp_builds`, `pipeline::library::tests::a_rejected_blob_gives_an_empty_library`). The one-line commit is at `LaunchDoesntCode/VIctory@d5447c8` (branch `fix/wine-deferred-copy`) if it is useful to pick up or compare against. I have not opened a pull request since this issue is claimed; happy to if that helps. Not tested here: Windows, and the title itself. No game data used. AI-assisted (Claude Code).
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:04 UTC · original

Extra evidence that this is specific to vkd3d-proton's memory mapping, not to mapped memory in general:

  • With Wine's built-in D3D12 (fresh prefix, no vkd3d-proton), the whole victory_gpu suite passes 52/52, including resource::tests::buffer_data_reaches_the_host_texture.
  • With vkd3d-proton 3.1, that test fails as described, and adding a native Microsoft d3dcompiler_47 (to remove the unrelated compiler gap) does not change it — 50 passed / 2 failed (this one plus the pipeline-library one).

So VirtualQuery does report MEM_COMMIT for Wine's own D3D12 mappings; it is vkd3d-proton's Map memory that reads as MEM_FREE. The same suite also confirms the test passes as soon as the guard is skipped (title_dst = false).

AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 01:04 UTC · [original](https://github.com/Marvisak/VIctory/issues/128#issuecomment-7118720540) Extra evidence that this is specific to vkd3d-proton's memory mapping, not to mapped memory in general: - With **Wine's built-in D3D12** (fresh prefix, no vkd3d-proton), the whole `victory_gpu` suite passes **52/52**, including `resource::tests::buffer_data_reaches_the_host_texture`. - With **vkd3d-proton 3.1**, that test fails as described, and adding a native Microsoft `d3dcompiler_47` (to remove the unrelated compiler gap) does not change it — 50 passed / 2 failed (this one plus the pipeline-library one). So `VirtualQuery` does report `MEM_COMMIT` for Wine's own D3D12 mappings; it is vkd3d-proton's `Map` memory that reads as `MEM_FREE`. The same suite also confirms the test passes as soon as the guard is skipped (`title_dst = false`). AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠ghost on GitHub · 2026-11-24 07:35 UTC · original

An NVIDIA data point for this (the report above is on AMD/RADV), with two of the open fixes.

Setup:

  • GTX 1660 Ti Laptop (Turing), current NVIDIA driver, CachyOS.
  • Wine 11.22 (built-in d3dcompiler_47), vkd3d-proton 3.1.
  • victory-gpu tests cross-built for x86_64-pc-windows-gnu (rustc 1.98.1), main at d2a4bae.

resource::tests::buffer_data_reaches_the_host_texture:

  • main: fails with zeros, exactly as reported.
  • main + #680 (af22e5d): passes.
  • main + #322 (b58d198): passes.

Whole victory-gpu suite under this setup:

  • main: 3 failures. This test, the argument clamp (#170), and pipeline::library::tests::a_rejected_blob_gives_an_empty_library.
  • main + #190 + #680 + #347: 43 passed, 0 failed, 1 ignored. #347 (197c7ac) fixes the pipeline-library test on vkd3d-proton.

AI-assisted (Claude Code); the runs are mine.

**@⁠ghost** on GitHub · 2026-11-24 07:35 UTC · [original](https://github.com/Marvisak/VIctory/issues/128#issuecomment-7125149288) An NVIDIA data point for this (the report above is on AMD/RADV), with two of the open fixes. **Setup:** - GTX 1660 Ti Laptop (Turing), current NVIDIA driver, CachyOS. - Wine 11.22 (built-in `d3dcompiler_47`), vkd3d-proton 3.1. - `victory-gpu` tests cross-built for `x86_64-pc-windows-gnu` (rustc 1.98.1), `main` at `d2a4bae`. **`resource::tests::buffer_data_reaches_the_host_texture`:** - `main`: fails with zeros, exactly as reported. - `main` + #680 (`af22e5d`): passes. - `main` + #322 (`b58d198`): passes. **Whole `victory-gpu` suite under this setup:** - `main`: 3 failures. This test, the argument clamp (#170), and `pipeline::library::tests::a_rejected_blob_gives_an_empty_library`. - `main` + #190 + #680 + #347: **43 passed, 0 failed, 1 ignored**. #347 (`197c7ac`) fixes the pipeline-library test on vkd3d-proton. _AI-assisted (Claude Code); the runs are mine._
Author
Owner

@⁠arthurprudenteres on GitHub · 2026-11-25 00:28 UTC · original

I confirmed the staging path distinction independently on Windows 11 build 26300.9974, Rust 1.98.1. In the synthetic buffer-to-texture readback, forcing the title-destination commitment check to reject the staging address left row 0 all zeros on WARP (exit 101). Changing only the upload call to defer_fill restored the expected bytes on WARP and RTX 5060 Ti (621.24), both exit 0. With the forced result removed, the diagnostics workspace on the original base plus the local test-module rename passed 267 tests (4 ignored).

I found #680 already merged with that same upload routing. The Proton runs above cover that runtime, so this is supplemental Windows evidence. I did not open a duplicate PR. AI-assisted.

**@⁠arthurprudenteres** on GitHub · 2026-11-25 00:28 UTC · [original](https://github.com/Marvisak/VIctory/issues/128#issuecomment-7148541565) I confirmed the staging path distinction independently on Windows 11 build 26300.9974, Rust 1.98.1. In the synthetic buffer-to-texture readback, forcing the title-destination commitment check to reject the staging address left row 0 all zeros on WARP (exit 101). Changing only the upload call to `defer_fill` restored the expected bytes on WARP and RTX 5060 Ti (621.24), both exit 0. With the forced result removed, the diagnostics workspace on the original base plus the local test-module rename passed 267 tests (4 ignored). I found #680 already merged with that same upload routing. The Proton runs above cover that runtime, so this is supplemental Windows evidence. I did not open a duplicate PR. AI-assisted.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#128
No description provided.