speed up editor beat bar drawing (frame rate is not 3x as fast!)
fixed inaccurate 2k/xp video card detection
This commit is contained in:
@@ -14,6 +14,17 @@ struct VideoDriverInfo
|
||||
CString sDeviceID;
|
||||
};
|
||||
|
||||
|
||||
void LogVideoDriverInfo( VideoDriverInfo info )
|
||||
{
|
||||
LOG->Info("Video Driver Information:");
|
||||
LOG->Info("%-15s:\t%s", "Provider", info.sProvider.GetString());
|
||||
LOG->Info("%-15s:\t%s", "Description", info.sDescription.GetString());
|
||||
LOG->Info("%-15s:\t%s", "Version", info.sVersion.GetString());
|
||||
LOG->Info("%-15s:\t%s", "Date", info.sDate.GetString());
|
||||
LOG->Info("%-15s:\t%s", "DeviceID", info.sDeviceID.GetString());
|
||||
}
|
||||
|
||||
CString GetRegValue( HKEY hKey, CString sName )
|
||||
{
|
||||
char szBuffer[MAX_PATH];
|
||||
@@ -24,10 +35,11 @@ CString GetRegValue( HKEY hKey, CString sName )
|
||||
return "";
|
||||
}
|
||||
|
||||
bool GetDebugInfoWin9x( VideoDriverInfo& infoOut )
|
||||
bool GetVideoDriverInfo9x( int iIndex, VideoDriverInfo& infoOut )
|
||||
{
|
||||
HKEY hkey;
|
||||
if (RegOpenKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Class\\Display\\0000", &hkey) != ERROR_SUCCESS)
|
||||
CString sKey = ssprintf("SYSTEM\\CurrentControlSet\\Services\\Class\\Display\\%04d",iIndex);
|
||||
if (RegOpenKey(HKEY_LOCAL_MACHINE, sKey, &hkey) != ERROR_SUCCESS)
|
||||
return false;
|
||||
|
||||
infoOut.sDate = GetRegValue( hkey, "DriverDate");
|
||||
@@ -41,10 +53,11 @@ bool GetDebugInfoWin9x( VideoDriverInfo& infoOut )
|
||||
}
|
||||
|
||||
|
||||
bool GetDebugInfoWinNT( VideoDriverInfo& infoOut )
|
||||
bool GetVideoDriverInfo2k( int iIndex, VideoDriverInfo& infoOut )
|
||||
{
|
||||
HKEY hkey;
|
||||
if (RegOpenKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}\\0000", &hkey) != ERROR_SUCCESS)
|
||||
CString sKey = ssprintf("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}\\%04d",iIndex);
|
||||
if (RegOpenKey(HKEY_LOCAL_MACHINE, sKey, &hkey) != ERROR_SUCCESS)
|
||||
return false;
|
||||
|
||||
infoOut.sDate = GetRegValue( hkey, "DriverDate");
|
||||
@@ -57,79 +70,78 @@ bool GetDebugInfoWinNT( VideoDriverInfo& infoOut )
|
||||
return true;
|
||||
}
|
||||
|
||||
void HandleKnownTerribleDriver( VideoDriverInfo info )
|
||||
{
|
||||
struct ProblemAndBookmark
|
||||
{
|
||||
char szProblemProvider[1024];
|
||||
char szProblemDescription[1024];
|
||||
char szReadMeBookmark[64];
|
||||
};
|
||||
ProblemAndBookmark ENTRIES[] =
|
||||
{
|
||||
// Hacked around the bug in the V3 driver. -Chris
|
||||
// {"3dfx Interactive, Inc. (Optimized by Amigamerlin)", "Voodoo3 PCI", "Voodoo3"},
|
||||
{"blah", "blah", "Voodoo3"},
|
||||
};
|
||||
const int NUM_ENTRIES = sizeof(ENTRIES) / sizeof(ENTRIES[0]);
|
||||
|
||||
for( int i=0; i<NUM_ENTRIES; i++ )
|
||||
CString GetPrimaryVideoName9xAnd2k() // this will not work on 95 and NT b/c of EnumDisplayDevices
|
||||
{
|
||||
|
||||
typedef BOOL (WINAPI* pfnEnumDisplayDevices)(PVOID,DWORD,PDISPLAY_DEVICE,DWORD);
|
||||
pfnEnumDisplayDevices EnumDisplayDevices;
|
||||
HINSTANCE hInstUser32;
|
||||
|
||||
hInstUser32 = LoadLibrary("User32.DLL");
|
||||
if( !hInstUser32 )
|
||||
return "";
|
||||
|
||||
// VC6 don't have a stub to static link with, so link dynamically.
|
||||
EnumDisplayDevices = (pfnEnumDisplayDevices)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
|
||||
if( EnumDisplayDevices == NULL )
|
||||
{
|
||||
if( info.sProvider == ENTRIES[i].szProblemProvider &&
|
||||
info.sDescription == ENTRIES[i].szProblemDescription )
|
||||
FreeLibrary(hInstUser32);
|
||||
return "";
|
||||
}
|
||||
|
||||
CString sPrimaryDeviceName;
|
||||
for( DWORD i=0; true; i++ )
|
||||
{
|
||||
DISPLAY_DEVICE dd;
|
||||
ZERO( dd );
|
||||
dd.cb = sizeof(dd);
|
||||
if( !EnumDisplayDevices(NULL, i, &dd, 0) )
|
||||
break;
|
||||
if( dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE )
|
||||
{
|
||||
CString sQuestion = ssprintf(
|
||||
"Video Driver Information:\n\n"
|
||||
"Provider: %s\n"
|
||||
"Description: %s\n"
|
||||
"Version: %s\n"
|
||||
"Date: %s\n"
|
||||
"DeviceID: %s\n"
|
||||
"\n"
|
||||
"This video driver is known to have bugs that make StepMania unplayable.\n"
|
||||
"Click OK to see information on where to find a newer driver.\n"
|
||||
"Click Cancel to dismiss this warning and continue playing.",
|
||||
info.sProvider.GetString(),
|
||||
info.sDescription.GetString(),
|
||||
info.sVersion.GetString(),
|
||||
info.sDate.GetString(),
|
||||
info.sDeviceID.GetString() );
|
||||
if( IDOK == MessageBox(NULL, sQuestion, "Known problem driver", MB_ICONHAND|MB_OKCANCEL) )
|
||||
{
|
||||
char szBuffer[MAX_PATH];
|
||||
GetCurrentDirectory( MAX_PATH, szBuffer );
|
||||
GotoURL( ssprintf("%s/README-FIRST.html#%s", szBuffer, ENTRIES[i].szReadMeBookmark) );
|
||||
exit(1); // Is there a better way to clean up? -Chris
|
||||
}
|
||||
else
|
||||
return;
|
||||
sPrimaryDeviceName = (char*)dd.DeviceString;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FreeLibrary(hInstUser32);
|
||||
return sPrimaryDeviceName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void GetDisplayDriverDebugInfo()
|
||||
{
|
||||
VideoDriverInfo info;
|
||||
|
||||
if( GetDebugInfoWin9x(info) )
|
||||
goto got_debug_info;
|
||||
if( GetDebugInfoWinNT(info) )
|
||||
goto got_debug_info;
|
||||
CString sPrimaryDeviceName = GetPrimaryVideoName9xAnd2k();
|
||||
|
||||
LOG->Warn( "Failed to get video card driver info." );
|
||||
return;
|
||||
if( sPrimaryDeviceName == "" )
|
||||
LOG->Info( "Primary display driver could not be determined." );
|
||||
else
|
||||
LOG->Info( "Primary display driver: %s", sPrimaryDeviceName.GetString() );
|
||||
|
||||
got_debug_info:
|
||||
OSVERSIONINFO version;
|
||||
version.dwOSVersionInfoSize=sizeof(version);
|
||||
GetVersionEx(&version);
|
||||
bool bIsWin9x = version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
|
||||
|
||||
LOG->Info("Video Driver Information:");
|
||||
LOG->Info("%-15s:\t%s", "Provider", info.sProvider.GetString());
|
||||
LOG->Info("%-15s:\t%s", "Description", info.sDescription.GetString());
|
||||
LOG->Info("%-15s:\t%s", "Version", info.sVersion.GetString());
|
||||
LOG->Info("%-15s:\t%s", "Date", info.sDate.GetString());
|
||||
LOG->Info("%-15s:\t%s", "DeviceID", info.sDeviceID.GetString());
|
||||
|
||||
HandleKnownTerribleDriver( info );
|
||||
for( int i=0; true; i++ )
|
||||
{
|
||||
VideoDriverInfo info;
|
||||
if( ! (bIsWin9x ? GetVideoDriverInfo9x : GetVideoDriverInfo2k)(i,info) )
|
||||
break;
|
||||
|
||||
if( sPrimaryDeviceName == "" ) // failed to get primary disaply name (NT4)
|
||||
{
|
||||
LogVideoDriverInfo( info );
|
||||
}
|
||||
else if( info.sDescription == sPrimaryDeviceName )
|
||||
{
|
||||
LogVideoDriverInfo( info );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static CString wo_ssprintf( MMRESULT err, const char *fmt, ...)
|
||||
|
||||
Reference in New Issue
Block a user