Vulkan: Use LLVM shader compiler for BOTW on Linux + Mesa (#1857)

Workaround for GPU crashes when using certain runes in BOTW
Can be overridden by setting RADV_DEBUG=aco
This commit is contained in:
goeiecool9999 2026-04-04 19:14:49 +02:00 committed by GitHub
parent b3e310220e
commit b9b46ecb65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -621,6 +621,35 @@ bool MainWindow::FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATE
cemuLog_log(LogType::Force, "GameMode has been started.");
}
}
#endif
// Workaround for BOTW + Mesa. Runes like Magnesis and the camera cause GPU crashes.
// Using the LLVM shader compiler prevents crashes which points to an issue with the default ACO compiler.
// Either that or Cemu is violating a specification (GLSL?) causing the shaders to be broken after compilation.
#if BOOST_OS_LINUX
uint64 currentTitleId = CafeSystem::GetForegroundTitleId();
if (currentTitleId == 0x00050000101c9500 || currentTitleId == 0x00050000101c9400 || currentTitleId == 0x00050000101c9300)
{
// if the variable is empty set it to llvm, otherwise check if it contains llvm/aco and if not append it
if (const char* value; (value = getenv("RADV_DEBUG")) != NULL && strlen(value) != 0)
{
std::string valueStr{value};
// only append ,llvm when llvm or aco are not already passed as flags.
// "aco" is not a mesa flag (anymore, it used to be when llvm was default)
// but it will provide users with a way to override this workaround by setting RADV_DEBUG=aco
// should parse the flag list but there are currently no other flags containing llvm or aco as a substring
if (valueStr.find("llvm") == std::string::npos && valueStr.find("aco") == std::string::npos)
{
valueStr.append(",llvm");
setenv("RADV_DEBUG", valueStr.c_str(), 1);
}
}
else
{
setenv("RADV_DEBUG", "llvm", 1);
}
}
#endif
CreateCanvas();