Submission CPU time, ambient light following the exposure, unattended benchmark #139
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!139
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-139"
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?
@Zetsukae on GitHub · 2026-11-25 16:12 UTC · original
Zetsukae:perf/submission-cpu→main· +964 −61 · 10 files · 12 commits · openWhat this does
Speeds up the work the submitting thread does around each submission, found with
VICTORY_PROFILEand measured with an unattended benchmark (included).in_parallelkeeps its helper threads for the run instead of starting and joining five threads on each call. That was about an eighth of the submitting thread's time.bindless planswent from 45–70 ms to about 19 ms a frame in the world. In test builds, every remake also makes the lists the old way and asserts they are equal.VICTORY_KEYS,VICTORY_KEYS_FILE) also press the stand-in pad's buttons on a real pad in slot 0: while a pad is connected, the title reads the pad and ignores the keyboard.scripts/bench.ps1: an unattended benchmark. It presses Enter at the title screen, waits through the opening cinematic, measures 90 s in the world, can take screenshots, and writes a summary.-GpuTimingalso setsVICTORY_D3D12_DRED: per-pipeline GPU times are only recorded when it is set (this is not in the README).scripts/profile-run.ps1is the same run played by hand.Results
Standing still in the world (frame lines averaged over 90 s): 3.5–4 fps (250–300 ms) before, 4.75 fps (216 ms) after. Walking: 3–4 fps before, about 5 after.
What is left per frame: GPU about 72 ms (spread over about 1,300 pipelines, the slowest 4.5 ms), refresh copies about 42 ms, snapshots about 36–40 ms, copy-back about 31 ms, bindless plans about 19 ms. These still run one after the other.
Lighting: the ambient stand-in follows the title's exposure
The stand-in for the missing ray-traced indirect light was one constant (0.6). The lighting images it goes into are already multiplied by the title's exposure, so in a dark scene where the title raises the exposure (interiors, night: -5.5 EV) the constant came out as strong as at noon (-9.75 EV): flat and too bright at night, pure black in daytime shadows.
PS_CalculateExposuredraws a 1×1 RGBA32F holding (multiplier, EV, EV); in the prison interior it read (0.0221, -5.5, -5.5). The program is found by name, the same way as the resolve, its target is noted, and the ambient pass reads it as a shader resource. The level becomesat · 2^(-k·(EV - ev)): by default k = 0.5 and 1.4 at -9.75 EV, which gives about 0.32 at -5.5 EV. Those are the README's hand-tuned noon and dusk levels.VICTORY_AMBIENT_EXPOSURE=k,ev,attunes it; settingVICTORY_AMBIENTor using the ambient file still forces a fixed level.Only checked at dusk in the prison so far. Night has not been looked at yet.
Also new in diagnostics:
VICTORY_RESOLVE_CONSTANTS=1logs the resolve's constants (that's how the exposure was ruled out there), andbench.ps1gains cinematic screenshots, render-target dumps and-ExtraEnv.Textures written by the GPU through another view
Skin and tattoos on people showed noise (the guard's forearms, inmates' faces), with a new pattern each launch. With
VICTORY_TEXTURES=always(every texture looked at on every use) they rendered correctly, so the data in title memory was right and only the upload was stale. The GPU writes those textures' memory through a buffer view. Copying that back into title memory told the guards, but not the textures placed there.watch::writing, which every write of ours into title memory goes through, now marks the textures in that range (and at the other views of its pages) as rewritten, the same way a streamed file does. The tattoos have rendered correctly since. Textures the title's own CPU threads write are still only caught at their next periodic look.Findings that are not fixed here
VICTORY_ASYNC_SUBMIT=1and lighting bugs. With async on,prewarmrefreshes the next submission's copies while the previous submission's GPU work may still be reading them. Only the ranges it writes are skipped, so a constant buffer it reads can change under it. This fits the lighting errors seen with async on; it is not confirmed with a capture.Tests
cargo test -p victory-gpupasses, except for thewatch::testsfailures that already happen onmain. Those tests share the guards' global state: run in parallel they fail now and then, with or without this change (3 of 5 runs failed onmain), andwritten_pages_are_reported_to_every_askerfails every time with--test-threads=1, with or without this change.cargo xtask policyreports only the knownlower.rssize.🤖 Generated with Claude Code
@battledogegames-design on GitHub · 2026-11-25 21:19 UTC · original
WARP reproducer for prewarm overwriting an in-flight upload read
Zetsukae, I tested the overlap you identified in #139 using two D3D12 copy commands and synthetic data. With the first read held on the queue, the next submission's prewarm can update the same upload bytes before the GPU consumes them. The first copy then returns the second submission's value.
4f62c2aa208d61Each run used a fresh process. Synchronous overlap and asynchronous disjoint ranges both passed. In every overlap failure, the two reads returned [0xAABBCCDD, 0xAABBCCDD]; the expected values were [0x11223344, 0xAABBCCDD]. A separate fence on the same WARP queue verified completion before readback. No timeouts occurred.
The attached ZIP contains the test patch against main, commands, and results. With the patch applied, run:
The test is opt-in while it demonstrates the open bug. Default CI skips it. The diagnostic comparison leaves the ordinary post-drain refresh in place; its performance cost is unmeasured. These runs establish the buffer overwrite on software WARP. Physical GPU behavior and the proposed connection to lighting still need separate evidence.
Would it help to carry this case in the eventual fix PR, or would you prefer a separate test-only PR?
warp-reproducer.zip
@Zetsukae on GitHub · 2026-11-25 21:38 UTC · original
Thanks, this is a great reproducer, and it matches what I saw: the early refresh rewrites memory the in-flight submission still reads. Since
prewarmis onmainand not something #139 adds, a separate test-only PR againstmainseems cleanest, so the maintainer can take it on its own and a fix can land against it. One data point from here: on an RX 9060 XT, async submission measured within noise of async off (7.85 vs 7.56 fps standing), so skipping the early refresh might cost little; it would be worth measuring alongside the fix.@MamaLeVrai on GitHub · 2026-11-26 05:10 UTC · original
One side effect of the change to
watch::writing(watch.rs, the newstaleloop that callscrate::resource::textures_rewritten). It comes from reading the code; I have not run it.writingis also called where nothing is written. Twice inshadow.rson this branch, just before title memory is opened in place:crate::watch::writing(start, len)"Read-only guards would refuse the GPU's writes", followed byOpenExistingHeapFromAddress1. With this PR those calls now mark every placed texture in the window as rewritten.texture::rewrittenthen removes it fromHOST_WRITTEN: these are the textures whose contents a host copy or resolve made, while their title memory stayed as it was. At its next use such a texture would be uploaded again from the stale title memory, over what the copy wrote.That only matters for host-written textures that lie in a window opened in place, so it may be rare. Keeping the
textures_rewrittenpart out of the guard-opening calls (for example a flag, or a separate function for the write-back path) would avoid it.AI-assisted (Claude Code); no game data.
@Zetsukae on GitHub · 2026-11-26 12:21 UTC · original
Good catch, thanks. Confirmed: the two
writingcalls beforeOpenExistingHeapFromAddress1only open guards, and witha208d61they also marked the window's textures rewritten. Fixed infaac6de:watch::writingis back to opening guards only, and a newwatch::written_backdoes that and marks the textures. It's used only where we actually write title memory (the copy-backs inshadow.rs, the read-backs and title copies inhost.rs). Tests pass; the tattoo fix goes throughwritten_backunchanged.@gut0to on GitHub · 2026-11-27 15:11 UTC · original · reviewed
AI-assisted static review; I traced the new exposure-curve override parser and its shader use. I did not run the test suite.
@ -31,0 +65,4 @@let mut curve = [0.5, -9.75, 1.4];let set = std::env::var("VICTORY_AMBIENT_EXPOSURE").unwrap_or_default();for (to, v) in curve.iter_mut().zip(set.split(',')) {if let Ok(v) = v.trim().parse() {@gut0to on GitHub · 2026-11-27 15:11 UTC · original
AI-assisted review:
f32::parseacceptsNaNand infinities, soif let Oktreats them as valid and passes them into the shader constants. For example,k=NaNsatisfies the laterk != 0.0check and makes the exposure exponent NaN instead of falling back to the constant level. Could the parser requireis_finite()and add a non-finite override case?@gut0to on GitHub · 2026-11-27 15:17 UTC · original · reviewed
AI-assisted static review; I checked the new exposure formula and its documented defaults. I did not run the GPU tests.
@ -280,0 +328,4 @@if (has_exposure > 0.0 && k != 0.0) {float e = exposure.Load(int3(0, 0, 0)).y;// A plausible EV only; else the constant.if (e > -20.0 && e < 10.0) return clamp(at_ev * exp2(-k * (e - ev)), 0.01, 4.0);@gut0to on GitHub · 2026-11-27 15:17 UTC · original
AI-assisted review: the default ambient level now depends on this EV curve, whose direction and constants were tuned by hand. Could a deterministic test cover the default point (
EV = -9.75gives1.4), a darker point (EV = -5.5gives about0.3), and the fallback for an out-of-range EV? That would lock the intended behavior and catch a future sign or clamp regression.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.