@ -57,7 +57,7 @@ bool CheckEnvVars(bool* is_child) {
return false ;
return false ;
}
}
bool StartupChecks ( const char * arg0 , bool * has_broken_vulkan ) {
bool StartupChecks ( const char * arg0 , bool * has_broken_vulkan , bool perform_vulkan_check ) {
# ifdef _WIN32
# ifdef _WIN32
// Set the startup variable for child processes
// Set the startup variable for child processes
const bool env_var_set = SetEnvironmentVariableA ( STARTUP_CHECK_ENV_VAR , ENV_VAR_ENABLED_TEXT ) ;
const bool env_var_set = SetEnvironmentVariableA ( STARTUP_CHECK_ENV_VAR , ENV_VAR_ENABLED_TEXT ) ;
@ -67,29 +67,32 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan) {
return false ;
return false ;
}
}
PROCESS_INFORMATION process_info ;
if ( perform_vulkan_check ) {
std : : memset ( & process_info , ' \0 ' , sizeof ( process_info ) ) ;
// Spawn child process that performs Vulkan check
PROCESS_INFORMATION process_info ;
std : : memset ( & process_info , ' \0 ' , sizeof ( process_info ) ) ;
if ( ! SpawnChild ( arg0 , & process_info , 0 ) ) {
if ( ! SpawnChild ( arg0 , & process_info , 0 ) ) {
return false ;
return false ;
}
}
// Wait until the processs exits and get exit code from it
// Wait until the processs exits and get exit code from it
WaitForSingleObject ( process_info . hProcess , INFINITE ) ;
WaitForSingleObject ( process_info . hProcess , INFINITE ) ;
DWORD exit_code = STILL_ACTIVE ;
DWORD exit_code = STILL_ACTIVE ;
const int err = GetExitCodeProcess ( process_info . hProcess , & exit_code ) ;
const int err = GetExitCodeProcess ( process_info . hProcess , & exit_code ) ;
if ( err = = 0 ) {
if ( err = = 0 ) {
std : : fprintf ( stderr , " GetExitCodeProcess failed with error %d \n " , GetLastError ( ) ) ;
std : : fprintf ( stderr , " GetExitCodeProcess failed with error %d \n " , GetLastError ( ) ) ;
}
}
// Vulkan is broken if the child crashed (return value is not zero)
// Vulkan is broken if the child crashed (return value is not zero)
* has_broken_vulkan = ( exit_code ! = 0 ) ;
* has_broken_vulkan = ( exit_code ! = 0 ) ;
if ( CloseHandle ( process_info . hProcess ) = = 0 ) {
if ( CloseHandle ( process_info . hProcess ) = = 0 ) {
std : : fprintf ( stderr , " CloseHandle failed with error %d \n " , GetLastError ( ) ) ;
std : : fprintf ( stderr , " CloseHandle failed with error %d \n " , GetLastError ( ) ) ;
}
}
if ( CloseHandle ( process_info . hThread ) = = 0 ) {
if ( CloseHandle ( process_info . hThread ) = = 0 ) {
std : : fprintf ( stderr , " CloseHandle failed with error %d \n " , GetLastError ( ) ) ;
std : : fprintf ( stderr , " CloseHandle failed with error %d \n " , GetLastError ( ) ) ;
}
}
}
if ( ! SetEnvironmentVariableA ( STARTUP_CHECK_ENV_VAR , nullptr ) ) {
if ( ! SetEnvironmentVariableA ( STARTUP_CHECK_ENV_VAR , nullptr ) ) {
@ -98,26 +101,28 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan) {
}
}
# elif defined(YUZU_UNIX)
# elif defined(YUZU_UNIX)
const pid_t pid = fork ( ) ;
if ( perform_vulkan_check ) {
if ( pid = = 0 ) {
const pid_t pid = fork ( ) ;
CheckVulkan ( ) ;
if ( pid = = 0 ) {
return true ;
CheckVulkan ( ) ;
} else if ( pid = = - 1 ) {
return true ;
const int err = errno ;
} else if ( pid = = - 1 ) {
std : : fprintf ( stderr , " fork failed with error %d \n " , err ) ;
const int err = errno ;
return false ;
std : : fprintf ( stderr , " fork failed with error %d \n " , err ) ;
}
return false ;
}
// Get exit code from child process
// Get exit code from child process
int status ;
int status ;
const int r_val = wait ( & status ) ;
const int r_val = wait ( & status ) ;
if ( r_val = = - 1 ) {
if ( r_val = = - 1 ) {
const int err = errno ;
const int err = errno ;
std : : fprintf ( stderr , " wait failed with error %d \n " , err ) ;
std : : fprintf ( stderr , " wait failed with error %d \n " , err ) ;
return false ;
return false ;
}
// Vulkan is broken if the child crashed (return value is not zero)
* has_broken_vulkan = ( status ! = 0 ) ;
}
}
// Vulkan is broken if the child crashed (return value is not zero)
* has_broken_vulkan = ( status ! = 0 ) ;
# endif
# endif
return false ;
return false ;
}
}