Renderer port 1 never places the 32-bit heap (Scattered); arrange from ab113ff is never reached - RTX 4070 Ti, Series S and Series X #23

Closed
opened 2026-11-27 06:06:59 +00:00 by github-bot · 2 comments
Owner

@⁠Spaghetih on GitHub · 2026-11-26 17:23 UTC · original

Machine: Windows 11, i7-13700KF, 32 GB, RTX 4070 Ti 12 GB. Game build 1.0.2.1. Built from source at 472e841 (release + diagnostics), merged into a local branch that only adds a host FidelityFX path; the memory code is yours.

What happens

With VICTORY_PORT_CONSTANTS=1 (and VICTORY_PORT_CBV=1), renderer port 1 never places the 32-bit graphics heap. Every run logs once:

WARN victory_gpu::port: renderer port 1: title memory not in place, a copy as before start=0x15090000 len=182452224 window=false why="not one stretch of a section: Scattered"

and from then on, every second:

renderer port 1 (VICTORY_PORT_CONSTANTS=1): 0 regions of the title's graphics memory in place (0 MB), 0 title buffers and windows placed in them ...; since the start refused: 1 not one stretch of ...
renderer port 5 (VICTORY_PORT_CBV=1) per frame: 0 tables' constant buffers read by the card in place (0.0 KB not copied, ...); copied as before: 8289 not in place, ...

So port 5 places nothing either. Same result in all of these (5 runs, 2.5-5 min each, no device removal):

  • --console series-s, VICTORY_THIN=1, VICTORY_JOIN_PARTS=8, otherwise Play-VIctory.cmd's switches
  • --console series-s, VICTORY_THIN=0, VICTORY_JOIN_PARTS=0
  • your launcher's own settings: --console series-x, THIN=0, JOIN_PARTS=0, TEXTURE_GUARD=0, AMBIENT=constant:0.8, both ports on

The heap's start address changes between runs (0x15090000, 0x4b40000, 0x4f80000, 0x37030000); the length is always 182452224.

arrange (ab113ff) never runs

arrange logs "... given their section's slices in address order" when it moves pages. That line never shows. I added a line at each of its early returns (no reservation noted for a 32-bit mapping, at debug; pages with no section; section size different from the reservation's or pages of other sections, at info) with VICTORY_LOG=info,victory_hle::modules::xmem=debug. None of them shows either, so arrange is not reached for this heap at all.

One thing I noticed: XMemMapPhysicalPagesScatter with side_by_side() > 1 goes to scatter(&wanted) and does not pass through XMemMapPhysicalPages, where arrange is called. I made the scatter path call arrange on each run of consecutive addresses first. That changed nothing here, so the heap is reserved or mapped through yet another path (or the reservation is never pushed to LOW_RESERVATIONS: it is only noted for placeholder && constrained && ADDRESS_32BIT).

What would help

  • Did port 1 place the heap on your machine after ab113ff ("N regions ... in place" with N > 0)? If yes, which --console and switches?
  • If someone can say which call maps the 185 MB heap's pages on their side (XMemMapPhysicalPages, the scatter variant, map_alias/CopyPageMappingsBatchX, ...), I can check whether it is the same here.

Happy to re-run with more logging.

**@⁠Spaghetih** on GitHub · 2026-11-26 17:23 UTC · [original](https://github.com/DoubleGhosty/cool_fox/issues/23) **Machine:** Windows 11, i7-13700KF, 32 GB, **RTX 4070 Ti 12 GB**. Game build 1.0.2.1. Built from source at `472e841` (release + diagnostics), merged into a local branch that only adds a host FidelityFX path; the memory code is yours. ## What happens With `VICTORY_PORT_CONSTANTS=1` (and `VICTORY_PORT_CBV=1`), renderer port 1 never places the 32-bit graphics heap. Every run logs once: ``` WARN victory_gpu::port: renderer port 1: title memory not in place, a copy as before start=0x15090000 len=182452224 window=false why="not one stretch of a section: Scattered" ``` and from then on, every second: ``` renderer port 1 (VICTORY_PORT_CONSTANTS=1): 0 regions of the title's graphics memory in place (0 MB), 0 title buffers and windows placed in them ...; since the start refused: 1 not one stretch of ... renderer port 5 (VICTORY_PORT_CBV=1) per frame: 0 tables' constant buffers read by the card in place (0.0 KB not copied, ...); copied as before: 8289 not in place, ... ``` So port 5 places nothing either. Same result in all of these (5 runs, 2.5-5 min each, no device removal): - `--console series-s`, `VICTORY_THIN=1`, `VICTORY_JOIN_PARTS=8`, otherwise `Play-VIctory.cmd`'s switches - `--console series-s`, `VICTORY_THIN=0`, `VICTORY_JOIN_PARTS=0` - **your launcher's own settings**: `--console series-x`, `THIN=0`, `JOIN_PARTS=0`, `TEXTURE_GUARD=0`, `AMBIENT=constant:0.8`, both ports on The heap's start address changes between runs (`0x15090000`, `0x4b40000`, `0x4f80000`, `0x37030000`); the length is always 182452224. ## `arrange` (ab113ff) never runs `arrange` logs `"... given their section's slices in address order"` when it moves pages. That line never shows. I added a line at each of its early returns (no reservation noted for a 32-bit mapping, at `debug`; pages with no section; section size different from the reservation's or pages of other sections, at `info`) with `VICTORY_LOG=info,victory_hle::modules::xmem=debug`. **None of them shows either**, so `arrange` is not reached for this heap at all. One thing I noticed: `XMemMapPhysicalPagesScatter` with `side_by_side() > 1` goes to `scatter(&wanted)` and does not pass through `XMemMapPhysicalPages`, where `arrange` is called. I made the scatter path call `arrange` on each run of consecutive addresses first. That changed nothing here, so the heap is reserved or mapped through yet another path (or the reservation is never pushed to `LOW_RESERVATIONS`: it is only noted for `placeholder && constrained && ADDRESS_32BIT`). ## What would help - Did port 1 place the heap on your machine after ab113ff ("N regions ... in place" with N > 0)? If yes, which `--console` and switches? - If someone can say which call maps the 185 MB heap's pages on their side (`XMemMapPhysicalPages`, the scatter variant, `map_alias`/`CopyPageMappingsBatchX`, ...), I can check whether it is the same here. Happy to re-run with more logging.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 06:06:59 +00:00
Author
Owner

@⁠Spaghetih on GitHub · 2026-11-26 17:36 UTC · original

Found it, and port 1 now places the heap here.

Cause

The title reserves its 185 MB heap with kind=0x42000 flags=0x7 (32-bit, no commit). XMemVirtualAlloc only pushes a reservation to LOW_RESERVATIONS when placeholder && constrained && ADDRESS_32BIT, and placeholder (kind & PAGES_64K == PAGES_64K && kind & MEM_COMMIT == 0) is false for 0x42000. So the reservation was never noted and arrange returned at its first let ... else on every mapping.

What the title does (logged with port 1 on, sizes of 16 MB or more):

XMemVirtualAlloc size=193986560 kind=0x42000 flags=0x7 at=0xfeb0000 placeholder=false constrained=true
XMemAllocatePhysicalPages size=193986560 pages=2960 flags=0x280          (one section)
XMemMapPhysicalPages at=0x124b0000 pages=752
XMemMapPhysicalPages at=0x153b0000 pages=1600
XMemMapPhysicalPages at=0xfeb0000  pages=160
XMemMapPhysicalPages at=0x109b0000 pages=432

Fix

Note any reservation without commit of 16 MB or more asked below 4 GiB, not only 64 KiB placeholders:

let reserved_only = kind & MEM_COMMIT == 0 && (placeholder || size >= 16 << 20);
if !at.is_null() && reserved_only && constrained && flags & ADDRESS_32BIT != 0 {
    LOW_RESERVATIONS.lock().unwrap_or_else(|e| e.into_inner()).push((at as usize, size));
}

(I also made XMemMapPhysicalPagesScatter's side-by-side path call arrange on runs of consecutive addresses, since it does not go through XMemMapPhysicalPages; not needed for this heap, which is mapped by XMemMapPhysicalPages.)

Result (RTX 4070 Ti, Series S, THIN, 5 min)

the title's 32-bit graphics pages given their section's slices in address order ... moved=752 / 1600 / 160 / 16 / 416, not_fresh=0
renderer port 1: title memory in place, read and written by the card where the title has it start=0x40390000 len=182452224
1 regions of the title's graphics memory in place (185 MB)

Data sent up per frame dropped from 38-48 MB to 25 MB. Frame rate unchanged (17.3 fps median, prep 49 ms) on this machine. No device removal and no exception in 5 minutes (issue #15 saw one about 3 minutes in with both ports, so this is not a long enough test to rule it out).

Port 5 on NVIDIA

Port 5 still places nothing here: copied as before: 962 not in place, 7404 not on 16 bytes. The second counter is misleading: constant_raw_at returns false because self.twin(index) is None: on NVIDIA the view heap is capped at 1,000,000 views, so raw twins are off (host view heaps hold 1000000 views ... raw_twins=false), and copied(false) counts that as "not on 16 bytes". So port 5 cannot place anything on NVIDIA as it stands. This may also be behind #15's missing road with PORT_CBV=1 alone on an RTX 4060 Ti (shaders translated to read constants through raw twins on a host that makes none), though I have not checked that.

**@⁠Spaghetih** on GitHub · 2026-11-26 17:36 UTC · [original](https://github.com/DoubleGhosty/cool_fox/issues/23#issuecomment-7199319599) Found it, and port 1 now places the heap here. ## Cause The title reserves its 185 MB heap with **`kind=0x42000 flags=0x7`** (32-bit, no commit). `XMemVirtualAlloc` only pushes a reservation to `LOW_RESERVATIONS` when `placeholder && constrained && ADDRESS_32BIT`, and `placeholder` (`kind & PAGES_64K == PAGES_64K && kind & MEM_COMMIT == 0`) is **false** for `0x42000`. So the reservation was never noted and `arrange` returned at its first `let ... else` on every mapping. What the title does (logged with port 1 on, sizes of 16 MB or more): ``` XMemVirtualAlloc size=193986560 kind=0x42000 flags=0x7 at=0xfeb0000 placeholder=false constrained=true XMemAllocatePhysicalPages size=193986560 pages=2960 flags=0x280 (one section) XMemMapPhysicalPages at=0x124b0000 pages=752 XMemMapPhysicalPages at=0x153b0000 pages=1600 XMemMapPhysicalPages at=0xfeb0000 pages=160 XMemMapPhysicalPages at=0x109b0000 pages=432 ``` ## Fix Note any reservation without commit of 16 MB or more asked below 4 GiB, not only 64 KiB placeholders: ```rust let reserved_only = kind & MEM_COMMIT == 0 && (placeholder || size >= 16 << 20); if !at.is_null() && reserved_only && constrained && flags & ADDRESS_32BIT != 0 { LOW_RESERVATIONS.lock().unwrap_or_else(|e| e.into_inner()).push((at as usize, size)); } ``` (I also made `XMemMapPhysicalPagesScatter`'s side-by-side path call `arrange` on runs of consecutive addresses, since it does not go through `XMemMapPhysicalPages`; not needed for this heap, which is mapped by `XMemMapPhysicalPages`.) ## Result (RTX 4070 Ti, Series S, THIN, 5 min) ``` the title's 32-bit graphics pages given their section's slices in address order ... moved=752 / 1600 / 160 / 16 / 416, not_fresh=0 renderer port 1: title memory in place, read and written by the card where the title has it start=0x40390000 len=182452224 1 regions of the title's graphics memory in place (185 MB) ``` Data sent up per frame dropped from 38-48 MB to 25 MB. **Frame rate unchanged** (17.3 fps median, prep 49 ms) on this machine. No device removal and no exception in 5 minutes (issue #15 saw one about 3 minutes in with both ports, so this is not a long enough test to rule it out). ## Port 5 on NVIDIA Port 5 still places nothing here: `copied as before: 962 not in place, 7404 not on 16 bytes`. The second counter is misleading: `constant_raw_at` returns `false` because **`self.twin(index)` is `None`**: on NVIDIA the view heap is capped at 1,000,000 views, so raw twins are off (`host view heaps hold 1000000 views ... raw_twins=false`), and `copied(false)` counts that as "not on 16 bytes". So port 5 cannot place anything on NVIDIA as it stands. This may also be behind #15's missing road with `PORT_CBV=1` alone on an RTX 4060 Ti (shaders translated to read constants through raw twins on a host that makes none), though I have not checked that.
Author
Owner

@⁠DoubleGhosty on GitHub · 2026-11-26 20:30 UTC · original

Resolved in commit 46714eb: Low-address placeholder tracking (using VirtualAlloc MEM_RESERVE_PLACEHOLDER and MapViewOfFile3) ensures Renderer Port 1 in-place mapping succeeds consistently on Windows.

**@⁠DoubleGhosty** on GitHub · 2026-11-26 20:30 UTC · [original](https://github.com/DoubleGhosty/cool_fox/issues/23#issuecomment-7202773591) Resolved in commit 46714eb: Low-address placeholder tracking (using VirtualAlloc MEM_RESERVE_PLACEHOLDER and MapViewOfFile3) ensures Renderer Port 1 in-place mapping succeeds consistently on Windows.
This discussion has been locked. Commenting is limited to contributors.
No description provided.