|
|
@@ -22,29 +22,7 @@
|
|
|
#include "yuzu/startup_checks.h"
|
|
|
#include "yuzu/uisettings.h"
|
|
|
|
|
|
-constexpr char TEMP_FILE_NAME[] = "vulkan_check";
|
|
|
-
|
|
|
-bool CheckVulkan() {
|
|
|
- if (UISettings::values.has_broken_vulkan) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- LOG_DEBUG(Frontend, "Checking presence of Vulkan");
|
|
|
-
|
|
|
- const auto fs_config_loc = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir);
|
|
|
- const auto temp_file_loc = fs_config_loc / TEMP_FILE_NAME;
|
|
|
-
|
|
|
- if (std::filesystem::exists(temp_file_loc)) {
|
|
|
- LOG_WARNING(Frontend, "Detected recovery from previous failed Vulkan initialization");
|
|
|
-
|
|
|
- UISettings::values.has_broken_vulkan = true;
|
|
|
- std::filesystem::remove(temp_file_loc);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- std::ofstream temp_file_handle(temp_file_loc);
|
|
|
- temp_file_handle.close();
|
|
|
-
|
|
|
+void CheckVulkan() {
|
|
|
try {
|
|
|
Vulkan::vk::InstanceDispatch dld;
|
|
|
const Common::DynamicLibrary library = Vulkan::OpenLibrary();
|
|
|
@@ -53,32 +31,48 @@ bool CheckVulkan() {
|
|
|
|
|
|
} catch (const Vulkan::vk::Exception& exception) {
|
|
|
LOG_ERROR(Frontend, "Failed to initialize Vulkan: {}", exception.what());
|
|
|
- // Don't set has_broken_vulkan to true here: we care when loading Vulkan crashes the
|
|
|
- // application, not when we can handle it.
|
|
|
}
|
|
|
-
|
|
|
- std::filesystem::remove(temp_file_loc);
|
|
|
- return true;
|
|
|
}
|
|
|
|
|
|
-bool StartupChecks() {
|
|
|
+bool StartupChecks(const char* arg0, bool* has_broken_vulkan) {
|
|
|
#ifdef _WIN32
|
|
|
const bool env_var_set = SetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, "ON");
|
|
|
if (!env_var_set) {
|
|
|
- LOG_ERROR(Frontend, "SetEnvironmentVariableA failed to set {}, {}", STARTUP_CHECK_ENV_VAR,
|
|
|
- GetLastError());
|
|
|
+ std::fprintf(stderr, "SetEnvironmentVariableA failed to set %s, %d\n",
|
|
|
+ STARTUP_CHECK_ENV_VAR, GetLastError());
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- STARTUPINFOA startup_info;
|
|
|
PROCESS_INFORMATION process_info;
|
|
|
+ std::memset(&process_info, '\0', sizeof(process_info));
|
|
|
+
|
|
|
+ if (!SpawnChild(arg0, &process_info)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // wait until the processs exits
|
|
|
+ DWORD exit_code = STILL_ACTIVE;
|
|
|
+ while (exit_code == STILL_ACTIVE) {
|
|
|
+ GetExitCodeProcess(process_info.hProcess, &exit_code);
|
|
|
+ }
|
|
|
+
|
|
|
+ *has_broken_vulkan = (exit_code != 0);
|
|
|
+
|
|
|
+ CloseHandle(process_info.hProcess);
|
|
|
+ CloseHandle(process_info.hThread);
|
|
|
+#endif
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+#ifdef _WIN32
|
|
|
+bool SpawnChild(const char* arg0, PROCESS_INFORMATION* pi) {
|
|
|
+ STARTUPINFOA startup_info;
|
|
|
|
|
|
std::memset(&startup_info, '\0', sizeof(startup_info));
|
|
|
- std::memset(&process_info, '\0', sizeof(process_info));
|
|
|
startup_info.cb = sizeof(startup_info);
|
|
|
|
|
|
char p_name[255];
|
|
|
- std::strncpy(p_name, "yuzu.exe", 255);
|
|
|
+ std::strncpy(p_name, arg0, 255);
|
|
|
|
|
|
// TODO: use argv[0] instead of yuzu.exe
|
|
|
const bool process_created = CreateProcessA(nullptr, // lpApplicationName
|
|
|
@@ -90,23 +84,13 @@ bool StartupChecks() {
|
|
|
nullptr, // lpEnvironment
|
|
|
nullptr, // lpCurrentDirectory
|
|
|
&startup_info, // lpStartupInfo
|
|
|
- &process_info // lpProcessInformation
|
|
|
+ pi // lpProcessInformation
|
|
|
);
|
|
|
if (!process_created) {
|
|
|
- LOG_ERROR(Frontend, "CreateProcessA failed, {}", GetLastError());
|
|
|
+ std::fprintf(stderr, "CreateProcessA failed, %d\n", GetLastError());
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // wait until the processs exits
|
|
|
- DWORD exit_code = STILL_ACTIVE;
|
|
|
- while (exit_code == STILL_ACTIVE) {
|
|
|
- GetExitCodeProcess(process_info.hProcess, &exit_code);
|
|
|
- }
|
|
|
-
|
|
|
- std::fprintf(stderr, "exit code: %d\n", exit_code);
|
|
|
-
|
|
|
- CloseHandle(process_info.hProcess);
|
|
|
- CloseHandle(process_info.hThread);
|
|
|
-#endif
|
|
|
return true;
|
|
|
}
|
|
|
+#endif
|