shadow: use the existing AVX2 compare for the refresh and copy-back runs #145
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/145"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by lido772 on 2026-11-27T18:51:29Z.
Two hot call sites compared whole pages with the scalar
dword_runs(.., 0)althoughword_runs()is exactly that call with an AVX2 implementation when it can use one, and afallback to the same scalar call when it cannot (unaligned, different lengths, no AVX2).
Its only other user was
send_changed, behindwords_under().Shadow::take: the compare a refresh makes for a host copy,dword_runs(at, held, title, 0).put_changed: the runs written back when shaders wrote into a copy, same call.Measured (release build with diagnostics, same scene, same switch set)
The submitting thread's
refreshesfigure, normalised per span because the scene's spancount moves between samples:
-8.5 % per span, about 2.4 ms a frame off the submitting thread. The unchanged average
run size is the check that these are the same runs and only the compare got wider;
VICTORY_REFRESH_SPLIT=1reports the same MB copied before and after (38-47 MB, 890-1077runs a frame), as it must.
Why it is safe
word_runsis not new logic: it already existed forsend_changed, andshadow::merge_tests::word_runs_are_the_dword_runsasserts over random rounds that itreports exactly what
dword_runs(.., 0)does. Both tests pass on this branch. The fallbackis the identical scalar call, so the only thing that changes is the instruction used, never
the runs reported.
A third site (
~3981, in the landing path) already usesword_runsbehindhost::words_under()and was deliberately left alone: that guard is load-bearing, becauseit pairs with the
goes_as_wordsfilter, so relaxing it would change which runs arereported rather than just how fast they are found.
How it was found
Timing the refresh path showed ~71.6 MB of title memory compared per frame to find the
~47 MB that actually changed, with only ~32 % of sampled rewritten pages differing at all.
That is a comparison-bound path, not a copy-bound one - which is what made an unused AVX2
compare worth looking for.