PreBuilt Shaders Do Nothing - Each unique hardware setup has to compile unique shaders #617

Closed
opened 2026-11-08 14:32:19 +00:00 by Intoxicus · 4 comments
Intoxicus commented 2026-11-08 14:32:19 +00:00 (Migrated from github.com)

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.

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.
tillo88 commented 2026-11-08 15:14:39 +00:00 (Migrated from github.com)

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:

  1. 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.

  2. 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.

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: 1. 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. 2. 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.
Intoxicus commented 2026-11-08 15:28:37 +00:00 (Migrated from github.com)

"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.

"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.
NotRexed commented 2026-11-09 05:51:30 +00:00 (Migrated from github.com)

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).

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).
Intoxicus commented 2026-11-09 12:56:04 +00:00 (Migrated from github.com)

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.

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.
Commenting is not possible because the repository is archived.
No milestone
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Hookshot#617
No description provided.