auto-cpu-data

This commit is contained in:
David Rose 2009-09-24 19:51:38 +00:00
parent fada2d5933
commit 0a0224f1ef
6 changed files with 75 additions and 39 deletions

View File

@ -147,3 +147,14 @@ DisplayInformation * GraphicsPipe::
get_display_information() { get_display_information() {
return _display_information; return _display_information;
} }
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::lookup_cpu_data
// Access: Public, Virtual
// Description: Looks up the detailed CPU information and stores it
// in _display_information, if supported by the OS.
// This may take a second or two.
////////////////////////////////////////////////////////////////////
void GraphicsPipe::
lookup_cpu_data() {
}

View File

@ -97,6 +97,7 @@ PUBLISHED:
INLINE int get_display_height() const; INLINE int get_display_height() const;
DisplayInformation *get_display_information(); DisplayInformation *get_display_information();
virtual void lookup_cpu_data();
virtual string get_interface_name() const=0; virtual string get_interface_name() const=0;

View File

@ -40,6 +40,12 @@ ConfigVariableBool do_vidmemsize_check
PRC_DESC("if true, use ddraw's GetAvailVidMem to fail if driver says " PRC_DESC("if true, use ddraw's GetAvailVidMem to fail if driver says "
"it has too little video mem")); "it has too little video mem"));
ConfigVariableBool auto_cpu_data
("auto-cpu-data", false,
PRC_DESC("Set this true to automatically get the CPU data at start; false to "
"require an explicit call to pipe->lookup_cpu_data(). Setting this "
"true may slow down startup time by 1-2 seconds."));
ConfigVariableBool ime_aware ConfigVariableBool ime_aware
("ime-aware", false, ("ime-aware", false,
PRC_DESC("Set this true to show ime texts on the chat panel and hide the " PRC_DESC("Set this true to show ime texts on the chat panel and hide the "

View File

@ -25,6 +25,7 @@ NotifyCategoryDecl(windisplay, EXPCL_PANDAWIN, EXPTP_PANDAWIN);
extern ConfigVariableBool responsive_minimized_fullscreen_window; extern ConfigVariableBool responsive_minimized_fullscreen_window;
extern ConfigVariableBool hold_keys_across_windows; extern ConfigVariableBool hold_keys_across_windows;
extern ConfigVariableBool do_vidmemsize_check; extern ConfigVariableBool do_vidmemsize_check;
extern ConfigVariableBool auto_cpu_data;
extern ConfigVariableBool ime_composition_w; extern ConfigVariableBool ime_composition_w;
extern ConfigVariableBool ime_aware; extern ConfigVariableBool ime_aware;
extern ConfigVariableBool ime_hide; extern ConfigVariableBool ime_hide;

View File

@ -836,7 +836,60 @@ WinGraphicsPipe() {
state = true; state = true;
} }
#endif #endif
if (auto_cpu_data) {
lookup_cpu_data();
}
OSVERSIONINFO version_info;
version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx (&version_info)) {
sprintf (string, "OS version: %d.%d.%d.%d \n", version_info.dwMajorVersion, version_info.dwMinorVersion, version_info.dwPlatformId, version_info.dwBuildNumber);
windisplay_cat.info() << string;
windisplay_cat.info() << " " << version_info.szCSDVersion << "\n";
_display_information -> _os_version_major = version_info.dwMajorVersion;
_display_information -> _os_version_minor = version_info.dwMinorVersion;
_display_information -> _os_version_build = version_info.dwBuildNumber;
_display_information -> _os_platform_id = version_info.dwPlatformId;
}
// Screen size
_display_width = GetSystemMetrics(SM_CXSCREEN);
_display_height = GetSystemMetrics(SM_CYSCREEN);
HMODULE power_dll;
power_dll = LoadLibrary ("PowrProf.dll");
if (power_dll) {
CallNtPowerInformationFunction = (CallNtPowerInformationType) GetProcAddress (power_dll, "CallNtPowerInformation");
if (CallNtPowerInformationFunction) {
_display_information -> _update_cpu_frequency_function = update_cpu_frequency_function;
update_cpu_frequency_function(0, _display_information);
sprintf (string, "max Mhz %I64d, current Mhz %I64d \n", _display_information -> _maximum_cpu_frequency, _display_information -> _current_cpu_frequency);
windisplay_cat.info() << string;
}
}
if (state) {
}
}
////////////////////////////////////////////////////////////////////
// Function: WinGraphicsPipe::lookup_cpu_data
// Access: Public, Virtual
// Description: Looks up the detailed CPU information and stores it
// in _display_information, if supported by the OS.
// This may take a second or two.
////////////////////////////////////////////////////////////////////
void WinGraphicsPipe::
lookup_cpu_data() {
char string [512];
// set callback for memory function // set callback for memory function
_display_information -> _get_memory_information_function = get_memory_information; _display_information -> _get_memory_information_function = get_memory_information;
@ -860,7 +913,6 @@ WinGraphicsPipe() {
HANDLE thread; HANDLE thread;
windisplay_cat.info() << "begin QueryPerformanceFrequency\n"; windisplay_cat.info() << "begin QueryPerformanceFrequency\n";
thread = GetCurrentThread(); thread = GetCurrentThread();
priority = GetThreadPriority (thread); priority = GetThreadPriority (thread);
SetThreadPriority(thread, THREAD_PRIORITY_TIME_CRITICAL); SetThreadPriority(thread, THREAD_PRIORITY_TIME_CRITICAL);
@ -881,12 +933,12 @@ WinGraphicsPipe() {
} }
SetThreadPriority(thread, priority); SetThreadPriority(thread, priority);
sprintf (string, "QueryPerformanceFrequency: %I64d\n", frequency.QuadPart); sprintf (string, "QueryPerformanceFrequency: %I64d\n", frequency.QuadPart);
windisplay_cat.info() << string; windisplay_cat.info() << string;
sprintf (string, "CPU frequency: %I64d\n", _display_information -> _cpu_frequency); sprintf (string, "CPU frequency: %I64d\n", _display_information -> _cpu_frequency);
windisplay_cat.info() << string; windisplay_cat.info() << string;
// CPUID // CPUID
CPU_ID cpu_id; CPU_ID cpu_id;
@ -937,43 +989,6 @@ WinGraphicsPipe() {
// Number of CPU's // Number of CPU's
count_number_of_cpus(_display_information); count_number_of_cpus(_display_information);
OSVERSIONINFO version_info;
version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx (&version_info)) {
sprintf (string, "OS version: %d.%d.%d.%d \n", version_info.dwMajorVersion, version_info.dwMinorVersion, version_info.dwPlatformId, version_info.dwBuildNumber);
windisplay_cat.info() << string;
windisplay_cat.info() << " " << version_info.szCSDVersion << "\n";
_display_information -> _os_version_major = version_info.dwMajorVersion;
_display_information -> _os_version_minor = version_info.dwMinorVersion;
_display_information -> _os_version_build = version_info.dwBuildNumber;
_display_information -> _os_platform_id = version_info.dwPlatformId;
}
// Screen size
_display_width = GetSystemMetrics(SM_CXSCREEN);
_display_height = GetSystemMetrics(SM_CYSCREEN);
HMODULE power_dll;
power_dll = LoadLibrary ("PowrProf.dll");
if (power_dll) {
CallNtPowerInformationFunction = (CallNtPowerInformationType) GetProcAddress (power_dll, "CallNtPowerInformation");
if (CallNtPowerInformationFunction) {
_display_information -> _update_cpu_frequency_function = update_cpu_frequency_function;
update_cpu_frequency_function(0, _display_information);
sprintf (string, "max Mhz %I64d, current Mhz %I64d \n", _display_information -> _maximum_cpu_frequency, _display_information -> _current_cpu_frequency);
windisplay_cat.info() << string;
}
}
if (state) {
}
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -37,6 +37,8 @@ public:
WinGraphicsPipe(); WinGraphicsPipe();
virtual ~WinGraphicsPipe(); virtual ~WinGraphicsPipe();
virtual void lookup_cpu_data();
private: private:
HINSTANCE _hUser32; HINSTANCE _hUser32;
typedef BOOL (WINAPI *PFN_TRACKMOUSEEVENT)(LPTRACKMOUSEEVENT); typedef BOOL (WINAPI *PFN_TRACKMOUSEEVENT)(LPTRACKMOUSEEVENT);