Repository navigation
Under Wine: title pages shown with the host's mmap, and renderer port 1's heap opened in place (VICTORY_WINE_MAP, VICTORY_PORT_HOME) - #2455
Conversation
…side Wine's server (VICTORY_WINE_MAP=0: views in placeholders, as before) The title shows its physical pages one 64 KiB view at a time (XMemMapPhysicalPagesScatter and the GPU's page-mapping copies), with tens of thousands of views there. Wine's server keeps a process's views in a linked list and walks it for every view mapped (is_valid_view_addr) and unmapped (find_mapped_view), while the calling thread holds ntdll's virtual_mutex: the lock every NtProtectVirtualMemory, NtQueryVirtualMemory, NtGetWriteWatch and every fault of the process takes too. So the guards' protection changes and faults wait behind the title's mapping calls. Under Wine only (wine_get_version in ntdll), where the host would have a placeholder the reservation is a plain one; a page is shown by mapping the section's file there with the C library's mmap (MAP_SHARED | MAP_FIXED; the descriptor from ntdll's wine_server_handle_to_fd, the same pages as any view of the section), then committing the range, which under Wine sets its books and protection and nothing else. It is taken away by MEM_DECOMMIT. Protections, queries and faults go through Wine as before. A query calls such a page private, so the GPU side is told where these reservations are (victory_gpu::title_view_space). The title's VirtualFree of placeholders (split, coalesce, release) is done on pieces kept of the reservation. A page of a section of our own is shown this way at the start, read, written, protected and taken away; if any of that fails, pages are shown as views. On Windows nothing changes. Measured on an RX 7900 GRE + Ryzen 9 9900X, Proton Experimental (Wine 11.0, ntsync), vkd3d-proton 3.2, in the borntofrag34/VIctory-7900XTX fork where it was written (2026-11-26): in the first scene 768 -> 13 ms of every second in mapping calls, waiting for the guards 171 -> 23 ms a frame, changing protections 48 -> 11 ms (runs 9 and 11); with the pipeline workers' fix as well, 136 -> 11 ms and 41 -> 7.7 ms (runs 21 and 19). Ported from borntofrag34/VIctory-7900XTX 94530f03 onto this tree's xmem (soft and lazy views, file-backed sections, batched page mapper). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ics pages where the title has them (VICTORY_PORT_HOME=0: as before) vkd3d-proton opens a host heap on memory by importing it into Vulkan (VK_EXT_external_memory_host); where the import fails it gives the heap memory of its own and reports success. With RADV it works for private memory and fails for a view of a section: the card reads zeros there and every frame of the port is black. And the kernel (amdgpu's amdgpu_ttm_tt_get_user_pages) takes memory by address only as one mapping of the process's own, from first byte to last. With VICTORY_PORT_CONSTANTS=1 and VICTORY_WINE_MAP on, under Wine only: before the 32-bit heap's section is first shown, its whole stretch is made one anonymous mapping (one mmap, then committed); its pages are then shown as that private memory at the one address the title maps them at, their bytes copied in from the section and back out when they are unmapped. If the title shows one of them at a second address, the section goes back to being its file everywhere. The port opens its heap right there (no view of ours), asks the card what it reads through it, and tries four times before giving the stretch up (copied and guarded as before). The guards never make such pages read-only: while one is, the kernel refuses every submission and the device is lost (UwUCammie, borntofrag34/VIctory-7900XTX 73d7b690). A stretch that is a view is refused under Wine unless the card reads the view's bytes through such a heap (one probe at the start). Today, with VICTORY_PORT_CONSTANTS unset, the GPU side's port is on but xmem's half (arrange) is off, so the heap is "Scattered" and never in place; this commit does not change that: PORT_HOME acts only where the switch is set to 1. Measured in borntofrag34/VIctory-7900XTX (RX 7900 GRE, Proton Experimental, first scene at 1920x1080, 2026-11-27): 40.5 -> 33.4 ms a frame, changing protections 7.7 -> 3.7 ms, the submitting thread 37.7 -> 29.0 ms (runs 30 and 33). On Windows nothing changes. Ported from borntofrag34/VIctory-7900XTX 1be9bdaa and 73d7b690. Co-Authored-By: UwUCammie <UwUCammie@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in town on an RX 7900 GRE (55.0 ms a frame against 62.2 to 64.7) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Follow-up on "each protection change still costs about 60 µs here … not explained yet": a run with |
|
A Wine run on the current tree, and one number that may be worth a look. Built Environment: RTX 4080 SUPER 16 GB, i9-14900K, 62 GB, CachyOS, Hyprland (Wayland), The start-up check runs. The log has The run: 6m 13s, 19–29 fps, up to 11,795 draws/frame, no
The difference between the last two is 1m 7s and I did not exercise The number I think matters. With the camera still, a frame is 51 ms, and the layer's What I did not do: Windows, a patched wineserver to compare against, or a longer run. |
… heap opened in place (PR trustno1-coder#2455) Port of trustno1-coder#2455 (VICTORY_WINE_MAP on under Wine, VICTORY_PORT_HOME with VICTORY_PORT_CONSTANTS=1) onto this fork's main, applied with a 3-way merge; no conflicts. Nothing changes on Windows (both act only when ntdll exports wine_get_version). Tried here, RTX 3080 10 GB, Proton, native 1080p, pool at its default, same scene, played: no Xid in 484 s, Wine server CPU about 3%, game memory unchanged (about 19 GB, so RAM stays tight). Frame rate over the whole run is on par with the build without it (14.2 fps / 74 ms against 14.6 fps / 74 ms); the first minutes looked faster (15.8 fps / 68 ms) but that did not hold. The user reported it feels good. One run each: an indication, not a benchmark. PORT_HOME is a RADV fix and was not exercised on this card.
…one lock (PR trustno1-coder#3268, shadow.rs part) From trustno1-coder#3268 (banaanpapa): Shadow::take_all groups the parts of a refresh into tasks of about 256 KiB; a task's marks are kept on its thread and told once ([`Shadow::telling_once`]). The PR's host.rs/bus.rs/placement.rs benches and audit text come with it. One conflict, in take_all: the PR's `wide_each` with a pointer cast is replaced by this tree's `wide_each_scoped`. Tried here (RTX 3080, Proton, native 1080p, pool at default, played): no Xid in 5:24; the user reports it is better. The logs do not show it clearly: frame rate within noise of the build without it (15.7 fps / 73 ms against 14.6 fps / 74 ms); texture refresh CPU per frame about 5 ms against about 24 ms in the run with trustno1-coder#2455 alone (4 ms in a baseline without trustno1-coder#2455, so scene or trustno1-coder#2455 may explain part). Put on main at the user's call; a longer, repeated run has not been done.
Two changes for running under Wine/Proton, each behind its own switch. On Windows nothing changes: both act only when ntdll exports
wine_get_version. They come from borntofrag34/VIctory-7900XTX'slinux-winebranch, where they have been in use since 2026-11-26/27. They are ported here onto this tree'sxmem, which has soft and lazy views, file-backed sections and the batched page mapper.What changes
VICTORY_WINE_MAP(on under Wine;=0brings back today's behaviour)is_valid_view_addr,find_mapped_view). It does that while the calling thread holds ntdll'svirtual_mutex, the lock everyNtProtectVirtualMemory,NtGetWriteWatch, query and fault also takes. (docs/linux-proton.mdalready describes this list, with a patched wineserver as the workaround.)mmap(MAP_SHARED | MAP_FIXED; the descriptor comes fromwine_server_handle_to_fd), then committing the range.MEM_DECOMMIT.VirtualFreeof placeholders (split, coalesce, release) is done on pieces of the reservation that we keep track of.title_view_space, whichwatch'sis_view/readable_view/placeholderandinplace::private_wholeuse.VICTORY_PORT_HOME(on withVICTORY_PORT_CONSTANTS=1andVICTORY_WINE_MAP;=0: off)amdgpu_ttm_tt_get_user_pages) also takes memory by address only as one mapping that the process owns.port.rsopens the heap right there, with no view of ours. It checks through the card that the bytes really arrive, makes up to four attempts, and otherwise gives the stretch up (copied and guarded as before).Side note, not changed here: with
VICTORY_PORT_CONSTANTSunset, the GPU side's port is on by default (except on Ampere), butxmem's half (port_on, which runsarrange) defaults to off. The 32-bit heap is then never in one stretch, the log saysnot one native-import-eligible stretch of a section: Scattered, and nothing is ported. I think the same happens on Windows, but I have not checked.VICTORY_PORT_HOMEonly acts whereVICTORY_PORT_CONSTANTS=1is set explicitly.Measured
victory playsettings with the frame clock at 16.667 ms. A save another player shared (issue 332) in a town, the same scripted walk each time. 300 s per run, read from 150 s on, diagnostics build, one run per setting.main829188e (+ #2048 to build diagnostics)VICTORY_WINE_MAP=0VICTORY_PORT_CONSTANTS=1VICTORY_WINE_MAPalone does not make the frame shorter here. It takes the Wine server from 6.1 % to 0.4 % of a processor, the write-watch askings from 7.1 to 3.1 ms a frame and the texture refreshes from 9.9 to 5.5 ms. This tree's soft views and section windows already avoid most mapping calls. In the fork, which has neither, the same change took the guards' wait from 171 to 23 ms a frame and protection changes from 48 to 11 ms (first scene, 4K).maintoo.docs/linux-proton.md.Not verified
on_wine(), but nothing was measured there.VICTORY_WINE_MAPis on by default under Wine for every card. Whether NVIDIA's driver imports private memory the same way was not checked; the port's own check through the card guards against zeros.VICTORY_SOFT_VIEWScovering the pool (1orpool), the 32-bit heap is shown lazily and the port finds it uncommitted, so it falls back to copies. The launcher usescopies, which is fine.Tests (under Wine, in a headless gamescope, on the card)
victory-hlexmemandwine_map: 49 passed, 1 failed. The failure,a_read_by_range_waits_only_for_a_remapping_that_meets_it, also fails onmain.maingives 44 passed, 2 failed (that one anda_title_thread_goes_on_using_the_rest_of_a_view).under_wine_the_32_bit_heap_is_shown_as_memory_of_its_own;under_wine_a_stretch_at_home_is_opened_where_it_is_and_a_view_only_if_shared, which runs on the card;pages_at_home_are_never_made_read_only;wine_map's three.victory-gpuwatch::,inplace::,port::: 73 passed, 4 failed. The four aremany_askers_tests×3 andwhat_is_left_alone_is_no_known_hole;maingives 71 passed and the same 4 failed.cargo clippy -D warningsandcargo xtask policyalready fail onmain(victory-shader, victory-loader,heap_sites/frame_users.rs).🤖 Generated with Claude Code