PreBuilt Shaders Do Nothing - Each unique hardware setup has to compile unique shaders #617
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot#617
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?
Including precompiled shaders is an absolute waste of time.
Shaders are compiled for your specific hardware. Other people's shaders are not usable. You will compile your own anyway.
If anything precompiled shaders that aren't yours will likely cause issues.
You're right about one part, compiled shader/pipeline binaries are specific to the GPU and driver version, so sharing someone else's driver cache (in Hookshot's case mkw_vk_pipelines.bin) doesn't help anyone.
But two things are worth clarifying:
They won't "cause issues". A Vulkan pipeline cache carries the vendor ID, device ID and pipelineCacheUUID in its header, and a mismatched one just gets thrown out. Hookshot already checks this (gpu/vk/vk_draw.cpp, around line 538: it compares against dev.props.pipelineCacheUUID and falls back to an empty cache). Worst case it's wasted disk space, nothing breaks.
There's a different file that would be useful to share: hookshot_pipelines.bin.
From the code, this isn't compiled GPU code. It's a list of PipeNote records: pipeline key, program hash, topology, color/depth formats, sample count and the NVN render state. Basically which pipelines the game needs and how they're configured. precompile_run() reads it at startup and builds those pipelines locally, on your own GPU, before you play.
That list is hardware-independent. It's the same idea behind Steam's Fossilize (share pipeline state, compile locally) and SCSKiller's shared hash database. And it contains no game data: the actual shaders stay in each player's own hookshot_shaders.bin, built from their own dump.
Right now every player has to "record" this list by playing each area at least once, which is where the first visit stutter comes from. If the notes from players who've already been through the game could be merged in, a fresh install could precompile the full set before the first start.
Suggestion for @notrexed: an optional folder next to the exe whose files get merged into the notes at precompile_run(), skipping any whose header stamp doesn't match program_cache_stamp(). The version check is already there, so this should be a fairly small change.
this is from reading the source, I haven't tested swapping notes files between machines yet.
"Worst case it's wasted disk space"
Don't be wasting my diskspace please.
Obviously the hookshot_pipelines.bin isn't what I'm talking about.
There's been a persistent myth about sharing shaders going back to the early days of Switch emulation. One of the patch notes makes it seem like that's what's happening.
Thanks for the idea. Feature requests are now collected in #1007, which lists this one with a link back here, so closing it in favour of that list (this is not a decision against the idea).
wtf not planned?
You can't share shaders. It doesn't work. Don't waste my disk space with shaders from other hardware I need to compile anyway.