vk: read a pipeline cache over 2 GB on Windows #1226
No reviewers
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!1226
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pipeline-cache-size"
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?
On Windows, pcache_init took the size of mkw_vk_pipelines.bin from ftell, which returns a 32-bit long there. Past 2 GB the size came back wrong, the read was skipped and the game started with an empty pipeline cache. The next save then wrote that run's much smaller cache over the big one, so everything the prepare had put in it was gone. Linux was not affected.
A normal cache is well under the limit (500 to 700 MB here after a prepare and 20 minutes of play), so this matters for a cache that has grown over long play or for anything that adds to it. The fix uses _fseeki64 and _ftelli64, as the shader cache reader in vk_shader.cpp already does.
Testing
Windows 11, RTX 4070 Ti SUPER, on
8b2e1d3with a local change that also keeps the GPL stage libraries in the cache (RX_VK_GPL=1), which took it to 2,151,265,735 bytes after --prepare-shaders. Without this fix the log said "pipeline cache ... (0 KB)" and the file was 882 MB after the run. With it the log said "(2100271 KB)" and the same 19-minute scripted route through eleven areas ran normally.Build checks only for the rebased commit on current main: it compiles for Windows (llvm-mingw) and Linux.
Thanks, this looks right to me.
longis 32-bit, softellfails (returns -1) once the file is past 2 GB;sz > 32was then false, the read was skipped, and the nextpipeline_cache_savereplaced the big file with the small in-memory cache. That matches what you saw._fseeki64/_ftelli64are already used elsewhere invk_draw.cpp(the pipe notes reader) andvk_shader.cpp, and on Linux they come from thehost/posix/windows.hshim (fseeko/ftello), so nothing new is needed for the Linux build. Linux behaviour is unchanged sincelongwas already 64-bit there._ftelli64still falls throughsz > 32and starts with an empty cache, same as before.ci.initialDataSizeissize_t, so a >2 GB blob goes to the driver intact.No test for this, but I don't think one is worth it for a three-line change like this.