GPU: keep a title guard page inside a range; change guards in runs #68
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/68"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from avatarmanz/VIctory-7900XTX. Originally posted by zocram4cc on 2026-11-26T01:28:48Z.
Promised to @itsonewi on #14 (review of "copies of title memory"): a separate PR for this bug, with its own test. It does not depend on #14: this branch is cut from
avatarmanz/VIctory-7900XTXmainand contains none of #14's code.Bug: a title guard page inside a protected block loses its guard
protect_here(a range) andprotect_alias(another view of a guarded page) madePAGE_READONLYover a whole 64 KiB block, or over a whole range, after looking at the first page's old protection only. A page the title guards itself (PAGE_GUARD) further on in that block lost its guard: nothing faulted and nothing was seen written, so the title's own guard never fired.Now a change of protection covers only blocks that Windows says are alike (committed, one region, read-only or read-write throughout). A block that is not gets no call and stays as it is, with
VICTORY_GUARD_RUNSon or off.Tests (the two bug tests run with the switch off and on):
watch::tests::a_page_the_title_guards_inside_a_range_keeps_its_guard: on v7900/main the guarded page readsPAGE_READONLY(left: 2) instead ofPAGE_READWRITE | PAGE_GUARD(right: 260).watch::tests::a_page_the_title_guards_in_another_view_keeps_its_guard:left: 2,right: 260before theprotect_aliascheck; green with it.Change guards in runs (
VICTORY_GUARD_RUNS, on by default)Each change of protection is a kernel call; under Wine it is an
mprotectand a flush of every processor's address cache. The guards changed protection one block at a call, after asking for a whole range first where it could be refused across views. With the switch on:With
VICTORY_GUARD_RUNS=0a range is asked for whole only when it is one alike region; otherwise each block gets its own call. The refused call across views is no longer made:runs_of_guarded_blocks_are_cut_where_views_meetexpects 6 calls there, not 7.In-game counter (Proton Experimental, v7900 base, one scripted run)
Frame-line counter (diagnostics builds), two steady windows, per frame:
VICTORY_GUARD_RUNS=0.No frame-time change measured. The only two frame-time runs (98.0 ms/frame median in an earlier run without the bug fix or the runs, 100.9 ms in the run with both) are not an A/B: they differ in more than this change. I make no frame-time claim either way.
Credits
VirtualProtectper run of guarded pages, the idea behind the runs.As we read their code, their runs ignore view boundaries and the call's result, so it does not fit this tree; this is a new implementation.
Testing
cargo xwin build --profile diag -p victory --features diagnostics --target x86_64-pc-windows-msvcpasses.-D warnings(cargo xwin clippy -p victory-gpu --all-targets, default and--all-features): every diagnostic it reports is on a line this PR does not change.other_memory_inside_a_run_keeps_its_protectionpasses there too, since the old code already kept other memory's protection. The other-view test fails on the port before theprotect_aliascheck and passes after it.watch::module under Proton: the same three tests fail on the unchanged base and here (holes_are_known_until_the_runtime_tells,no_mapping_is_lost_between_askers,what_is_left_alone_is_no_known_hole). No new failures.AI-assisted: yes. Drafted with an AI coding assistant; the tests were run under Proton; the counter numbers come from the in-game run above.
Imported from avatarmanz/VIctory-7900XTX. Originally posted by avatarmanz on 2026-11-26T07:33:48Z.
Left open: conflicts with main (host.rs), and VICTORY_GUARD_RUNS is on by default; needs a rebase and an in-game check.
Imported from avatarmanz/VIctory-7900XTX. Originally posted by zocram4cc on 2026-11-26T08:12:53Z.
Rebased onto current
main(the 5 s lines moved intometer_lines; the guard counter line is called there now) andVICTORY_GUARD_RUNSis off by default now (=1turns the batching on). The guard-page fix does not depend on the switch: with it off, a range is asked for whole only when it is one alike region, and a block that is not alike is left as it is.In-game check on
main+ this branch (Proton, RX 6900 XT) follows; I will post the numbers here.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.