Reconsider GPU hasher for GPU side page change detection #1355
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/fxceless--victory-fork#1355
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@JayFoxRox on GitHub · 2026-11-26 17:55 UTC · original
I've mentioned the hasher in #1273 and this was split into issue #1306 where the GPU hasher only had a minor mention.
However, my overall criticism of the GPU hasher system was lost, so I'm additionally creating this issue.
There's a GPU hasher in VIctory which hashes GPU pages on (what are assumed to be) free GPU compute resources.
It's a cool idea and it was done because the developers system had leftover GPU compute resources.
However, on other machines this might not hold true and there might not be spare GPU compute.
It also doesn't consider the effects on VRAM memory bandwidth / overall performance impact.
Instead, identifiying the root cause of the GPU side changes (= which GPU shader modified them and why?) could help to only run the hasher on GPU resources which are potentially modified OR to let the shader itself communicate wether (and which) resources got updated (something like a resource-dirty flag).
This could happen by shader analysis, learning shader behaviour(by observing runtime behaviour, which might be faulty approach as rare cases could remain undetected) or potentially other means.
With #1306 there is also another alternative where GPU resources would only be hashed on demand if and when the CPU tries to read from them. However, this could be potentially also be replaced by shader analysis / identifying if it's just poor CPU code which tries to read static GPU resources (comparable to accidental read on write-combine) or actually necessary (read on a resource which might have changed due to some GPU behaviour / shader execution).
@liuycsbxbxn on GitHub · 2026-11-26 19:00 UTC · original
Agreed on the criticism, and I would rather turn it into a measurement than an argument, because the arithmetic decides it either way.
The cheap numbers, and which of them need a card:
One more thing the hasher assumption understates: "free compute" competes with whatever else wants the async queue at the same time, and that contention shows up as tail latency rather than throughput. So a hasher that looks free in an average can still be the reason a texture arrived a frame late.
If you want, I can make the recorder report "pages read but unchanged" as a separate bucket - that is the number that says whether #1306 is a real optimisation or just avoids a fault that would not have mattered. It is the same recorder, one more counter.
@JayFoxRox on GitHub · 2026-11-26 19:34 UTC · original
re 1. Also note that hashing on demand might cause latency, hence the idea to do static analysis (for shaders to mark resources dirty themselves) OR always load pages but only when actually necessary (which is suitable if the current code finds that pages are almost always updated anyway = no need to check through hash). Remember that there might be readbacks which shouldn't be necessary / don't need any download (like accidental write-combine read on static resource) which would be excluded [1].
re 2. Yes.
re 3. You can't measure this easily. You'd only have the measurement on your developer machine (or user submitted results if measurement code lives in VIctory and results get crowdsourced) but the ultimate goal is to distribute this project to end users who won't submit measurements (in particular if there game runs so slow that they don't see point in submitting). In fact, supporting lower end machines is also a goal, so we have to assume that there's no spare GPU compute or VRAM bandwidth available (as you also implied in one of your paragraphs re async queue).
"pages read but unchanged" would be a poor metric for deciding about #1306, because that is about removing the overhead to even reach the code where such a metric would be recorded (it's useful independent of wether the fault matters, unless that number is 0.. in which case the fault handler is useless).
Footnotes:
[1] This also affects your "pages read but unchanged" measurement - it must be a per-page-read-code-location measurement, potentially even respecting the call stack OR a per-resource/associated-with-shared-X thing. It's certainly not trivial to formulate the actual scope.