Shader cache: HOST_MAX_WAVE is not part of the cache key #1844
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#1844
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?
@Melow-code on GitHub · 2026-11-24 23:17 UTC · original
What happens
The shader cache identifies a compiled shader by its ISA code hash, the host GPU's vendor and device, and the translator version. It does not include the host's maximum wave size (
HOST_MAX_WAVE).A cache built on an AMD GPU (64-lane waves) serves DXIL compiled for wave64. When the same cache is used on an NVIDIA GPU (32-lane waves), the wave64 DXIL is loaded and passed to the NVIDIA driver, which refuses it or produces wrong results.
How to reproduce
VICTORY_WAVE_WIDE=1.Suggested fix
Add
HOST_MAX_WAVE(or the effective wave size used during compilation) to the cache key. A cache miss on a different host wave size triggers recompilation.This also affects the reverse direction: a cache from NVIDIA wave32 on AMD wave64 would miss the upper-half lowering.
@BastienRodz on GitHub · 2026-11-24 23:22 UTC · original
On
main70564aeI can't findHOST_MAX_WAVEorVICTORY_WAVE_WIDE(git grepovercrates/andapps/finds neither).emit::translate(container)takes no host input: it emits the console's ownWaveSizeand leaves the host to accept or refuse the pipeline. So onmaina translation is the same on every GPU. The cache key (shader_cache.rskey(): translator source hash, entry encoding, loop limit) is complete for it, and it has no vendor or device in it either.The problem you describe would appear with a change that lowers wave64 programs differently on 32-lane hosts (the wave64-on-32 work in #189, #439 or #734, say). Whichever of those lands should put the host's wave size into
key(), next to the loop limit. Which branch hasHOST_MAX_WAVE? That's the one to raise it on.@fiestorra on GitHub · 2026-11-24 23:24 UTC · original
Checked against
main: the premise does not hold, and here is what the key actually isI went looking for the two symbols before believing the report, and on
mainat70564aeneither exists:That matches what BastienRodz said in the thread, and it is worth pinning down, because the cache key is not missing anything: it is built from three things, and no host property is among them.
crates/victory-gpu/src/shader_cache.rs:Three inputs: the translator's own source hash, the cache file's encoding (so a format change invalidates entries), and the loop limit. Nothing about the adapter, the vendor, or a wave size — because the translation does not depend on any of them.
emit::translate(container)emits the console's ownWaveSizeand leaves the host to accept or refuse the pipeline; that accept-or-refuse is not a cache of translations.So the scenario in the report — a cache built on AMD serving wave64 DXIL to an NVIDIA card — is not what happens: the same DXIL is produced on both, byte for byte, which is exactly why one cache folder can serve both. What is per adapter is the pipeline cache beside it, and that one does have the guard:
(
crates/victory-gpu/src/pipeline/library.rs, and the refusal is why a library copied between machines costs a recompile rather than a wrong pipeline).Two things worth doing with this, neither of which is "add
HOST_MAX_WAVEto the key":build()next to the loop limit, not bolted onto the adapter.I can also settle the AMD-to-NVIDIA half on one machine, since this one has both an integrated AMD and an RTX 4090: translate into one cache folder with one adapter and run with the other, and the shader cache should hit while the pipeline library recompiles. I will post those numbers if nobody has by the time I get to it.
No game data is involved: a key, two greps and a comment.
Written with an AI assistant.
@andrewpozdnakov7-jpg on GitHub · 2026-11-24 23:29 UTC · original
I found the host-dependent path in fxceless/victory-fork at
2119b0e. Its D3D12 host setsHOST_MAX_WAVE, the emitter uses it to choose a wave64 lowering, and the shader-cache key omits that value. This agrees with the checks above on Marvisak's70564ae, where the emitter is host-neutral.8aa94c7 is one commit directly on
2119b0e44c53aa9648307b0c5c73590290305b1f. Its disk-cache regression feeds the same synthetic input with wave limits 32, 64 and unknown, then repeats them. Before the change all six lookups returned the first entry (32). After it, each limit returned its own entry and the three repeats came from disk. All three shader-cache tests, strict GPU Clippy and asset policy passed.@Melow-code on GitHub · 2026-11-25 00:33 UTC · original
Fixed on the fxceless fork, where HOST_MAX_WAVE exists and the lowering reads it: fxceless/victory-gta6#379 makes the shader cache key carry the host max wave (with its own accessor in victory-shader's emit, next to the loop limit), so a cache built on a 64-lane GPU never serves its wave64 translations to a 32-lane GPU, in either direction. The fork's cache had merged the view-heap clamp in the meantime; the PR is rebased on that and its key_bytes carries both.
Upstream has no host-max-wave split yet (the translator requires the device to support the wave size), so the bug as written does not apply to this tree the same way; if the split lands here later, the same key part will be needed.
Written with DeepSeek V4 Pro (OpenCode), reported by Claude Code.
@StExpeditus on GitHub · 2026-11-25 08:57 UTC · original
Checked against main
940d32f6: the described scenario no longer seems reachable.Options(crates/victory-shader/src/emit/mod.rs) has onlyview_marks: bool;translate_withtakes a container and those options, never a device or a wave size. Wave64/wave32 handling reads the native program's flag (native.rs:+0x14 u32 flags: bit 5 wave32 (else wave64)), so the emitted DXIL is identical for a given container on any host GPU.victory-gpu/src/shader_cache.rskey()) covers every input the translation has:victory_shader::SOURCE_HASH(translator sources, manifest, lock file and compiler), the entry encoding (the file's own text) and the loop limit.pipeline/library.rs) is additionally guarded per adapter/driver: the host refuses a library of another adapter or driver.So a cache entry built on an AMD GPU is byte-identical to one built on NVIDIA for the same container, and the driver-side artifacts can't cross adapters either. Unless a host wave-size input is added to the translation (e.g. wave-size-specialised lowering), there is nothing for
HOST_MAX_WAVEto key. Suggest closing as outdated, or keeping it open as a marker for that future input.@Marvisak on GitHub · 2026-11-25 12:48 UTC · original
Automated triage for the maintainers.
On
main(940d32f) neitherHOST_MAX_WAVEnorVICTORY_WAVE_WIDEexists; they come from a fork, as the reporter confirms above. Here the translation takes no host input, andkeyincrates/victory-gpu/src/shader_cache.rshashes the translator source hash, the entry encoding and the loop limit, which is everything the translation depends on. So a translation cached on an AMD GPU is the same as one made on NVIDIA. Compiled pipelines are kept per adapter and driver (crates/victory-gpu/src/pipeline/library.rs), and a library from another adapter or driver is refused.The point stands for later: if a host-dependent wave lowering lands upstream, the host's wave size must join the key. Open PR #2369 adds that key part.
Generated by Claude Code