Resource labels: name GPU resources with content hashes #1309
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#1309
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?
@liuycsbxbxn on GitHub · 2026-11-26 13:34 UTC · original
Suggestion from the discussion below, kept here so the issue states the current plan.
Label = kind + content hash (+ size). No game knowledge inside the label. The source archive name and the offset are not always known at upload time, so they are not inputs.
The hash lives in the D3D compatibility layer, where GPU resources are uploaded and downloaded, independent of game code. The Victory-side code only ever sees content; anything game-specific has to come from outside.
Names come from an external table, keyed by (kind, hash):
Unrecognised hashes are a diagnostic, not a failure. A resource we cannot name is likely either generated at runtime or corrupted on the CPU -> GPU upload path, so it should surface as its own counter rather than being silently skipped.
Second consumer: texture downscaling for lower memory usage - an allow/deny list keyed by the same content hash. That is the argument for making the hash canonical rather than per-feature.
Open questions:
Acceptance (revised):
@JayFoxRox on GitHub · 2026-11-26 17:27 UTC · original
re 1:
I don't think the source-archive name etc. are always known.
This hashing would have to live in the D3D compatibility layer where GPU resources are uploaded / downloaded, independent of the game-code.
So the portion in VIctory would only have access to the content but not to any game-specific knowledge (unless further stack analysis was added, but even then tracking sources for the game data would be difficult).
The proposal is to exclusively hash the buffer content (and lookup the name from a hashmap).
The hashmap would be built from things such as:
More motivation:
Knowing the resource name at runtime (outside of D3D12) might be helpful when analyzing UMA emulation or shader bugs.
Another example would be texture downscaling to lower memory usage: by identifying the corresponding game resource using the content hash, there could be a allow/denylist for texture downscaling.
So while this debug labelling is obviously a slow/debug feature, a faster variant could be designed if it's deemed useful (which can be figured out by doing the slow content hashing).
If such a change in VIctory is unwanted, a script for handling PIX or RenderDoc (traces or API) could be made to hash the content in those tools and to find and assign names then. However, for things like shaders, a lot of the original information would already be lost (as traces would work on VIctory DXIL rather than hashing RDNA2 structures, so hashtables would need to update with VIctory code changes).
The idea for this came from my previous work on an original Xbox emulator (which also uses UMA). There, we successfully used GL debug labels to communicate CPU side addresses of GL resources initially to ease debugging. Later I also added content hashes for testing hacks/workarounds in specific games - it had led to many compatibility and performance related improvements by providing context about the games intent. Dynamicly generated and broken resources were also identifieable (as unrecognized resources likely got corrupted along the CPU -> GPU upload path or they were generated on the fly).
@liuycsbxbxn on GitHub · 2026-11-26 17:30 UTC · original
Agreed on all three constraints: drop the archive name and offset from the label, keep the hashing in the compatibility layer where upload/download happens, and resolve names from a table instead of trying to know them. Let me restate the scope that follows, so we are arguing about the same thing:
Two questions before I prototype anything:
If that shape is right, the part I can build and test without a card is the labeler, the table lookup and the unrecognised-resource report.
@liuycsbxbxn on GitHub · 2026-11-26 17:56 UTC · original
Prototype is up for the CPU side: 26 tests, green, no warnings. A labeler, an XXH64 behind a ContentHasher trait, a text table with version/algo headers, and an unrecognised-resource report.
Three things I made concrete that you may want to push back on:
XXH64 is a placeholder behind the trait, so your call on xxh3-64 vs truncated blake3 is a one-file change plus a table version bump. Still waiting on that and on which shader bytes to key on before I wire anything into the upload path.