From 35efedd74799182c9e9091d7b7cd1ac649764a24 Mon Sep 17 00:00:00 2001 From: JJenkx Date: Thu, 29 Oct 2026 16:38:18 -0400 Subject: [PATCH] fix(shader): give a device-path shader cache root the long-path form on Windows NativeCachePath_nid_no_patch returned a path that already started with \.\ unchanged. Unlike \?\, a \.\ path is still parsed by Win32 and limited to MAX_PATH, so with ANYPS5_SHADER_CACHE_DIR=\.\C:\... and a moderately deep root (a ~140-character TEMP is enough) the versioned cache entries crossed 260 characters and could not be written. A \.\ path now goes through GetFullPathNameW like the others, and a drive path in that form (\.\X:\...) becomes the equivalent \?\X:\...; other device names are kept as they are. Co-Authored-By: Claude Opus 5.5 --- core/shader/recompiler/ShaderCacheDirectory.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/shader/recompiler/ShaderCacheDirectory.hpp b/core/shader/recompiler/ShaderCacheDirectory.hpp index d46558890b8d..b822e82fcb83 100644 --- a/core/shader/recompiler/ShaderCacheDirectory.hpp +++ b/core/shader/recompiler/ShaderCacheDirectory.hpp @@ -37,7 +37,7 @@ std::filesystem::path ShaderCacheDirectory(); inline std::filesystem::path NativeCachePath_nid_no_patch(const std::filesystem::path& path, std::error_code& error) { auto native = path; native.make_preferred(); - if (native.native().starts_with(L"\\\\?\\") || native.native().starts_with(L"\\\\.\\")) return native; + if (native.native().starts_with(L"\\\\?\\")) return native; const auto capacity = GetFullPathNameW(native.c_str(), 0, nullptr, nullptr); if (capacity == 0) { error = std::error_code(GetLastError(), std::system_category()); return {}; } std::wstring absolute(capacity, L'\0'); @@ -47,6 +47,10 @@ inline std::filesystem::path NativeCachePath_nid_no_patch(const std::filesystem: return {}; } absolute.resize(size); + if (absolute.starts_with(L"\\\\.\\")) { + if (absolute.size() >= 6 && absolute[5] == L':') return std::filesystem::path(L"\\\\?\\" + absolute.substr(4)); + return std::filesystem::path(absolute); + } if (absolute.starts_with(L"\\\\")) return std::filesystem::path(L"\\\\?\\UNC\\" + absolute.substr(2)); return std::filesystem::path(L"\\\\?\\" + absolute); }