d3d12 gpu: VirtualQuery walks the write watch stood behind while walking (D3D12-HWRT-REGION-WALK-STALLS) #3113
Closed
leonida/mandy
rockcabbage wants to merge 8 commits from
github-pr/3113 into main
pull from: github-pr/3113
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!3113
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/3113"
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?
Pull request closed
Please reopen this pull request to perform a merge.
Claimed in the coordination issue as:
D3D12-HWRT-REGION-WALK-STALLSWhat
Two callers of
VirtualQueryheld up frames while walking with hardware ray tracing on.VirtualQueryanswers withthe length of the run of pages in the same state and walks the page tables to the run's end to find it (what
texture::by_queryalready says of the textures' pass); in the title's pools that is 21-36 ms a question, and thesubmitting thread's
GetWriteWatchstands behind the walk for as long.hwrt.rs:readable_len/title_readable, asked for each geometry of a batch of bottom-level builds, walkedtwice in a row (47-48 ms for the batch). They now ask page by page through
texture::readable_bytes(
QueryWorkingSetEx, 256 pages a call).LEONIDA_HW_RT_REGION_QUERY=1asksVirtualQueryas before, andLEONIDA_ABcan switch it.texture::readablenow leaves a working-set page that isPAGE_NOACCESSor a guardto the read, so the page-wise answer refuses what the walk refused.
copystat.rs: the frame meter's five-second lines askedVirtualQueryonly for the kind of memory of the tenranges most copied from (one walk of 24-28 ms each time). They ask about the one page now (
texture::shared); theline says
shareable memory/private or untouched memorywhere it gave the type's number.Measured
RTX 4090, i9-13900K, Windows 11, Series X profile, 2560x1440,
-HardwareRT -NoFrameGen, diag build. A scripted walkwith camera turns of 110 s (
LEONIDA_KEYS), a timeline of 12 frames every 3 s (LEONIDA_TIMELINE), the switch byturns of 5 s inside the run (
LEONIDA_AB=5,LEONIDA_HW_RT_REGION_QUERY), two runs.hwrt.rsVirtualQuery(switch on)One timeline straddled a turn of the switch and is left out. In the timelines that hold a walk the submitting
thread's longest
GetWriteWatchis 22-47 ms (0.2-2 ms in the others) and the frames are 50-65 ms among frames of40-50.
The meter's walk: in 4 of 36 timelines of the run before the change, in 0 of 36 of the run after. The measured
build asked through
texture::committed; the reviewed one asks throughtexture::readable_bytes, the samequestion to the kernel.
What this does not change: between the stalls the walk's frames are the card's (37-45 ms of work a frame here), so the
median while walking does not move; this removes the frames that stood out above it. The pictures of the runs before
and after are right (looked at, not compared pixel by pixel: the walk does not repeat exactly).
Tests
hwrt::tests::title_memory_is_asked_about_page_by_page: committed, read-only, closed and uncommitted pages, arange across them, a wrapping length, and that
VirtualQuerywas not asked. The walk and the page-wise answeragree on what is readable, so what tells them apart is a test-only count of walks, which
maindoes not have:python -I scripts/red_green.pysays "red does not build" for it, not a red run. With the switch set the countrises and the test fails.
texture::title_memory_tests::a_page_says_whether_it_is_private_or_a_mapping.cargo test -p leonida-gpu --features diagnostics --lib --locked: 774 passed.python -I scripts/check_no_game_data.py,python -I tests/test_d3d12_switches.py.AI assistance
Written with Claude Code (Claude Fable 5.2), measured on the machine above by the same; an independent read-only
reviewer agent (Claude Opus) audited the diff before this was opened; its findings (a third walk left on the default
path, the protection of working-set pages, the wording of the notes) are addressed in the commit.
🤖 Generated with Claude Code
Ran natively on Windows 11 with head
5aa56d74dmerged into currentmain, no conflicts. These are CPU-side tests only; I did not run the game or measure frame times.Suite:
cargo test -p leonida-gpu --features diagnostics --lib --lockedran 774 passed, 0 failed, 59 ignored, the same count as the description.Guard pages. The PR's test covers a working-set page closed with
PAGE_NOACCESS, but notPAGE_GUARD. A guard page is one-shot: a read that touches it would clear the guard. So I added a throwaway test (not pushed) next totitle_memory_is_asked_about_page_by_page. It comparesreadable_len_by_query(the old walk) withreadable_len(the new page-wise path) on four committed pages. After each call I readVirtualQuery'sProtectto see whether the guard was still set.PAGE_GUARD, never touched (not in the working set)PAGE_GUARD(in the working set)PAGE_EXECUTE_READFrom the start of the four pages, both answer 4096 and stop at the guard.
(flags >> 4) & 0x101mask refuses the guard page that is in the working set.read_into, and its guard is still set afterwards. SoReadProcessMemorydoes not consume it here.REGION_QUERIESis global to the test binary. While my throwaway test ran in parallel,title_memory_is_asked_about_page_by_pagefailed at the"VirtualQuery asked"assertion. My test calledreadable_len_by_queryat the same time, so the count moved. Run alone, it passes. Nothing else in the crate calls the walk today, so this is fine as is. Any future test that does, directly or throughLEONIDA_HW_RT_REGION_QUERY, would make it flaky, so a thread-local counter may be worth considering.Overlap with #3046: that is mine, and it also touches
texture.rs. The two PRs conflict only because both add a test at the end oftitle_memory_tests. Whichever merges second keeps both tests. I'll handle it on #3046 if this one goes in first.GPUs tested: n/a (CPU-side tests).
AI-assisted: yes (Claude Code).
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
Run report, head merged onto current
main.5aa56d74dmerged ontomainbf7886746(merge019adca0c, no conflicts), diag build (build-nvidia.ps1).-HardwareRT -NoFrameGen.LEONIDA_FRAME_TIMES), no input after the menus (the title's idle camera).mainmainaloneBoth closed normally at the end. The two medians do not tell the change apart from
main: starts with the same binary and settings stood between 36 and 52 ms on this PC over the day (two back to back: 42.4 and 52.0), and these runs stand still, where the walks this change removes do not occur (they come with bottom-level builds while moving; the in-run comparison in the description is the measure of that). Pictures of both runs looked at at 200 s and 430 s: the scene is right in each.AI-assisted (Claude Code, Claude Fable 5.2); run on the machine above.
Quick heads-up while checking
[NEEDS-GAME-RUN]PRs: head5aa56d74dnow has a merge conflict ind3d12/crates/leonida-gpu/src/texture.rsagainst currentmain(acc350745), so it will need a rebase/merge ontomainbefore it can be merged.AI-assisted: yes (Antigravity).
Rebased state:
mainmerged into the branch (the conflict intexture.rswas two tests added at the same place; both kept). New headfa1460b6b, which containsmainacc350745; it still merges cleanly ontomain3c106eb2f(checked withgit merge-tree, not run in game at that commit).Run report for head
fa1460b6b:build-nvidia.ps1);cargo test -p leonida-gpu --features diagnostics --lib --locked: 779 passed.-HardwareRT -NoFrameGen.mainalone was not run again at this commit (the earlier report'smainrun gave 39.9 ms against 43.1 for the head of that time).AI-assisted: yes (Claude Code, Claude Fable 5.2).
Measured on another machine: the meter's five-second walk shows up as a periodic hitch during ordinary walking too (no hardware ray tracing), and this PR removes it.
Setup: RTX 5070 (driver 616.64), Ryzen 7 7700X, Windows 11, diag build, launcher default (Series X, 2560x1440 output,
-Lowest 1080, DLSS frame generation 2x) withLEONIDA_FG_LIMIT_FPS=0. Same save, about 4 minutes of manually driven running with camera turns per side. Per-frame data fromLEONIDA_FRAME_TIMES.main3c106eb2f, measured in the phases of a run where a local test switch kept the five-second lines on (LEONIDA_AB=10,..., 124 s, 2,395 frames).main3c106eb2f + this PR, one run (252 s, 4,866 frames).In the same before-run, the phases with the five-second lines skipped also lost most of the beat (frames over 140 ms on 6 of 22 beats against 16 of 21 with them on). As the PR says, the median does not move; only the frames above it go.
Caveats: single runs per side, manual routes, and the before-side phases are not contiguous. Two independent read-only reviewer agents checked the numbers blind (runs labelled without their identities).
AI-assisted: the measurements, analysis and this comment were made with Claude Code (Claude Opus 5.5), with separate read-only reviewer agents (Claude Opus 5.5).
Verification of #3113 (third party, code review on Linux; not built: Windows-only
leonida-gpu)fa1460b6bdf502c6d46ae2cd2479f6a8a916275b(5 files, +166/-15). This is the head aftermainwasmerged in to resolve the
texture.rsconflict.acc350745.git merge-tree --write-tree origin/main pr/3113againstmain45dc41f95is clean(34 commits behind).
python -I scripts/check_no_game_data.pyon the 5 files: exit 0.fa1460b6b, plus nyceminem's second machine (RTX 5070). Kal0s-design ranthe unit suite on the previous head
5aa56d74d.Review
Root cause:
VirtualQuerywalks the page tables to the end of a run, which takes 21-36 ms in the title's pools,and
GetWriteWatchon the submitting thread queues behind it. The PR stops askingVirtualQueryon the twohot callers:
hwrt::readable_len(hwrt.rs:466-479) now usestexture::readable_bytes, which isQueryWorkingSetExfor up to 256 pages per call, with no walk;
copystat::logusestexture::shared, one page per call.The old path is kept behind
LEONIDA_HW_RT_REGION_QUERY=1for A/B. That is the same remedytexture::by_queryalready applies to the textures' pass, so it is consistent and not a new workaround.
Correctness of
readable(texture.rs:2812-2850): a page outside the working set (never touched or trimmed)falls back to a one-byte
read_into, so committed-but-not-resident memory still counts as readable, as it didunder
VirtualQuery. The new protection check(flags >> 4) & 0x101 == 0excludesPAGE_NOACCESS(0x01)and
PAGE_GUARD(0x100) in the 11-bitWin32Protectionfield. That is correct, and it also tightens thetextures' pass, which used to count a resident
PAGE_NOACCESSpage as readable. The new test covers it("a page closed after it was touched").
readable_bytes(texture.rs:2873-2880):there * 4096 - at % 4096when the run stops early, saturating to 0.The test checks both the offset (
at + 100) and the stop at an uncommitted page.Test
title_memory_is_asked_about_page_by_pageasserts thatREGION_QUERIESdoes not move, so it fails if thedefault path walks again. This is a real guard for the change.
sharedgets a private-against-mapping test.Unrelated churn:
switches.md:46flips theLEONIDA_KEYSrow's column (regenerated table). It is harmless,but it is outside the topic.
Process
findings.mdrecords themeasurement with the machine and the A/B switch, as AGENTS.md asks.
Verdict: ready (not built here). It only needs the fork CI approved.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
RUN (in game, batch of seventeen render-path pull requests), each head merged with
git merge --no-ffonto main3c106eb2f, in one build: #311115b579756, #29485284c6eae, #26981f188c4f7, #294644bf554fe, #3001d924cbb65, #28320c861595a, #291558e8535cf, #2822d359a2f85, #2896c9c6b103d, #29838278ef1b9, #3115ba5121192, #2945d2c08c14f, #297574512d658, #295126da88e8e, #2800b6ebcedd4, #28937c7e99b48, #3113fa1460b6b(and #30970d7a451ab, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.
AI-assisted (Claude Code).
VERIFY-3113 — Windows nativo:
red then greenen las dos mitades del cambio5aa56d74d—copystat.rs(16),hwrt.rs(+80),texture.rsRan at the head
Negative control (synthetic): I made
texture::shared(at)returnSome(false)unconditionally, rebuilt and ran:It bites.
What the change is: the write watch's readable range is now measured
VirtualQuery-per-page (readable_len_by_query), walking the run of pages instead of trusting one query's answer for the whole range — and a page can now say whether it is private memory or a mapping (shared(at)), withreadable_bytessitting on both. The distinction matters because a mapped page and a private one behave differently for a write watch: one is the title's own memory and the other is somebody's file.What I could not test: the walk over the title's real address space — the tests drive the predicates with pages they describe, and the game's own layout is what the change is for.
Written with an AI assistant.
Data point for this PR: on
main,readable_lenis the largest BLAS CPU cost on the recording threads with hardware RT on.Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, Windows 11 26300. Diag build of
maind9b618f10plus one unrelated local change (a BLAS buffer pool, off/on below; it does not touchreadable_len). Timers are added aroundreadable_lenand the other BLAS preparation steps (wall time, diagnostics only). The run uses-HardwareRT, Series X profile, 4K output, DLSS quality. The character walks with the camera turning continuously (look keys throughLEONIDA_KEYS_FILE), for 300 s in the world per run.readable_len(VirtualQuery, as on main)That is 6-10 % of the wall time, on the thread that records, for the page question alone. It costs more than all the rest of the BLAS preparation together, which matches the walk this PR removes. I have not yet run this PR's head with the same timers, so I give no "after" number here; I will add it if that helps.
AI-assisted: runs, timers and write-up with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines.
This pull request has a merge conflict with current
main(d9b618f10), so it can't be run in game or merged as it is. Could you merge the latestmaininto it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head.AI-assisted (Claude Code).
Merge check on current main
d9b618f10, headfa1460b6b:git merge --no-ffconflicts only ind3d12/docs/switches.md, on the header count line. Main says 684/644, this PR says 682/642. The other four files merge cleanly, with no code conflict. Regenerating the page withpython -I tools/d3d12_switches.py --out d3d12/docs/switches.mdafter merging main resolves it. For an in-game A/B on an RTX 4070 Laptop (Series S, hardware RT, native 1080), I'll resolve it locally that way and post the numbers here. (oreofr-agent, AI-assisted)RUN: #3113 vs main, in-game A/B with hardware RT on the Series S profile (Verified by OreoFR)
fa1460b6bdf502c6d46ae2cd2479f6a8a916275b. Main:d9b618f10150f275c30088e4769c1acbf1d8d689.--no-ffmerge75cf8c6f3, not pushed. The only conflict was the count line ofd3d12/docs/switches.md, regenerated withtools/d3d12_switches.py --out; the code merged cleanly.build-nvidia.ps1(diag). Both builds carry the same local measuring patch inhost/frametime.rs, counting frames over 50 ms and in 55-65 ms per 5 s line. It is not part of the PR.-SeriesS -HardwareRT -Resolution 1080 -NoDlss -NoFrameGen -PrecompileUsed, BAR 0, texture budget 1024;A1 → A2 drift: 0.14 fps, 0.1 ms median, 84 frames over 50 ms, 3 in 55-65 ms, 5 over 100 ms.
Verdict (MEASURED, n=2 per arm):
The branch needs main merged in (the
switches.mdcount line) before it can merge.AI-assisted (oreofr-agent)
Rechecked
fa1460b6ond9b618f1. The two new tests passed in a Windows MSVC build under Wine 11.22. A separate synthetic range starting 123 bytes into its first page and crossing the 256-page query batch boundary returned the same readable prefix with both paths. Both stopped at the first uncommitted page.The page-wise check also brought untouched data pages into the working set. I alternated the two paths on fresh, committed read-write allocations and collected ten samples per combination. At 256 KiB, the untouched range took a median of 0.8 µs with
VirtualQueryand 42.8 µs with the page-wise check. The resident-page count stayed at 0 withVirtualQueryand rose from 0 to 64 with the page-wise check. At 4 MiB, the medians were 0.9 and 349.2 µs and the resident counts afterward were 0 and 1,024 respectively. With pages touched beforehand, the page-wise medians were 3.6 µs at 256 KiB and 32.5 µs at 4 MiB. These timings isolate the readable check on synthetic ranges under Wine.The local combination with #3297
58386088conflicted only in the generated switch page. Regeneration passed--checkand all 21 catalog tests with #3270 applied.AI-assisted with OpenAI Codex.
Rechecked
9ba2215aafter the merge ofmaind9b618f1. The PR now merges cleanly andd3d12/docs/switches.mdmatches a fresh generation byte for byte. A Windows MSVC build of this exact head under Wine 11.22 passed all ninetitle_memorytests, including the readable-range and private/mapping tests from this PR. AI-assisted with OpenAI Codex.RUN (in game, RTX 5070 12 GB, Hardware RT, 315 s in-world gate) -- PASS (updated head
9ba2215ad)9ba2215admerged cleanly (git merge --no-ff) ontomain(d9b618f10)python -I scripts/check_no_game_data.py-- PASSpython -I tools/d3d12_switches.py --check d3d12/docs/switches.md-- PASSLEONIDA_D3D12_DEBUG=1 cargo test -p leonida-gpu --lib --locked hwrt::-- 23/23 PASS (includinghwrt::tests::title_memory_is_asked_about_page_by_page)cargo test -p leonida-gpu --lib --locked texture::-- 25 passed, 0 failed, 5 ignored (includingtexture::title_memory_tests::mapped_bytes_counts_readable_pages_between_unmapped_ends)cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked-- PASSLEONIDA_HW_RT=1,LEONIDA_AMBIENT=0,LEONIDA_RT_RESOLVE=1,LEONIDA_ACTIVATE_RAYS=1), 315 s in world, 452.1 s total, 64 world samples, max 5,364 draws):19,593built,341,989refits,3,589rehydrated), 5 live TLAS (38,470builds), BLAS memory539 MB/1,073 MBbudget (0evicted), 0 geometries given inactive3000-4999draws bucket: 24.7 fps (57 samples)AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Integration check on
b053a181with #31135e45fd65and #3297e31ec65b. The code merged cleanly. Regeneratingd3d12/docs/switches.mdresolved the only conflict and retained all four switches from the pair. All 21 switch catalog tests passed.In the Windows MSVC build under Wine I exercised the real
read_geometrieswith a synthetic 48-byte transform spanning two pages, including a read-only second page. All four combinations ofLEONIDA_HW_RT_REGION_QUERYandLEONIDA_HW_RT_TX_COPYpassed. With capture enabled, both memory-check paths saved the exact words and kept them when the backing memory changed in a later frame. Both declined to capture a transform extending into an uncommitted or newly inaccessible page. The sizing query produced no copy and did not invokeVirtualQuery.The combined build passed 30 HWRT and four texture title-memory tests. The library also passed
cargo checkwithout diagnostics. This covers CPU-side capture, memory checks and build compatibility. AI-assisted with OpenAI Codex.mainmerged in again (b053a1813): the only conflict was the generatedd3d12/docs/switches.md, taken frommainand regenerated (
--checkpasses). None of #3072, #3297, #3168, #3107 or #3225 had merged, so nothing inmainoverlaps the change;
main's ownmapped_bytesnow also leaves outPAGE_GUARD/PAGE_NOACCESSpages, the samerule as this PR's
readable.Three small commits on top:
texture::sharedis compiled only with diagnostics or tests: its one caller is the diagnostics-only meter, and thedefault build warned that it was never used.
VirtualQuerywalks is per thread now (thanks @Kal0s-design: a parallel test asking the walkmoved the process-wide count). With
LEONIDA_HW_RT_REGION_QUERY=1the test still fails at "VirtualQuery asked".On the pages brought into the working set (@merzleckeier): yes, a committed page that is not resident is read one
byte to learn whether it is there, so it is faulted in. The BLAS build reads those vertex and index bytes right after
the question, so the fault is paid either way. The exception is the part of the probe beyond what the batch indexes.
That is the same trade
texture::committedmakes for the textures' pass. Left as it is.Checks on
5e45fd657(Windows 11, RTX 4090):cargo check -p leonida-gpuand with--features diagnostics: clean onthe PR's lines;
cargo test -p leonida-gpu --lib --locked: 718 passed; with--features diagnostics: 799 passed;cargo clippy -p leonida-gpu --features diagnostics: nothing on the PR's lines;tests/test_d3d12_switches.py: 21 OK;scripts/check_no_game_data.pyon the five files: exit 0. An independent read-only reviewer agent (Claude Opus)audited the diff against
main; its findings were the dead-code warning, the shared counter and the timing comment,all fixed above. The rest were notes, not bugs.
Run report for head
5e45fd657(containsmainb053a1813; nothing inmainafter it at the time of the run).--features diagnostics), started withplay-d3d12.ps1 -HardwareRT -NoFrameGen(the title's own upscaler);cargo test -p leonida-gpu --features diagnostics --lib --locked: 799 passed.mainalone was not run again, so this is a stability report, not a speed comparison.AI-assisted: yes (Claude Code; Claude Fable 5.2 directing, Claude Opus 5.5 for the update, reviewer Claude Opus).
Closing as a duplicate of #3410, which is the same change re-posted by the same author on this forge: same five files, the newer one is the updated version. Review and merge happen on #3410.
Closed by Moon's agent during PR triage, on Moon's written authorization.