Detect D3D9 CreateDevice / CreateDeviceEx failures (#388)

## Link to GitHub Issue, if one exists
#345 

## Description of change
Show a block of warning text if the game crashes after CreateDevice(Ex)
fails.

## Testing
Tested by injecting invalid resolution into spicecfg.
This commit is contained in:
bicarus-dev
2025-09-30 22:13:02 -07:00
committed by GitHub
parent b487cf2bcf
commit d3fa27ae4a
3 changed files with 34 additions and 1 deletions
+23 -1
View File
@@ -35,6 +35,8 @@ namespace launcher::signal {
bool SUPERSTEP_SOUND_ERROR = false;
bool AVS_DIR_CREATION_FAILURE = false;
std::string AVS_SRC_PATH;
bool D3D9_CREATE_DEVICE_FAILED = false;
uint32_t D3D9_CREATE_DEVICE_FAILED_HRESULT;
}
#define V(variant) case variant: return #variant
@@ -137,7 +139,8 @@ static LONG WINAPI TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *Exception
log_warning("signal", "audio initialization error was previously detected during boot!");
log_warning("signal", " (W:SuperstepSound: Audio device is not available!!!)");
log_warning("signal", " this crash is most likely related to audio init failure");
log_warning("signal", " fix your audio device, double check your audio options/patches, and try again");
log_warning("signal", " see if the default audio device changed, fix your audio configuration (e.g., sample rate)");
log_warning("signal", " double check your spice audio options/patches, and try again");
}
if (launcher::signal::AVS_DIR_CREATION_FAILURE) {
@@ -152,6 +155,25 @@ static LONG WINAPI TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *Exception
log_warning("signal", " fix the XML file and try again");
}
if (launcher::signal::D3D9_CREATE_DEVICE_FAILED) {
log_warning("signal",
"D3D9 CreateDevice/CreateDeviceEx failed with {:#x}!",
launcher::signal::D3D9_CREATE_DEVICE_FAILED_HRESULT);
log_warning("signal",
" this is a common graphics / monitor issue");
log_warning("signal",
" double check any graphics options you configured in spicecfg");
log_warning("signal",
" double check that your monitor supports the resolution + refresh rate that the game needs");
log_warning("signal",
" enable GPU-side resolution scaling in your GPU options as needed");
log_warning("signal",
" if you have three or more monitors, try unplugging them down to one or two, or enable -graphics-force-single-adapter option");
log_warning("signal",
" failing all that, see if enabling windowed mode helps");
}
// walk the exception chain
struct _EXCEPTION_RECORD *record_cause = ExceptionRecord->ExceptionRecord;
while (record_cause != nullptr) {