shadow: use the existing AVX2 compare for the refresh and copy-back runs #145
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!145
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@lido772 on GitHub · 2026-11-27 18:51 UTC · original
lido772:avx2-refresh-compare→main· +2 −2 · 1 files · 2 commits · merged 2026-11-28 19:39 UTCTwo 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.